diff options
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/audio_stream_player_3d.cpp | 24 | ||||
-rw-r--r-- | scene/3d/audio_stream_player_3d.h | 4 | ||||
-rw-r--r-- | scene/3d/camera.h | 2 | ||||
-rw-r--r-- | scene/3d/collision_object.cpp | 14 | ||||
-rw-r--r-- | scene/3d/collision_object.h | 2 | ||||
-rw-r--r-- | scene/3d/physics_body.cpp | 13 | ||||
-rw-r--r-- | scene/3d/physics_joint.cpp | 3 | ||||
-rw-r--r-- | scene/3d/skeleton.cpp | 6 | ||||
-rw-r--r-- | scene/3d/skeleton.h | 8 | ||||
-rw-r--r-- | scene/3d/vehicle_body.cpp | 2 | ||||
-rw-r--r-- | scene/3d/voxel_light_baker.cpp | 26 | ||||
-rw-r--r-- | scene/3d/voxel_light_baker.h | 4 |
12 files changed, 75 insertions, 33 deletions
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/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/physics_body.cpp b/scene/3d/physics_body.cpp index a15a7dcead..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); @@ -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_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/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/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index aeee51c4b2..ed3bde9504 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -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(), 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++) { |