diff options
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/audio_stream_player_3d.cpp | 4 | ||||
-rw-r--r-- | scene/3d/cpu_particles.cpp | 23 | ||||
-rw-r--r-- | scene/3d/cpu_particles.h | 2 | ||||
-rw-r--r-- | scene/3d/light.cpp | 9 | ||||
-rw-r--r-- | scene/3d/mesh_instance.cpp | 6 | ||||
-rw-r--r-- | scene/3d/mesh_instance.h | 1 | ||||
-rw-r--r-- | scene/3d/voxel_light_baker.cpp | 6 |
7 files changed, 34 insertions, 17 deletions
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index abf022ecb3..3046cad624 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -290,7 +290,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { PhysicsDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS]; - int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask); + int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true); Area *area = NULL; for (int i = 0; i < areas; i++) { @@ -448,7 +448,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { //float dist_att_db = -20 * Math::log(dist + 0.00001); //logarithmic attenuation, like in real life - float center_val[3] = { 0.5, 0.25, 0.16666 }; + float center_val[3] = { 0.5f, 0.25f, 0.16666f }; AudioFrame center_frame(center_val[vol_index_max - 1], center_val[vol_index_max - 1]); if (attenuation < 1.0) { diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index ec51c31674..35a2049bda 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -592,7 +592,7 @@ void CPUParticles::_particles_process(float p_delta) { Vector3 direction_xz = Vector3(Math::sin(angle1_rad), 0, Math::cos(angle1_rad)); Vector3 direction_yz = Vector3(0, Math::sin(angle2_rad), Math::cos(angle2_rad)); - direction_yz.z = direction_yz.z / Math::sqrt(direction_yz.z); //better uniform distribution + direction_yz.z = direction_yz.z / MAX(0.0001, Math::sqrt(ABS(direction_yz.z))); //better uniform distribution Vector3 direction = Vector3(direction_xz.x * direction_yz.z, direction_yz.y, direction_xz.z * direction_yz.z); direction.normalize(); p.velocity = direction * parameters[PARAM_INITIAL_LINEAR_VELOCITY] * Math::lerp(1.0f, float(Math::randf()), randomness[PARAM_INITIAL_LINEAR_VELOCITY]); @@ -977,6 +977,8 @@ void CPUParticles::_update_particle_data_buffer() { ptr += 17; } + + can_update = true; } #ifndef NO_THREADS @@ -989,8 +991,10 @@ void CPUParticles::_update_render_thread() { #ifndef NO_THREADS update_mutex->lock(); #endif - - VS::get_singleton()->multimesh_set_as_bulk_array(multimesh, particle_data); + if (can_update) { + VS::get_singleton()->multimesh_set_as_bulk_array(multimesh, particle_data); + can_update = false; //wait for next time + } #ifndef NO_THREADS update_mutex->unlock(); @@ -1032,7 +1036,7 @@ void CPUParticles::_notification(int p_what) { if (p_what == NOTIFICATION_INTERNAL_PROCESS) { - if (particles.size() == 0) + if (particles.size() == 0 || !is_visible_in_tree()) return; float delta = get_process_delta_time(); @@ -1061,6 +1065,8 @@ void CPUParticles::_notification(int p_what) { } } + bool processed = false; + if (time == 0 && pre_process_time > 0.0) { float frame_time; @@ -1073,6 +1079,7 @@ void CPUParticles::_notification(int p_what) { while (todo >= 0) { _particles_process(frame_time); + processed = true; todo -= frame_time; } } @@ -1091,6 +1098,7 @@ void CPUParticles::_notification(int p_what) { while (todo >= frame_time) { _particles_process(frame_time); + processed = true; todo -= decr; } @@ -1098,9 +1106,12 @@ void CPUParticles::_notification(int p_what) { } else { _particles_process(delta); + processed = true; } - _update_particle_data_buffer(); + if (processed) { + _update_particle_data_buffer(); + } } } @@ -1424,6 +1435,8 @@ CPUParticles::CPUParticles() { flags[i] = false; } + can_update = false; + set_color(Color(1, 1, 1, 1)); #ifndef NO_THREADS diff --git a/scene/3d/cpu_particles.h b/scene/3d/cpu_particles.h index 4e29d8d4ce..77a144b70b 100644 --- a/scene/3d/cpu_particles.h +++ b/scene/3d/cpu_particles.h @@ -142,6 +142,8 @@ private: int fixed_fps; bool fractional_delta; + volatile bool can_update; + DrawOrder draw_order; Ref<Mesh> mesh; diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 7e1d60ab8e..11d61315ba 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -163,11 +163,6 @@ void Light::_update_visibility() { if (!is_inside_tree()) return; - // FIXME: Since the call to VS::instance_light_set_enabled was disabled below, - // the whole logic became pointless so editor_ok triggers unused variable warnings. - // Commenting out for now but this should be fixed/reimplemented so that editor_only - // works as expected (GH-17989). - /* bool editor_ok = true; #ifdef TOOLS_ENABLED @@ -184,8 +179,8 @@ void Light::_update_visibility() { } #endif - //VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible_in_tree() && editor_ok); - */ + VS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree() && editor_ok); + _change_notify("geometry/visible"); } diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 4cbf6f2de3..cf0317cd58 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -253,6 +253,11 @@ void MeshInstance::_notification(int p_what) { } } +int MeshInstance::get_surface_material_count() const { + + return materials.size(); +} + void MeshInstance::set_surface_material(int p_surface, const Ref<Material> &p_material) { ERR_FAIL_INDEX(p_surface, materials.size()); @@ -359,6 +364,7 @@ void MeshInstance::_bind_methods() { ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &MeshInstance::set_skeleton_path); ClassDB::bind_method(D_METHOD("get_skeleton_path"), &MeshInstance::get_skeleton_path); + ClassDB::bind_method(D_METHOD("get_surface_material_count"), &MeshInstance::get_surface_material_count); ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material"), &MeshInstance::set_surface_material); ClassDB::bind_method(D_METHOD("get_surface_material", "surface"), &MeshInstance::get_surface_material); diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h index 0dfec538f9..0b5b4b9e7b 100644 --- a/scene/3d/mesh_instance.h +++ b/scene/3d/mesh_instance.h @@ -76,6 +76,7 @@ public: void set_skeleton_path(const NodePath &p_skeleton); NodePath get_skeleton_path(); + int get_surface_material_count() const; void set_surface_material(int p_surface, const Ref<Material> &p_material); Ref<Material> get_surface_material(int p_surface) const; diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index f9bd905181..541f6047d9 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -1619,7 +1619,7 @@ Vector3 VoxelLightBaker::_compute_pixel_light_at_pos(const Vector3 &p_pos, const Vector3(-0.700629, -0.509037, 0.5), Vector3(0.267617, -0.823639, 0.5) }; - static const float weights[6] = { 0.25, 0.15, 0.15, 0.15, 0.15, 0.15 }; + static const float weights[6] = { 0.25f, 0.15f, 0.15f, 0.15f, 0.15f, 0.15f }; // cone_dirs = dirs; cone_dir_count = 6; @@ -1641,7 +1641,7 @@ Vector3 VoxelLightBaker::_compute_pixel_light_at_pos(const Vector3 &p_pos, const Vector3(0.19124006749743122, 0.39355745585016605, 0.8991883926788214), Vector3(0.19124006749743122, -0.39355745585016605, 0.8991883926788214), }; - static const float weights[10] = { 0.08571, 0.08571, 0.08571, 0.08571, 0.08571, 0.08571, 0.08571, 0.133333, 0.133333, 0.13333 }; + static const float weights[10] = { 0.08571f, 0.08571f, 0.08571f, 0.08571f, 0.08571f, 0.08571f, 0.08571f, 0.133333f, 0.133333f, 0.13333f }; cone_dirs = dirs; cone_dir_count = 10; cone_aperture = 0.404; // tan(angle) 45 degrees @@ -1875,7 +1875,7 @@ Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh if (bake_mode == BAKE_MODE_RAY_TRACE) { //blur //gauss kernel, 7 step sigma 2 - static const float gauss_kernel[4] = { 0.214607, 0.189879, 0.131514, 0.071303 }; + static const float gauss_kernel[4] = { 0.214607f, 0.189879f, 0.131514f, 0.071303f }; //horizontal pass for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { |