diff options
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/audio_stream_player_3d.cpp | 2 | ||||
-rw-r--r-- | scene/3d/camera_3d.cpp | 19 | ||||
-rw-r--r-- | scene/3d/camera_3d.h | 8 | ||||
-rw-r--r-- | scene/3d/gpu_particles_collision_3d.cpp | 2 | ||||
-rw-r--r-- | scene/3d/node_3d.cpp | 13 | ||||
-rw-r--r-- | scene/3d/node_3d.h | 4 | ||||
-rw-r--r-- | scene/3d/proximity_group_3d.cpp | 10 | ||||
-rw-r--r-- | scene/3d/skeleton_3d.cpp | 83 | ||||
-rw-r--r-- | scene/3d/skeleton_3d.h | 8 | ||||
-rw-r--r-- | scene/3d/soft_dynamic_body_3d.cpp | 5 | ||||
-rw-r--r-- | scene/3d/soft_dynamic_body_3d.h | 2 | ||||
-rw-r--r-- | scene/3d/voxel_gi.cpp | 2 | ||||
-rw-r--r-- | scene/3d/voxelizer.cpp | 3 |
13 files changed, 106 insertions, 55 deletions
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index a54b10ba70..c422070480 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -282,7 +282,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { ERR_FAIL_COND_MSG(new_playback.is_null(), "Failed to instantiate playback."); Map<StringName, Vector<AudioFrame>> bus_map; bus_map[_get_actual_bus()] = volume_vector; - AudioServer::get_singleton()->start_playback_stream(new_playback, bus_map, setplay.get(), linear_attenuation, attenuation_filter_cutoff_hz, actual_pitch_scale); + AudioServer::get_singleton()->start_playback_stream(new_playback, bus_map, setplay.get(), actual_pitch_scale, linear_attenuation, attenuation_filter_cutoff_hz); stream_playbacks.push_back(new_playback); setplay.set(-1); } diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 61d73ff1e2..588d2b5018 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -238,8 +238,8 @@ void Camera3D::clear_current(bool p_enable_next) { } } -void Camera3D::set_current(bool p_current) { - if (p_current) { +void Camera3D::set_current(bool p_enabled) { + if (p_enabled) { make_current(); } else { clear_current(); @@ -460,7 +460,7 @@ void Camera3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_frustum", "size", "offset", "z_near", "z_far"), &Camera3D::set_frustum); ClassDB::bind_method(D_METHOD("make_current"), &Camera3D::make_current); ClassDB::bind_method(D_METHOD("clear_current", "enable_next"), &Camera3D::clear_current, DEFVAL(true)); - ClassDB::bind_method(D_METHOD("set_current"), &Camera3D::set_current); + ClassDB::bind_method(D_METHOD("set_current", "enabled"), &Camera3D::set_current); ClassDB::bind_method(D_METHOD("is_current"), &Camera3D::is_current); ClassDB::bind_method(D_METHOD("get_camera_transform"), &Camera3D::get_camera_transform); ClassDB::bind_method(D_METHOD("get_fov"), &Camera3D::get_fov); @@ -468,13 +468,13 @@ void Camera3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_size"), &Camera3D::get_size); ClassDB::bind_method(D_METHOD("get_far"), &Camera3D::get_far); ClassDB::bind_method(D_METHOD("get_near"), &Camera3D::get_near); - ClassDB::bind_method(D_METHOD("set_fov"), &Camera3D::set_fov); - ClassDB::bind_method(D_METHOD("set_frustum_offset"), &Camera3D::set_frustum_offset); - ClassDB::bind_method(D_METHOD("set_size"), &Camera3D::set_size); - ClassDB::bind_method(D_METHOD("set_far"), &Camera3D::set_far); - ClassDB::bind_method(D_METHOD("set_near"), &Camera3D::set_near); + ClassDB::bind_method(D_METHOD("set_fov", "fov"), &Camera3D::set_fov); + ClassDB::bind_method(D_METHOD("set_frustum_offset", "offset"), &Camera3D::set_frustum_offset); + ClassDB::bind_method(D_METHOD("set_size", "size"), &Camera3D::set_size); + ClassDB::bind_method(D_METHOD("set_far", "far"), &Camera3D::set_far); + ClassDB::bind_method(D_METHOD("set_near", "near"), &Camera3D::set_near); ClassDB::bind_method(D_METHOD("get_projection"), &Camera3D::get_projection); - ClassDB::bind_method(D_METHOD("set_projection"), &Camera3D::set_projection); + ClassDB::bind_method(D_METHOD("set_projection", "mode"), &Camera3D::set_projection); ClassDB::bind_method(D_METHOD("set_h_offset", "ofs"), &Camera3D::set_h_offset); ClassDB::bind_method(D_METHOD("get_h_offset"), &Camera3D::get_h_offset); ClassDB::bind_method(D_METHOD("set_v_offset", "ofs"), &Camera3D::set_v_offset); @@ -656,6 +656,7 @@ Vector3 Camera3D::get_doppler_tracked_velocity() const { } RID Camera3D::get_pyramid_shape_rid() { + ERR_FAIL_COND_V_MSG(!is_inside_tree(), RID(), "Camera is not inside scene."); if (pyramid_shape == RID()) { pyramid_shape_points = get_near_plane_points(); pyramid_shape = PhysicsServer3D::get_singleton()->convex_polygon_shape_create(); diff --git a/scene/3d/camera_3d.h b/scene/3d/camera_3d.h index 6006a2ea3f..73126611d5 100644 --- a/scene/3d/camera_3d.h +++ b/scene/3d/camera_3d.h @@ -44,8 +44,10 @@ public: PROJECTION_FRUSTUM }; - enum KeepAspect { KEEP_WIDTH, - KEEP_HEIGHT }; + enum KeepAspect { + KEEP_WIDTH, + KEEP_HEIGHT + }; enum DopplerTracking { DOPPLER_TRACKING_DISABLED, @@ -112,7 +114,7 @@ public: void make_current(); void clear_current(bool p_enable_next = true); - void set_current(bool p_current); + void set_current(bool p_enabled); bool is_current() const; RID get_camera() const; diff --git a/scene/3d/gpu_particles_collision_3d.cpp b/scene/3d/gpu_particles_collision_3d.cpp index 4fa34615bf..9127168c58 100644 --- a/scene/3d/gpu_particles_collision_3d.cpp +++ b/scene/3d/gpu_particles_collision_3d.cpp @@ -475,7 +475,7 @@ Ref<Image> GPUParticlesCollisionSDF::bake() { _create_bvh(bvh, face_pos.ptr(), face_pos.size(), faces.ptr(), th); Vector<uint8_t> data; - data.resize(sdf_size.z * sdf_size.y * sdf_size.x * sizeof(float)); + data.resize(sdf_size.z * sdf_size.y * sdf_size.x * (int)sizeof(float)); if (bake_step_function) { bake_step_function(0, "Baking SDF"); diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 12470939f5..272a06bce4 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -376,6 +376,18 @@ void Node3D::update_gizmos() { #endif } +void Node3D::set_subgizmo_selection(Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform) { +#ifdef TOOLS_ENABLED + if (!is_inside_world()) { + return; + } + + if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) { + get_tree()->call_group_flags(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_set_subgizmo_selection, this, p_gizmo, p_id, p_transform); + } +#endif +} + void Node3D::clear_subgizmo_selection() { #ifdef TOOLS_ENABLED if (!is_inside_world()) { @@ -792,6 +804,7 @@ void Node3D::_bind_methods() { ClassDB::bind_method(D_METHOD("add_gizmo", "gizmo"), &Node3D::add_gizmo); ClassDB::bind_method(D_METHOD("get_gizmos"), &Node3D::get_gizmos_bind); ClassDB::bind_method(D_METHOD("clear_gizmos"), &Node3D::clear_gizmos); + ClassDB::bind_method(D_METHOD("set_subgizmo_selection", "gizmo", "id", "transform"), &Node3D::set_subgizmo_selection); ClassDB::bind_method(D_METHOD("clear_subgizmo_selection"), &Node3D::clear_subgizmo_selection); ClassDB::bind_method(D_METHOD("set_visible", "visible"), &Node3D::set_visible); diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h index 0fd0c4e205..d6dcdd96fe 100644 --- a/scene/3d/node_3d.h +++ b/scene/3d/node_3d.h @@ -92,6 +92,7 @@ class Node3D : public Node { Vector<Ref<Node3DGizmo>> gizmos; bool gizmos_disabled = false; bool gizmos_dirty = false; + bool transform_gizmo_visible = true; #endif } data; @@ -145,6 +146,8 @@ public: #ifdef TOOLS_ENABLED virtual Transform3D get_global_gizmo_transform() const; virtual Transform3D get_local_gizmo_transform() const; + virtual void set_transform_gizmo_visible(bool p_enabled) { data.transform_gizmo_visible = p_enabled; }; + virtual bool is_transform_gizmo_visible() const { return data.transform_gizmo_visible; }; #endif void set_as_top_level(bool p_enabled); @@ -155,6 +158,7 @@ public: void set_disable_gizmos(bool p_enabled); void update_gizmos(); + void set_subgizmo_selection(Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform = Transform3D()); void clear_subgizmo_selection(); Vector<Ref<Node3DGizmo>> get_gizmos() const; Array get_gizmos_bind() const; diff --git a/scene/3d/proximity_group_3d.cpp b/scene/3d/proximity_group_3d.cpp index c8c61a9f00..23df00c1f6 100644 --- a/scene/3d/proximity_group_3d.cpp +++ b/scene/3d/proximity_group_3d.cpp @@ -34,9 +34,9 @@ void ProximityGroup3D::_clear_groups() { Map<StringName, uint32_t>::Element *E; + const int size = 16; - { - const int size = 16; + do { StringName remove_list[size]; E = groups.front(); int num = 0; @@ -50,11 +50,7 @@ void ProximityGroup3D::_clear_groups() { for (int i = 0; i < num; i++) { groups.erase(remove_list[i]); } - } - - if (E) { - _clear_groups(); // call until we go through the whole list - } + } while (E); } void ProximityGroup3D::_update_groups() { diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index b7a79a2645..2b52f034b2 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -32,6 +32,7 @@ #include "core/object/message_queue.h" #include "core/variant/type_info.h" +#include "editor/plugins/skeleton_3d_editor_plugin.h" #include "scene/3d/physics_body_3d.h" #include "scene/resources/skeleton_modification_3d.h" #include "scene/resources/surface_tool.h" @@ -178,7 +179,7 @@ void Skeleton3D::_update_process_order() { for (int i = 0; i < len; i++) { if (bonesptr[i].parent >= len) { - //validate this just in case + // Validate this just in case. ERR_PRINT("Bone " + itos(i) + " has invalid parent: " + itos(bonesptr[i].parent)); bonesptr[i].parent = -1; } @@ -186,9 +187,9 @@ void Skeleton3D::_update_process_order() { if (bonesptr[i].parent != -1) { int parent_bone_idx = bonesptr[i].parent; - // Check to see if this node is already added to the parent: + // Check to see if this node is already added to the parent. if (bonesptr[parent_bone_idx].child_bones.find(i) < 0) { - // Add the child node + // Add the child node. bonesptr[parent_bone_idx].child_bones.push_back(i); } else { ERR_PRINT("Skeleton3D parenthood graph is cyclic"); @@ -210,10 +211,10 @@ void Skeleton3D::_notification(int p_what) { int len = bones.size(); dirty = false; - // Update bone transforms + // Update bone transforms. force_update_all_bone_transforms(); - //update skins + // Update skins. for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) { const Skin *skin = E->get()->skin.operator->(); RID skeleton = E->get()->skeleton; @@ -231,7 +232,7 @@ void Skeleton3D::_notification(int p_what) { StringName bind_name = skin->get_bind_name(i); if (bind_name != StringName()) { - //bind name used, use this + // Bind name used, use this. bool found = false; for (int j = 0; j < len; j++) { if (bonesptr[j].name == bind_name) { @@ -453,7 +454,8 @@ int Skeleton3D::get_bone_axis_forward_enum(int p_bone) { return bones[p_bone].rest_bone_forward_axis; } -// skeleton creation api +// Skeleton creation api + void Skeleton3D::add_bone(const String &p_name) { ERR_FAIL_COND(p_name == "" || p_name.find(":") != -1 || p_name.find("/") != -1); @@ -626,6 +628,7 @@ void Skeleton3D::set_bone_enabled(int p_bone, bool p_enabled) { ERR_FAIL_INDEX(p_bone, bone_size); bones.write[p_bone].enabled = p_enabled; + emit_signal(SceneStringNames::get_singleton()->bone_enabled_changed, p_bone); _make_dirty(); } @@ -635,6 +638,16 @@ bool Skeleton3D::is_bone_enabled(int p_bone) const { return bones[p_bone].enabled; } +void Skeleton3D::set_show_rest_only(bool p_enabled) { + show_rest_only = p_enabled; + emit_signal(SceneStringNames::get_singleton()->show_rest_only_changed); + _make_dirty(); +} + +bool Skeleton3D::is_show_rest_only() const { + return show_rest_only; +} + void Skeleton3D::clear_bones() { bones.clear(); process_order_dirty = true; @@ -642,7 +655,7 @@ void Skeleton3D::clear_bones() { _make_dirty(); } -// posing api +// Posing api void Skeleton3D::set_bone_pose(int p_bone, const Transform3D &p_pose) { const int bone_size = bones.size(); @@ -697,7 +710,7 @@ void Skeleton3D::localize_rests() { set_bone_rest(current_bone_idx, bones[bones[current_bone_idx].parent].rest.affine_inverse() * bones[current_bone_idx].rest); } - // Add the bone's children to the list of bones to be processed + // Add the bone's children to the list of bones to be processed. int child_bone_size = bones[current_bone_idx].child_bones.size(); for (int i = 0; i < child_bone_size; i++) { bones_to_process.push_back(bones[current_bone_idx].child_bones[i]); @@ -705,8 +718,8 @@ void Skeleton3D::localize_rests() { } } -void Skeleton3D::set_animate_physical_bones(bool p_animate) { - animate_physical_bones = p_animate; +void Skeleton3D::set_animate_physical_bones(bool p_enabled) { + animate_physical_bones = p_enabled; if (Engine::get_singleton()->is_editor_hint() == false) { bool sim = false; @@ -718,7 +731,7 @@ void Skeleton3D::set_animate_physical_bones(bool p_animate) { } } } - set_physics_process_internal(sim == false && p_animate); + set_physics_process_internal(sim == false && p_enabled); } } @@ -831,7 +844,7 @@ void Skeleton3D::physical_bones_start_simulation_on(const TypedArray<StringName> Vector<int> sim_bones; if (p_bones.size() <= 0) { - sim_bones.push_back(0); // if no bones is specified, activate ragdoll on full body + sim_bones.push_back(0); // If no bones is specified, activate ragdoll on full body. } else { sim_bones.resize(p_bones.size()); int c = 0; @@ -884,19 +897,19 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) { Ref<Skin> skin = p_skin; if (skin.is_null()) { - //need to create one from existing code, this is for compatibility only - //when skeletons did not support skins. It is also used by gizmo - //to display the skeleton. + // Need to create one from existing code, this is for compatibility only + // when skeletons did not support skins. It is also used by gizmo + // to display the skeleton. skin.instantiate(); skin->set_bind_count(bones.size()); - _update_process_order(); //just in case + _update_process_order(); // Just in case. - // pose changed, rebuild cache of inverses + // Pose changed, rebuild cache of inverses. const Bone *bonesptr = bones.ptr(); int len = bones.size(); - // calculate global rests and invert them + // Calculate global rests and invert them. LocalVector<int> bones_to_process; bones_to_process = get_parentless_bones(); while (bones_to_process.size() > 0) { @@ -919,7 +932,7 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) { } for (int i = 0; i < len; i++) { - //the inverse is what is actually required + // The inverse is what is actually required. skin->set_bind_bone(i, i); skin->set_bind_pose(i, skin->get_bind_pose(i).affine_inverse()); } @@ -940,11 +953,17 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) { skin->connect("changed", Callable(skin_ref.operator->(), "_skin_changed")); - _make_dirty(); //skin needs to be updated, so update skeleton + _make_dirty(); // Skin needs to be updated, so update skeleton. return skin_ref; } +void Skeleton3D::force_update_all_dirty_bones() { + if (dirty) { + const_cast<Skeleton3D *>(this)->notification(NOTIFICATION_UPDATE_SKELETON); + } +} + void Skeleton3D::force_update_all_bone_transforms() { _update_process_order(); @@ -966,9 +985,10 @@ void Skeleton3D::force_update_bone_children_transforms(int p_bone_idx) { bones_to_process.erase(current_bone_idx); Bone &b = bonesptr[current_bone_idx]; + bool bone_enabled = b.enabled && !show_rest_only; if (b.disable_rest) { - if (b.enabled) { + if (bone_enabled) { Transform3D pose = b.pose; if (b.custom_pose_enable) { pose = b.custom_pose * pose; @@ -991,7 +1011,7 @@ void Skeleton3D::force_update_bone_children_transforms(int p_bone_idx) { } } else { - if (b.enabled) { + if (bone_enabled) { Transform3D pose = b.pose; if (b.custom_pose_enable) { pose = b.custom_pose * pose; @@ -1035,7 +1055,7 @@ void Skeleton3D::force_update_bone_children_transforms(int p_bone_idx) { b.global_pose_override_amount = 0.0; } - // Add the bone's children to the list of bones to be processed + // Add the bone's children to the list of bones to be processed. int child_bone_size = b.child_bones.size(); for (int i = 0; i < child_bone_size; i++) { bones_to_process.push_back(b.child_bones[i]); @@ -1045,7 +1065,7 @@ void Skeleton3D::force_update_bone_children_transforms(int p_bone_idx) { } } -// helper functions +// Helper functions Transform3D Skeleton3D::global_pose_to_world_transform(Transform3D p_global_pose) { return get_global_transform() * p_global_pose; @@ -1175,6 +1195,9 @@ void Skeleton3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bone_pose", "bone_idx"), &Skeleton3D::get_bone_pose); ClassDB::bind_method(D_METHOD("set_bone_pose", "bone_idx", "pose"), &Skeleton3D::set_bone_pose); + ClassDB::bind_method(D_METHOD("is_bone_enabled", "bone_idx"), &Skeleton3D::is_bone_enabled); + ClassDB::bind_method(D_METHOD("set_bone_enabled", "bone_idx", "enabled"), &Skeleton3D::set_bone_enabled, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("clear_bones_global_pose_override"), &Skeleton3D::clear_bones_global_pose_override); ClassDB::bind_method(D_METHOD("set_bone_global_pose_override", "bone_idx", "pose", "amount", "persistent"), &Skeleton3D::set_bone_global_pose_override, DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_bone_global_pose_override", "bone_idx"), &Skeleton3D::get_bone_global_pose_override); @@ -1198,7 +1221,10 @@ void Skeleton3D::_bind_methods() { ClassDB::bind_method(D_METHOD("local_pose_to_global_pose", "bone_idx", "local_pose"), &Skeleton3D::local_pose_to_global_pose); ClassDB::bind_method(D_METHOD("global_pose_z_forward_to_bone_forward", "bone_idx", "basis"), &Skeleton3D::global_pose_z_forward_to_bone_forward); - ClassDB::bind_method(D_METHOD("set_animate_physical_bones"), &Skeleton3D::set_animate_physical_bones); + ClassDB::bind_method(D_METHOD("set_show_rest_only", "enabled"), &Skeleton3D::set_show_rest_only); + ClassDB::bind_method(D_METHOD("is_show_rest_only"), &Skeleton3D::is_show_rest_only); + + ClassDB::bind_method(D_METHOD("set_animate_physical_bones", "enabled"), &Skeleton3D::set_animate_physical_bones); ClassDB::bind_method(D_METHOD("get_animate_physical_bones"), &Skeleton3D::get_animate_physical_bones); ClassDB::bind_method(D_METHOD("physical_bones_stop_simulation"), &Skeleton3D::physical_bones_stop_simulation); @@ -1212,6 +1238,7 @@ void Skeleton3D::_bind_methods() { ClassDB::bind_method(D_METHOD("execute_modifications", "delta", "execution_mode"), &Skeleton3D::execute_modifications); #ifndef _3D_DISABLED + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_rest_only"), "set_show_rest_only", "is_show_rest_only"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "animate_physical_bones"), "set_animate_physical_bones", "get_animate_physical_bones"); #endif // _3D_DISABLED @@ -1220,6 +1247,8 @@ void Skeleton3D::_bind_methods() { #endif // TOOLS_ENABLED ADD_SIGNAL(MethodInfo("bone_pose_changed", PropertyInfo(Variant::INT, "bone_idx"))); + ADD_SIGNAL(MethodInfo("bone_enabled_changed", PropertyInfo(Variant::INT, "bone_idx"))); + ADD_SIGNAL(MethodInfo("show_rest_only_changed")); BIND_CONSTANT(NOTIFICATION_UPDATE_SKELETON); } @@ -1228,7 +1257,7 @@ Skeleton3D::Skeleton3D() { } Skeleton3D::~Skeleton3D() { - //some skins may remain bound + // Some skins may remain bound. for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) { E->get()->skeleton_node = nullptr; } diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h index c8a19db813..9aa4fc823f 100644 --- a/scene/3d/skeleton_3d.h +++ b/scene/3d/skeleton_3d.h @@ -137,6 +137,8 @@ private: void _make_dirty(); bool dirty = false; + bool show_rest_only = false; + uint64_t version = 1; void _update_process_order(); @@ -197,6 +199,9 @@ public: void set_bone_enabled(int p_bone, bool p_enabled); bool is_bone_enabled(int p_bone) const; + + void set_show_rest_only(bool p_enabled); + bool is_show_rest_only() const; void clear_bones(); // posing api @@ -219,6 +224,7 @@ public: Ref<SkinReference> register_skin(const Ref<Skin> &p_skin); + void force_update_all_dirty_bones(); void force_update_all_bone_transforms(); void force_update_bone_children_transforms(int bone_idx); @@ -244,7 +250,7 @@ public: // Physical bone API - void set_animate_physical_bones(bool p_animate); + void set_animate_physical_bones(bool p_enabled); bool get_animate_physical_bones() const; void bind_physical_bone_to_bone(int p_bone, PhysicalBone3D *p_physical_bone); diff --git a/scene/3d/soft_dynamic_body_3d.cpp b/scene/3d/soft_dynamic_body_3d.cpp index 21f9b0a35d..9fceb21790 100644 --- a/scene/3d/soft_dynamic_body_3d.cpp +++ b/scene/3d/soft_dynamic_body_3d.cpp @@ -411,8 +411,9 @@ void SoftDynamicBody3D::_draw_soft_mesh() { return; } - if (!rendering_server_handler.is_ready()) { - rendering_server_handler.prepare(get_mesh()->get_rid(), 0); + const RID mesh_rid = get_mesh()->get_rid(); + if (!rendering_server_handler.is_ready(mesh_rid)) { + rendering_server_handler.prepare(mesh_rid, 0); /// Necessary in order to render the mesh correctly (Soft body nodes are in global space) simulation_started = true; diff --git a/scene/3d/soft_dynamic_body_3d.h b/scene/3d/soft_dynamic_body_3d.h index 0b4b3021cd..5e7fbfe29e 100644 --- a/scene/3d/soft_dynamic_body_3d.h +++ b/scene/3d/soft_dynamic_body_3d.h @@ -50,7 +50,7 @@ class SoftDynamicBodyRenderingServerHandler : public RenderingServerHandler { private: SoftDynamicBodyRenderingServerHandler(); - bool is_ready() { return mesh.is_valid(); } + bool is_ready(RID p_mesh_rid) const { return mesh.is_valid() && mesh == p_mesh_rid; } void prepare(RID p_mesh_rid, int p_surface); void clear(); void open(); diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp index d3d12d94e9..377abd5b38 100644 --- a/scene/3d/voxel_gi.cpp +++ b/scene/3d/voxel_gi.cpp @@ -398,7 +398,7 @@ void VoxelGI::bake(Node *p_from_node, bool p_create_visual_debug) { baker.end_bake(); - //create the data for visual server + //create the data for rendering server if (p_create_visual_debug) { MultiMeshInstance3D *mmi = memnew(MultiMeshInstance3D); diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp index 04f371f4b2..aa1236521d 100644 --- a/scene/3d/voxelizer.cpp +++ b/scene/3d/voxelizer.cpp @@ -618,7 +618,6 @@ void Voxelizer::begin_bake(int p_subdiv, const AABB &p_bounds) { bake_cells.resize(1); material_cache.clear(); - print_line("subdiv: " + itos(p_subdiv)); //find out the actual real bounds, power of 2, which gets the highest subdivision po2_bounds = p_bounds; int longest_axis = po2_bounds.get_longest_axis_index(); @@ -661,7 +660,7 @@ void Voxelizer::end_bake() { _fixup_plot(0, 0); } -//create the data for visual server +//create the data for rendering server int Voxelizer::get_voxel_gi_octree_depth() const { return cell_subdiv; |