diff options
Diffstat (limited to 'scene/3d')
34 files changed, 245 insertions, 240 deletions
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 4089d80d4e..21f471039f 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -169,7 +169,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_entered, node); } @@ -196,7 +196,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); if (E->get().in_tree) emit_signal(SceneStringNames::get_singleton()->body_exited, obj); } @@ -246,7 +246,7 @@ void Area::_clear_monitoring() { emit_signal(SceneStringNames::get_singleton()->body_exited, obj); node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); } } @@ -276,7 +276,7 @@ void Area::_clear_monitoring() { emit_signal(SceneStringNames::get_singleton()->area_exited, obj); node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree); } } } @@ -366,7 +366,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree, make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_entered, node); } @@ -393,7 +393,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_exited, obj); } diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index cf2a47f14c..d448ef024d 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -57,18 +57,18 @@ void AudioStreamPlayer3D::_mix_audio() { //mix if (output_count > 0 || out_of_range_mode == OUT_OF_RANGE_MIX) { - float pitch_scale = 0.0; + float output_pitch_scale = 0.0; if (output_count) { //used for doppler, not realistic but good enough for (int i = 0; i < output_count; i++) { - pitch_scale += outputs[i].pitch_scale; + output_pitch_scale += outputs[i].pitch_scale; } - pitch_scale /= float(output_count); + output_pitch_scale /= float(output_count); } else { - pitch_scale = 1.0; + output_pitch_scale = 1.0; } - stream_playback->mix(buffer, pitch_scale, buffer_size); + stream_playback->mix(buffer, pitch_scale * output_pitch_scale, buffer_size); } //write all outputs @@ -320,7 +320,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { total_max = MAX(total_max, cam_area_pos.length()); } if (total_max > max_distance) { - continue; //cant hear this sound in this camera + continue; //can't hear this sound in this camera } } @@ -607,6 +607,13 @@ float AudioStreamPlayer3D::get_max_db() const { return max_db; } +void AudioStreamPlayer3D::set_pitch_scale(float p_pitch_scale) { + pitch_scale = p_pitch_scale; +} +float AudioStreamPlayer3D::get_pitch_scale() const { + return pitch_scale; +} + void AudioStreamPlayer3D::play(float p_from_pos) { if (stream_playback.is_valid()) { @@ -832,6 +839,9 @@ void AudioStreamPlayer3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_max_db", "max_db"), &AudioStreamPlayer3D::set_max_db); ClassDB::bind_method(D_METHOD("get_max_db"), &AudioStreamPlayer3D::get_max_db); + ClassDB::bind_method(D_METHOD("set_pitch_scale", "pitch_scale"), &AudioStreamPlayer3D::set_pitch_scale); + ClassDB::bind_method(D_METHOD("get_pitch_scale"), &AudioStreamPlayer3D::get_pitch_scale); + ClassDB::bind_method(D_METHOD("play", "from_position"), &AudioStreamPlayer3D::play, DEFVAL(0.0)); ClassDB::bind_method(D_METHOD("seek", "to_position"), &AudioStreamPlayer3D::seek); ClassDB::bind_method(D_METHOD("stop"), &AudioStreamPlayer3D::stop); @@ -885,6 +895,7 @@ void AudioStreamPlayer3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_db", PROPERTY_HINT_RANGE, "-80,80"), "set_unit_db", "get_unit_db"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_size", PROPERTY_HINT_RANGE, "0.1,100,0.1"), "set_unit_size", "get_unit_size"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_db", PROPERTY_HINT_RANGE, "-24,6"), "set_max_db", "get_max_db"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "pitch_scale", PROPERTY_HINT_RANGE, "0.01,32,0.01"), "set_pitch_scale", "get_pitch_scale"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "is_playing"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "0,65536,1"), "set_max_distance", "get_max_distance"); @@ -921,6 +932,7 @@ AudioStreamPlayer3D::AudioStreamPlayer3D() { unit_size = 1; attenuation_model = ATTENUATION_INVERSE_DISTANCE; max_db = 3; + pitch_scale = 1.0; autoplay = false; setseek = -1; active = false; diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h index 9a1f369da2..1fcb83cf21 100644 --- a/scene/3d/audio_stream_player_3d.h +++ b/scene/3d/audio_stream_player_3d.h @@ -106,6 +106,7 @@ private: float unit_db; float unit_size; float max_db; + float pitch_scale; bool autoplay; StringName bus; @@ -153,6 +154,9 @@ public: void set_max_db(float p_boost); float get_max_db() const; + void set_pitch_scale(float p_pitch_scale); + float get_pitch_scale() const; + void play(float p_from_pos = 0.0); void seek(float p_seconds); void stop(); diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index 96eb7eb6f4..fa4e6492a1 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -170,11 +170,11 @@ void BakedLightmapData::_bind_methods() { ClassDB::bind_method(D_METHOD("clear_users"), &BakedLightmapData::clear_users); ADD_PROPERTY(PropertyInfo(Variant::AABB, "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bounds", "get_bounds"); - ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "octree", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_octree", "get_octree"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "cell_space_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_cell_space_transform", "get_cell_space_transform"); ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_subdiv", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_cell_subdiv", "get_cell_subdiv"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_energy", "get_energy"); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "user_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_user_data", "_get_user_data"); + ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "octree", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_octree", "get_octree"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "user_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_user_data", "_get_user_data"); } BakedLightmapData::BakedLightmapData() { @@ -784,7 +784,7 @@ void BakedLightmap::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "capture_cell_size", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_capture_cell_size", "get_capture_cell_size"); ADD_GROUP("Data", ""); ADD_PROPERTY(PropertyInfo(Variant::STRING, "image_path", PROPERTY_HINT_DIR), "set_image_path", "get_image_path"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light_data", PROPERTY_HINT_RESOURCE_TYPE, "BakedIndirectLightData"), "set_light_data", "get_light_data"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light_data", PROPERTY_HINT_RESOURCE_TYPE, "BakedLightmapData"), "set_light_data", "get_light_data"); BIND_ENUM_CONSTANT(BAKE_QUALITY_LOW); BIND_ENUM_CONSTANT(BAKE_QUALITY_MEDIUM); diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp index 3882b8548b..a875b65c22 100644 --- a/scene/3d/bone_attachment.cpp +++ b/scene/3d/bone_attachment.cpp @@ -30,43 +30,27 @@ #include "bone_attachment.h" -bool BoneAttachment::_get(const StringName &p_name, Variant &r_ret) const { +void BoneAttachment::_validate_property(PropertyInfo &property) const { - if (String(p_name) == "bone_name") { + if (property.name == "bone_name") { + Skeleton *parent = Object::cast_to<Skeleton>(get_parent()); - r_ret = get_bone_name(); - return true; - } - - return false; -} -bool BoneAttachment::_set(const StringName &p_name, const Variant &p_value) { - - if (String(p_name) == "bone_name") { - - set_bone_name(p_value); - return true; - } + if (parent) { - return false; -} -void BoneAttachment::_get_property_list(List<PropertyInfo> *p_list) const { - - Skeleton *parent = Object::cast_to<Skeleton>(get_parent()); + String names; + for (int i = 0; i < parent->get_bone_count(); i++) { + if (i > 0) + names += ","; + names += parent->get_bone_name(i); + } - if (parent) { + property.hint = PROPERTY_HINT_ENUM; + property.hint_string = names; + } else { - String names; - for (int i = 0; i < parent->get_bone_count(); i++) { - if (i > 0) - names += ","; - names += parent->get_bone_name(i); + property.hint = PROPERTY_HINT_NONE; + property.hint_string = ""; } - - p_list->push_back(PropertyInfo(Variant::STRING, "bone_name", PROPERTY_HINT_ENUM, names)); - } else { - - p_list->push_back(PropertyInfo(Variant::STRING, "bone_name")); } } @@ -138,4 +122,6 @@ BoneAttachment::BoneAttachment() { void BoneAttachment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bone_name", "bone_name"), &BoneAttachment::set_bone_name); ClassDB::bind_method(D_METHOD("get_bone_name"), &BoneAttachment::get_bone_name); + + ADD_PROPERTY(PropertyInfo(Variant::STRING, "bone_name"), "set_bone_name", "get_bone_name"); } diff --git a/scene/3d/bone_attachment.h b/scene/3d/bone_attachment.h index fa31642354..81a225015e 100644 --- a/scene/3d/bone_attachment.h +++ b/scene/3d/bone_attachment.h @@ -44,9 +44,7 @@ class BoneAttachment : public Spatial { void _check_unbind(); protected: - bool _get(const StringName &p_name, Variant &r_ret) const; - bool _set(const StringName &p_name, const Variant &p_value); - void _get_property_list(List<PropertyInfo> *p_list) const; + virtual void _validate_property(PropertyInfo &property) const; void _notification(int p_what); static void _bind_methods(); diff --git a/scene/3d/camera.h b/scene/3d/camera.h index 3fd3303a25..e2679870de 100644 --- a/scene/3d/camera.h +++ b/scene/3d/camera.h @@ -97,7 +97,7 @@ protected: void _update_camera_mode(); void _notification(int p_what); - virtual void _validate_property(PropertyInfo &property) const; + virtual void _validate_property(PropertyInfo &p_property) const; static void _bind_methods(); diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index b246fe75f4..07235b3da4 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -365,6 +365,20 @@ bool CollisionObject::get_capture_input_on_drag() const { return capture_input_on_drag; } +String CollisionObject::get_configuration_warning() const { + + String warning = Spatial::get_configuration_warning(); + + if (shapes.empty()) { + if (warning == String()) { + warning += "\n"; + } + warning += TTR("This node has no children shapes, so it can't interact with the space.\nConsider adding CollisionShape or CollisionPolygon children nodes to define its shape."); + } + + return warning; +} + CollisionObject::CollisionObject() { capture_input_on_drag = false; diff --git a/scene/3d/collision_object.h b/scene/3d/collision_object.h index c58e02848f..f31d65e411 100644 --- a/scene/3d/collision_object.h +++ b/scene/3d/collision_object.h @@ -109,6 +109,8 @@ public: _FORCE_INLINE_ RID get_rid() const { return rid; } + virtual String get_configuration_warning() const; + CollisionObject(); ~CollisionObject(); }; diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp index ef1b33a4e2..3a77360bc2 100644 --- a/scene/3d/collision_polygon.cpp +++ b/scene/3d/collision_polygon.cpp @@ -73,6 +73,14 @@ void CollisionPolygon::_build_polygon() { } } +void CollisionPolygon::_update_in_shape_owner(bool p_xform_only) { + + parent->shape_owner_set_transform(owner_id, get_transform()); + if (p_xform_only) + return; + parent->shape_owner_set_disabled(owner_id, disabled); +} + void CollisionPolygon::_notification(int p_what) { switch (p_what) { @@ -82,14 +90,20 @@ void CollisionPolygon::_notification(int p_what) { if (parent) { owner_id = parent->create_shape_owner(this); _build_polygon(); - parent->shape_owner_set_transform(owner_id, get_transform()); - parent->shape_owner_set_disabled(owner_id, disabled); + _update_in_shape_owner(); } } break; + case NOTIFICATION_ENTER_TREE: { + + if (parent) { + _update_in_shape_owner(); + } + + } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { if (parent) { - parent->shape_owner_set_transform(owner_id, get_transform()); + _update_in_shape_owner(true); } } break; diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h index 6643cfa044..971c67f1ad 100644 --- a/scene/3d/collision_polygon.h +++ b/scene/3d/collision_polygon.h @@ -51,6 +51,8 @@ protected: void _build_polygon(); + void _update_in_shape_owner(bool p_xform_only = false); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp index d6d49a197c..943f4158f7 100644 --- a/scene/3d/collision_shape.cpp +++ b/scene/3d/collision_shape.cpp @@ -64,6 +64,14 @@ void CollisionShape::make_convex_from_brothers() { } } +void CollisionShape::_update_in_shape_owner(bool p_xform_only) { + + parent->shape_owner_set_transform(owner_id, get_transform()); + if (p_xform_only) + return; + parent->shape_owner_set_disabled(owner_id, disabled); +} + void CollisionShape::_notification(int p_what) { switch (p_what) { @@ -75,19 +83,20 @@ void CollisionShape::_notification(int p_what) { if (shape.is_valid()) { parent->shape_owner_add_shape(owner_id, shape); } - parent->shape_owner_set_transform(owner_id, get_transform()); - parent->shape_owner_set_disabled(owner_id, disabled); + _update_in_shape_owner(); } } break; case NOTIFICATION_ENTER_TREE: { + if (parent) { + _update_in_shape_owner(); + } if (get_tree()->is_debugging_collisions_hint()) { _create_debug_shape(); } - } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { if (parent) { - parent->shape_owner_set_transform(owner_id, get_transform()); + _update_in_shape_owner(true); } } break; case NOTIFICATION_UNPARENTED: { diff --git a/scene/3d/collision_shape.h b/scene/3d/collision_shape.h index 724a025165..c9c91a5824 100644 --- a/scene/3d/collision_shape.h +++ b/scene/3d/collision_shape.h @@ -51,6 +51,8 @@ class CollisionShape : public Spatial { void _create_debug_shape(); + void _update_in_shape_owner(bool p_xform_only = false); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index ce9e801385..4ad2eb60ee 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -535,7 +535,7 @@ void GIProbe::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "normal_bias", PROPERTY_HINT_RANGE, "0,4,0.001"), "set_normal_bias", "get_normal_bias"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_interior", "is_interior"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "compress"), "set_compress", "is_compressed"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "GIProbeData"), "set_probe_data", "get_probe_data"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "GIProbeData", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE), "set_probe_data", "get_probe_data"); BIND_ENUM_CONSTANT(SUBDIV_64); BIND_ENUM_CONSTANT(SUBDIV_128); diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp index 5ec5b8b6c7..073e56fdb4 100644 --- a/scene/3d/navigation_mesh.cpp +++ b/scene/3d/navigation_mesh.cpp @@ -405,8 +405,8 @@ void NavigationMesh::_bind_methods() { BIND_CONSTANT(SAMPLE_PARTITION_MONOTONE); BIND_CONSTANT(SAMPLE_PARTITION_LAYERS); - ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_vertices", "get_vertices"); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "polygons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_polygons", "_get_polygons"); + ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_vertices", "get_vertices"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "polygons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_polygons", "_get_polygons"); ADD_PROPERTY(PropertyInfo(Variant::INT, "sample_partition_type/sample_partition_type", PROPERTY_HINT_ENUM, "Watershed,Monotone,Layers"), "set_sample_partition_type", "get_sample_partition_type"); diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 219464ae1f..8617bbc2f6 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -1597,4 +1597,21 @@ ParticlesMaterial::ParticlesMaterial() : } ParticlesMaterial::~ParticlesMaterial() { + + if (material_mutex) + material_mutex->lock(); + + if (shader_map.has(current_key)) { + shader_map[current_key].users--; + if (shader_map[current_key].users == 0) { + //deallocate shader, as it's no longer in use + VS::get_singleton()->free(shader_map[current_key].shader); + shader_map.erase(current_key); + } + + VS::get_singleton()->material_set_shader(_get_material(), RID()); + } + + if (material_mutex) + material_mutex->unlock(); } diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp index afe4dd3f46..7ac7f74bb0 100644 --- a/scene/3d/path.cpp +++ b/scene/3d/path.cpp @@ -190,61 +190,16 @@ bool PathFollow::get_cubic_interpolation() const { return cubic; } -bool PathFollow::_set(const StringName &p_name, const Variant &p_value) { - - if (p_name == SceneStringNames::get_singleton()->offset) { - set_offset(p_value); - } else if (p_name == SceneStringNames::get_singleton()->unit_offset) { - set_unit_offset(p_value); - } else if (p_name == SceneStringNames::get_singleton()->rotation_mode) { - set_rotation_mode(RotationMode(p_value.operator int())); - } else if (p_name == SceneStringNames::get_singleton()->v_offset) { - set_v_offset(p_value); - } else if (p_name == SceneStringNames::get_singleton()->h_offset) { - set_h_offset(p_value); - } else if (String(p_name) == "cubic_interp") { - set_cubic_interpolation(p_value); - } else if (String(p_name) == "loop") { - set_loop(p_value); - } else - return false; - - return true; -} +void PathFollow::_validate_property(PropertyInfo &property) const { -bool PathFollow::_get(const StringName &p_name, Variant &r_ret) const { - - if (p_name == SceneStringNames::get_singleton()->offset) { - r_ret = get_offset(); - } else if (p_name == SceneStringNames::get_singleton()->unit_offset) { - r_ret = get_unit_offset(); - } else if (p_name == SceneStringNames::get_singleton()->rotation_mode) { - r_ret = get_rotation_mode(); - } else if (p_name == SceneStringNames::get_singleton()->v_offset) { - r_ret = get_v_offset(); - } else if (p_name == SceneStringNames::get_singleton()->h_offset) { - r_ret = get_h_offset(); - } else if (String(p_name) == "cubic_interp") { - r_ret = cubic; - } else if (String(p_name) == "loop") { - r_ret = loop; - } else - return false; - - return true; -} -void PathFollow::_get_property_list(List<PropertyInfo> *p_list) const { - - float max = 10000; - if (path && path->get_curve().is_valid()) - max = path->get_curve()->get_baked_length(); - p_list->push_back(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0," + rtos(max) + ",0.01")); - p_list->push_back(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001", PROPERTY_USAGE_EDITOR)); - p_list->push_back(PropertyInfo(Variant::REAL, "h_offset")); - p_list->push_back(PropertyInfo(Variant::REAL, "v_offset")); - p_list->push_back(PropertyInfo(Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM, "None,Y,XY,XYZ")); - p_list->push_back(PropertyInfo(Variant::BOOL, "cubic_interp")); - p_list->push_back(PropertyInfo(Variant::BOOL, "loop")); + if (property.name == "offset") { + + float max = 10000; + if (path && path->get_curve().is_valid()) + max = path->get_curve()->get_baked_length(); + + property.hint_string = "0," + rtos(max) + ",0.01"; + } } void PathFollow::_bind_methods() { @@ -270,6 +225,14 @@ void PathFollow::_bind_methods() { ClassDB::bind_method(D_METHOD("set_loop", "loop"), &PathFollow::set_loop); ClassDB::bind_method(D_METHOD("has_loop"), &PathFollow::has_loop); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0,10000,0.01"), "set_offset", "get_offset"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001", PROPERTY_USAGE_EDITOR), "set_unit_offset", "get_unit_offset"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "h_offset"), "set_h_offset", "get_h_offset"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_offset"), "set_v_offset", "get_v_offset"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM, "None,Y,XY,XYZ"), "set_rotation_mode", "get_rotation_mode"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cubic_interp"), "set_cubic_interpolation", "get_cubic_interpolation"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop"), "set_loop", "has_loop"); + BIND_ENUM_CONSTANT(ROTATION_NONE); BIND_ENUM_CONSTANT(ROTATION_Y); BIND_ENUM_CONSTANT(ROTATION_XY); diff --git a/scene/3d/path.h b/scene/3d/path.h index fe57103d25..2ed686ac3c 100644 --- a/scene/3d/path.h +++ b/scene/3d/path.h @@ -79,9 +79,7 @@ private: void _update_transform(); protected: - bool _set(const StringName &p_name, const Variant &p_value); - bool _get(const StringName &p_name, Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; + virtual void _validate_property(PropertyInfo &property) const; void _notification(int p_what); static void _bind_methods(); diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 7d638d8737..25acd6deb0 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -258,6 +258,7 @@ void RigidBody::_body_enter_tree(ObjectID p_id) { Node *node = Object::cast_to<Node>(obj); ERR_FAIL_COND(!node); + ERR_FAIL_COND(!contact_monitor); Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id); ERR_FAIL_COND(!E); ERR_FAIL_COND(E->get().in_tree); @@ -281,6 +282,7 @@ void RigidBody::_body_exit_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); Node *node = Object::cast_to<Node>(obj); ERR_FAIL_COND(!node); + ERR_FAIL_COND(!contact_monitor); Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id); ERR_FAIL_COND(!E); ERR_FAIL_COND(!E->get().in_tree); @@ -306,6 +308,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, Object *obj = ObjectDB::get_instance(objid); Node *node = Object::cast_to<Node>(obj); + ERR_FAIL_COND(!contact_monitor); Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(objid); ERR_FAIL_COND(!body_in && !E); @@ -318,7 +321,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_entered, node); } @@ -345,7 +348,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); - node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); if (in_tree) emit_signal(SceneStringNames::get_singleton()->body_exited, obj); } @@ -719,6 +722,14 @@ void RigidBody::set_contact_monitor(bool p_enabled) { for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) { //clean up mess + Object *obj = ObjectDB::get_instance(E->key()); + Node *node = Object::cast_to<Node>(obj); + + if (node) { + + node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree); + } } memdelete(contact_monitor); @@ -772,7 +783,7 @@ String RigidBody::get_configuration_warning() const { if (warning != String()) { warning += "\n"; } - warning += TTR("Size changes to RigidBody (in character or rigid modes) will be overriden by the physics engine when running.\nChange the size in children collision shapes instead."); + warning += TTR("Size changes to RigidBody (in character or rigid modes) will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."); } return warning; diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 332eb3c740..c7556c0c5f 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -115,7 +115,7 @@ public: MODE_KINEMATIC, }; -private: +protected: bool can_sleep; PhysicsDirectBodyState *state; Mode mode; @@ -178,9 +178,8 @@ private: void _body_exit_tree(ObjectID p_id); void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape); - void _direct_state_changed(Object *p_state); + virtual void _direct_state_changed(Object *p_state); -protected: void _notification(int p_what); static void _bind_methods(); diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp index fed6d76f65..2e9f1a241a 100644 --- a/scene/3d/physics_joint.cpp +++ b/scene/3d/physics_joint.cpp @@ -71,8 +71,7 @@ void Joint::_update_joint(bool p_only_free) { ba = body_a->get_rid(); bb = body_b->get_rid(); - if (exclude_from_collision) - PhysicsServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid()); + PhysicsServer::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision); } void Joint::set_node_a(const NodePath &p_node_a) { diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group.cpp index f719a0356b..101d9ed70c 100644 --- a/scene/3d/proximity_group.cpp +++ b/scene/3d/proximity_group.cpp @@ -112,11 +112,6 @@ void ProximityGroup::_new_group(StringName p_name) { groups[p_name] = group_version; }; -void ProximityGroup::set_group_name(String p_group_name) { - - group_name = p_group_name; -}; - void ProximityGroup::_notification(int p_what) { switch (p_what) { @@ -153,9 +148,24 @@ void ProximityGroup::_proximity_group_broadcast(String p_name, Variant p_params) }; }; -void ProximityGroup::set_dispatch_mode(int p_mode) { +void ProximityGroup::set_group_name(const String &p_group_name) { + + group_name = p_group_name; +}; + +String ProximityGroup::get_group_name() const { - dispatch_mode = (DispatchMode)p_mode; + return group_name; +}; + +void ProximityGroup::set_dispatch_mode(DispatchMode p_mode) { + + dispatch_mode = p_mode; +}; + +ProximityGroup::DispatchMode ProximityGroup::get_dispatch_mode() const { + + return dispatch_mode; }; void ProximityGroup::set_grid_radius(const Vector3 &p_radius) { @@ -171,15 +181,22 @@ Vector3 ProximityGroup::get_grid_radius() const { void ProximityGroup::_bind_methods() { ClassDB::bind_method(D_METHOD("set_group_name", "name"), &ProximityGroup::set_group_name); - ClassDB::bind_method(D_METHOD("broadcast", "name", "parameters"), &ProximityGroup::broadcast); + ClassDB::bind_method(D_METHOD("get_group_name"), &ProximityGroup::get_group_name); ClassDB::bind_method(D_METHOD("set_dispatch_mode", "mode"), &ProximityGroup::set_dispatch_mode); - ClassDB::bind_method(D_METHOD("_proximity_group_broadcast", "name", "params"), &ProximityGroup::_proximity_group_broadcast); + ClassDB::bind_method(D_METHOD("get_dispatch_mode"), &ProximityGroup::get_dispatch_mode); ClassDB::bind_method(D_METHOD("set_grid_radius", "radius"), &ProximityGroup::set_grid_radius); ClassDB::bind_method(D_METHOD("get_grid_radius"), &ProximityGroup::get_grid_radius); + ClassDB::bind_method(D_METHOD("broadcast", "name", "parameters"), &ProximityGroup::broadcast); + ClassDB::bind_method(D_METHOD("_proximity_group_broadcast", "name", "params"), &ProximityGroup::_proximity_group_broadcast); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "group_name"), "set_group_name", "get_group_name"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "dispatch_mode", PROPERTY_HINT_ENUM, "Proxy,Signal"), "set_dispatch_mode", "get_dispatch_mode"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "grid_radius"), "set_grid_radius", "get_grid_radius"); - ADD_SIGNAL(MethodInfo("broadcast", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::ARRAY, "parameters"))); + ADD_SIGNAL(MethodInfo("broadcast", PropertyInfo(Variant::STRING, "group_name"), PropertyInfo(Variant::ARRAY, "parameters"))); + + BIND_ENUM_CONSTANT(MODE_PROXY); + BIND_ENUM_CONSTANT(MODE_SIGNAL); }; ProximityGroup::ProximityGroup() { diff --git a/scene/3d/proximity_group.h b/scene/3d/proximity_group.h index aae44e0be5..448f30bf80 100644 --- a/scene/3d/proximity_group.h +++ b/scene/3d/proximity_group.h @@ -67,15 +67,21 @@ public: static void _bind_methods(); public: - void set_group_name(String p_group_name); - void broadcast(String p_name, Variant p_params); - void set_dispatch_mode(int p_mode); + void set_group_name(const String &p_group_name); + String get_group_name() const; + + void set_dispatch_mode(DispatchMode p_mode); + DispatchMode get_dispatch_mode() const; void set_grid_radius(const Vector3 &p_radius); Vector3 get_grid_radius() const; + void broadcast(String p_name, Variant p_params); + ProximityGroup(); ~ProximityGroup(); }; +VARIANT_ENUM_CAST(ProximityGroup::DispatchMode); + #endif diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index 556774a0d1..dd5ae8a999 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -217,6 +217,8 @@ void RayCast::_update_raycast_state() { against_shape = rr.shape; } else { collided = false; + against = 0; + against_shape = 0; } } diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index 9e3a9ac27f..2178da02b5 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -195,7 +195,7 @@ void ReflectionProbe::_validate_property(PropertyInfo &property) const { if (property.name == "interior/ambient_color" || property.name == "interior/ambient_energy" || property.name == "interior/ambient_contrib") { if (!interior) { - property.usage = PROPERTY_USAGE_NOEDITOR; + property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; } } } diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 99541db4d3..d3a13c741e 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -61,7 +61,7 @@ bool Skeleton::_set(const StringName &p_path, const Variant &p_value) { set_bone_enabled(which, p_value); else if (what == "pose") set_bone_pose(which, p_value); - else if (what == "bound_childs") { + else if (what == "bound_children") { Array children = p_value; if (is_inside_tree()) { @@ -105,7 +105,7 @@ bool Skeleton::_get(const StringName &p_path, Variant &r_ret) const { r_ret = is_bone_enabled(which); else if (what == "pose") r_ret = get_bone_pose(which); - else if (what == "bound_childs") { + else if (what == "bound_children") { Array children; for (const List<uint32_t>::Element *E = bones[which].nodes_bound.front(); E; E = E->next()) { @@ -134,7 +134,7 @@ void Skeleton::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "rest")); p_list->push_back(PropertyInfo(Variant::BOOL, prep + "enabled")); p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "pose", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); - p_list->push_back(PropertyInfo(Variant::ARRAY, prep + "bound_childs")); + p_list->push_back(PropertyInfo(Variant::ARRAY, prep + "bound_children")); } } diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h index de0d4216d9..d693670055 100644 --- a/scene/3d/skeleton.h +++ b/scene/3d/skeleton.h @@ -83,12 +83,12 @@ class Skeleton : public Spatial { Array _get_bound_child_nodes_to_bone(int p_bone) const { Array bound; - List<Node *> childs; - get_bound_child_nodes_to_bone(p_bone, &childs); + List<Node *> children; + get_bound_child_nodes_to_bone(p_bone, &children); - for (int i = 0; i < childs.size(); i++) { + for (int i = 0; i < children.size(); i++) { - bound.push_back(childs[i]); + bound.push_back(children[i]); } return bound; } diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index b3740dba68..721641e09b 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -788,7 +788,9 @@ void Spatial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale"); ADD_GROUP("Visibility", ""); ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible"); - //ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/local"), "set_transform", "get_transform") ; +#ifdef TOOLS_ENABLED + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "SpatialGizmo", 0), "set_gizmo", "get_gizmo"); +#endif ADD_SIGNAL(MethodInfo("visibility_changed")); } diff --git a/scene/3d/spatial_velocity_tracker.cpp b/scene/3d/spatial_velocity_tracker.cpp index 75da3a7911..c547e76e30 100644 --- a/scene/3d/spatial_velocity_tracker.cpp +++ b/scene/3d/spatial_velocity_tracker.cpp @@ -125,6 +125,8 @@ void SpatialVelocityTracker::_bind_methods() { ClassDB::bind_method(D_METHOD("update_position", "position"), &SpatialVelocityTracker::update_position); ClassDB::bind_method(D_METHOD("get_tracked_linear_velocity"), &SpatialVelocityTracker::get_tracked_linear_velocity); ClassDB::bind_method(D_METHOD("reset", "position"), &SpatialVelocityTracker::reset); + + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "track_physics_step"), "set_track_physics_step", "is_tracking_physics_step"); } SpatialVelocityTracker::SpatialVelocityTracker() { diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index bc968b0a5f..ed3bde9504 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -375,7 +375,7 @@ void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) { Basis steeringMat(up, steering); - Basis rotatingMat(right, -wheel.m_rotation); + Basis rotatingMat(right, wheel.m_rotation); /* if (p_idx==1) @@ -572,7 +572,7 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec b2invmass); // FIXME: rel_vel assignment here is overwritten by the following assignment. - // What seemes to be intented in the next next assignment is: rel_vel = normal.dot(rel_vel); + // What seemes to be intended in the next next assignment is: rel_vel = normal.dot(rel_vel); // Investigate why. real_t rel_vel = jac.getRelativeVelocity( s->get_linear_velocity(), @@ -816,26 +816,24 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) { void VehicleBody::_direct_state_changed(Object *p_state) { - PhysicsDirectBodyState *s = Object::cast_to<PhysicsDirectBodyState>(p_state); + RigidBody::_direct_state_changed(p_state); - set_ignore_transform_notification(true); - set_global_transform(s->get_transform()); - set_ignore_transform_notification(false); + state = Object::cast_to<PhysicsDirectBodyState>(p_state); - float step = s->get_step(); + float step = state->get_step(); for (int i = 0; i < wheels.size(); i++) { - _update_wheel(i, s); + _update_wheel(i, state); } for (int i = 0; i < wheels.size(); i++) { - _ray_cast(i, s); - wheels[i]->set_transform(s->get_transform().inverse() * wheels[i]->m_worldTransform); + _ray_cast(i, state); + wheels[i]->set_transform(state->get_transform().inverse() * wheels[i]->m_worldTransform); } - _update_suspension(s); + _update_suspension(state); for (int i = 0; i < wheels.size(); i++) { @@ -848,21 +846,21 @@ void VehicleBody::_direct_state_changed(Object *p_state) { suspensionForce = wheel.m_maxSuspensionForce; } Vector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step; - Vector3 relpos = wheel.m_raycastInfo.m_contactPointWS - s->get_transform().origin; + Vector3 relpos = wheel.m_raycastInfo.m_contactPointWS - state->get_transform().origin; - s->apply_impulse(relpos, impulse); + state->apply_impulse(relpos, impulse); //getRigidBody()->applyImpulse(impulse, relpos); } - _update_friction(s); + _update_friction(state); for (int i = 0; i < wheels.size(); i++) { VehicleWheel &wheel = *wheels[i]; - Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - s->get_transform().origin; - Vector3 vel = s->get_linear_velocity() + (s->get_angular_velocity()).cross(relpos); // * mPos); + Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - state->get_transform().origin; + Vector3 vel = state->get_linear_velocity() + (state->get_angular_velocity()).cross(relpos); // * mPos); if (wheel.m_raycastInfo.m_isInContact) { - const Transform &chassisWorldTransform = s->get_transform(); + const Transform &chassisWorldTransform = state->get_transform(); Vector3 fwd( chassisWorldTransform.basis[0][Vector3::AXIS_Z], @@ -883,29 +881,8 @@ void VehicleBody::_direct_state_changed(Object *p_state) { wheel.m_deltaRotation *= real_t(0.99); //damping of rotation when not in contact } - linear_velocity = s->get_linear_velocity(); -} - -void VehicleBody::set_mass(real_t p_mass) { - - mass = p_mass; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_MASS, mass); -} - -real_t VehicleBody::get_mass() const { - return mass; -} - -void VehicleBody::set_friction(real_t p_friction) { - - friction = p_friction; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, friction); -} - -real_t VehicleBody::get_friction() const { - - return friction; + state = NULL; } void VehicleBody::set_engine_force(float p_engine_force) { @@ -936,18 +913,8 @@ float VehicleBody::get_steering() const { return m_steeringValue; } -Vector3 VehicleBody::get_linear_velocity() const { - return linear_velocity; -} - void VehicleBody::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_mass", "mass"), &VehicleBody::set_mass); - ClassDB::bind_method(D_METHOD("get_mass"), &VehicleBody::get_mass); - - ClassDB::bind_method(D_METHOD("set_friction", "friction"), &VehicleBody::set_friction); - ClassDB::bind_method(D_METHOD("get_friction"), &VehicleBody::get_friction); - ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleBody::set_engine_force); ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleBody::get_engine_force); @@ -957,21 +924,14 @@ void VehicleBody::_bind_methods() { ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleBody::set_steering); ClassDB::bind_method(D_METHOD("get_steering"), &VehicleBody::get_steering); - ClassDB::bind_method(D_METHOD("get_linear_velocity"), &VehicleBody::get_linear_velocity); - - ClassDB::bind_method(D_METHOD("_direct_state_changed"), &VehicleBody::_direct_state_changed); - ADD_GROUP("Motion", ""); ADD_PROPERTY(PropertyInfo(Variant::REAL, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01"), "set_engine_force", "get_engine_force"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "brake", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_brake", "get_brake"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering"); - ADD_GROUP("Mass", ""); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_RANGE, "0.01,65536,0.01"), "set_mass", "get_mass"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0.01,1,0.01"), "set_friction", "get_friction"); } VehicleBody::VehicleBody() : - PhysicsBody(PhysicsServer::BODY_MODE_RIGID) { + RigidBody() { m_pitchControl = 0; m_currentVehicleSpeedKmHour = real_t(0.); @@ -982,10 +942,11 @@ VehicleBody::VehicleBody() : friction = 1; + state = NULL; ccd = false; exclude.insert(get_rid()); - PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); + //PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); set_mass(40); } diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h index 1c7dacf5ac..7810a42e8a 100644 --- a/scene/3d/vehicle_body.h +++ b/scene/3d/vehicle_body.h @@ -139,20 +139,13 @@ public: VehicleWheel(); }; -class VehicleBody : public PhysicsBody { +class VehicleBody : public RigidBody { - GDCLASS(VehicleBody, PhysicsBody); - - real_t mass; - real_t friction; + GDCLASS(VehicleBody, RigidBody); float engine_force; float brake; - Vector3 linear_velocity; - Vector3 angular_velocity; - bool ccd; - real_t m_pitchControl; real_t m_steeringValue; real_t m_currentVehicleSpeedKmHour; @@ -192,12 +185,6 @@ class VehicleBody : public PhysicsBody { void _direct_state_changed(Object *p_state); public: - void set_mass(real_t p_mass); - real_t get_mass() const; - - void set_friction(real_t p_friction); - real_t get_friction() const; - void set_engine_force(float p_engine_force); float get_engine_force() const; @@ -207,8 +194,6 @@ public: void set_steering(float p_steering); float get_steering() const; - Vector3 get_linear_velocity() const; - VehicleBody(); }; diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp index a8818a06c3..9d6e4941f3 100644 --- a/scene/3d/visibility_notifier.cpp +++ b/scene/3d/visibility_notifier.cpp @@ -170,7 +170,7 @@ void VisibilityEnabler::_find_nodes(Node *p_node) { if (add) { - p_node->connect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed", varray(p_node), CONNECT_ONESHOT); + p_node->connect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed", varray(p_node), CONNECT_ONESHOT); nodes[p_node] = meta; _change_node_state(p_node, false); } @@ -208,7 +208,7 @@ void VisibilityEnabler::_notification(int p_what) { if (!visible) _change_node_state(E->key(), true); - E->key()->disconnect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed"); + E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed"); } nodes.clear(); @@ -240,7 +240,7 @@ void VisibilityEnabler::_node_removed(Node *p_node) { if (!visible) _change_node_state(p_node, true); - p_node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed"); + p_node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed"); nodes.erase(p_node); } diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index e1717a56f3..d389b69ef3 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -461,16 +461,16 @@ void VoxelLightBaker::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p } } - if (bake_cells[p_idx].childs[i] == CHILD_EMPTY) { + if (bake_cells[p_idx].children[i] == CHILD_EMPTY) { //sub cell must be created uint32_t child_idx = bake_cells.size(); - bake_cells[p_idx].childs[i] = child_idx; + bake_cells[p_idx].children[i] = child_idx; bake_cells.resize(bake_cells.size() + 1); bake_cells[child_idx].level = p_level + 1; } - _plot_face(bake_cells[p_idx].childs[i], p_level + 1, nx, ny, nz, p_vtx, p_normal, p_uv, p_material, aabb); + _plot_face(bake_cells[p_idx].children[i], p_level + 1, nx, ny, nz, p_vtx, p_normal, p_uv, p_material, aabb); } } } @@ -700,7 +700,7 @@ void VoxelLightBaker::_init_light_plot(int p_idx, int p_level, int p_x, int p_y, int half = (1 << (cell_subdiv - 1)) >> (p_level + 1); for (int i = 0; i < 8; i++) { - uint32_t child = bake_cells[p_idx].childs[i]; + uint32_t child = bake_cells[p_idx].children[i]; if (child == CHILD_EMPTY) continue; @@ -809,7 +809,7 @@ uint32_t VoxelLightBaker::_find_cell_at_pos(const Cell *cells, int x, int y, int ofs_z += half; } - cell = bc->childs[child]; + cell = bc->children[child]; if (cell == CHILD_EMPTY) return CHILD_EMPTY; @@ -1257,7 +1257,7 @@ void VoxelLightBaker::_fixup_plot(int p_idx, int p_level) { for (int i = 0; i < 8; i++) { - uint32_t child = bake_cells[p_idx].childs[i]; + uint32_t child = bake_cells[p_idx].children[i]; if (child == CHILD_EMPTY) continue; @@ -1483,7 +1483,7 @@ void VoxelLightBaker::_sample_baked_octree_filtered_and_anisotropic(const Vector ofs_z += half; } - cell = bc->childs[child]; + cell = bc->children[child]; if (cell == CHILD_EMPTY) break; @@ -1766,7 +1766,7 @@ Vector3 VoxelLightBaker::_compute_ray_trace_at_pos(const Vector3 &p_pos, const V ofs_z += half; } - cell = bc->childs[child]; + cell = bc->children[child]; if (unlikely(cell == CHILD_EMPTY)) break; @@ -1928,7 +1928,7 @@ Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { if (lightmap_ptr[i * width + j].normal == Vector3()) - continue; //empty, dont write over it anyway + continue; //empty, don't write over it anyway float gauss_sum = gauss_kernel[0]; Vector3 accum = lightmap_ptr[i * width + j].pos * gauss_kernel[0]; for (int k = 1; k < 4; k++) { @@ -2191,7 +2191,7 @@ PoolVector<int> VoxelLightBaker::create_gi_probe_data() { for (int i = 0; i < bake_cells.size(); i++) { for (int j = 0; j < 8; j++) { - w32[ofs++] = bake_cells[i].childs[j]; + w32[ofs++] = bake_cells[i].children[j]; } { //albedo @@ -2275,7 +2275,7 @@ void VoxelLightBaker::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Re for (int i = 0; i < 8; i++) { - uint32_t child = bake_cells[p_idx].childs[i]; + uint32_t child = bake_cells[p_idx].children[i]; if (child == CHILD_EMPTY || child >= max_original_cells) continue; @@ -2290,7 +2290,7 @@ void VoxelLightBaker::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Re if (i & 4) aabb.position.z += aabb.size.z; - _debug_mesh(bake_cells[p_idx].childs[i], p_level + 1, aabb, p_multimesh, idx, p_mode); + _debug_mesh(bake_cells[p_idx].children[i], p_level + 1, aabb, p_multimesh, idx, p_mode); } } } @@ -2423,7 +2423,7 @@ PoolVector<uint8_t> VoxelLightBaker::create_capture_octree(int p_subdiv) { } for (int j = 0; j < 8; j++) { - uint32_t child = bake_cells[demap[i]].childs[j]; + uint32_t child = bake_cells[demap[i]].children[j]; octree[i].children[j] = child == CHILD_EMPTY ? CHILD_EMPTY : remap[child]; } } diff --git a/scene/3d/voxel_light_baker.h b/scene/3d/voxel_light_baker.h index d270a26a2a..6a1f1253a3 100644 --- a/scene/3d/voxel_light_baker.h +++ b/scene/3d/voxel_light_baker.h @@ -60,7 +60,7 @@ private: struct Cell { - uint32_t childs[8]; + uint32_t children[8]; float albedo[3]; //albedo in RGB24 float emission[3]; //accumulated light in 16:16 fixed point (needs to be integer for moving lights fast) float normal[3]; @@ -70,7 +70,7 @@ private: Cell() { for (int i = 0; i < 8; i++) { - childs[i] = CHILD_EMPTY; + children[i] = CHILD_EMPTY; } for (int i = 0; i < 3; i++) { |