summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/area_3d.cpp58
-rw-r--r--scene/3d/area_3d.h10
-rw-r--r--scene/3d/audio_stream_player_3d.cpp35
-rw-r--r--scene/3d/baked_lightmap.cpp9
-rw-r--r--scene/3d/bone_attachment_3d.cpp9
-rw-r--r--scene/3d/camera_3d.cpp71
-rw-r--r--scene/3d/collision_object_3d.cpp24
-rw-r--r--scene/3d/collision_polygon_3d.cpp12
-rw-r--r--scene/3d/collision_shape_3d.cpp15
-rw-r--r--scene/3d/cpu_particles_3d.cpp47
-rw-r--r--scene/3d/gi_probe.cpp9
-rw-r--r--scene/3d/gpu_particles_3d.cpp24
-rw-r--r--scene/3d/immediate_geometry_3d.cpp3
-rw-r--r--scene/3d/light_3d.cpp6
-rw-r--r--scene/3d/listener_3d.cpp18
-rw-r--r--scene/3d/mesh_instance_3d.cpp61
-rw-r--r--scene/3d/multimesh_instance_3d.cpp10
-rw-r--r--scene/3d/navigation_agent_3d.cpp20
-rw-r--r--scene/3d/navigation_obstacle_3d.cpp11
-rw-r--r--scene/3d/navigation_region_3d.cpp18
-rw-r--r--scene/3d/node_3d.cpp85
-rw-r--r--scene/3d/path_3d.cpp39
-rw-r--r--scene/3d/physics_body_3d.cpp206
-rw-r--r--scene/3d/physics_body_3d.h5
-rw-r--r--scene/3d/physics_joint_3d.cpp68
-rw-r--r--scene/3d/proximity_group_3d.cpp3
-rw-r--r--scene/3d/ray_cast_3d.cpp79
-rw-r--r--scene/3d/remote_transform_3d.cpp27
-rw-r--r--scene/3d/skeleton_3d.cpp64
-rw-r--r--scene/3d/skeleton_ik_3d.cpp42
-rw-r--r--scene/3d/soft_body_3d.cpp51
-rw-r--r--scene/3d/spring_arm_3d.cpp3
-rw-r--r--scene/3d/sprite_3d.cpp130
-rw-r--r--scene/3d/vehicle_body_3d.cpp27
-rw-r--r--scene/3d/velocity_tracker_3d.cpp3
-rw-r--r--scene/3d/visibility_notifier_3d.cpp28
-rw-r--r--scene/3d/visual_instance_3d.cpp3
-rw-r--r--scene/3d/voxelizer.cpp44
-rw-r--r--scene/3d/world_environment.cpp3
-rw-r--r--scene/3d/xr_nodes.cpp15
40 files changed, 909 insertions, 486 deletions
diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp
index 3b5b6c0dd6..a024757927 100644
--- a/scene/3d/area_3d.cpp
+++ b/scene/3d/area_3d.cpp
@@ -165,8 +165,9 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
}
}
E->get().rc++;
- if (node)
+ if (node) {
E->get().shapes.insert(ShapePair(p_body_shape, p_area_shape));
+ }
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_area_shape);
@@ -175,8 +176,9 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
} else {
E->get().rc--;
- if (node)
+ if (node) {
E->get().shapes.erase(ShapePair(p_body_shape, p_area_shape));
+ }
bool eraseit = false;
@@ -184,8 +186,9 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &Area3D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Area3D::_body_exit_tree));
- if (E->get().in_tree)
+ if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
+ }
}
eraseit = true;
@@ -194,8 +197,9 @@ void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, i
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_area_shape);
}
- if (eraseit)
+ if (eraseit) {
body_map.erase(E);
+ }
}
locked = false;
@@ -213,12 +217,14 @@ void Area3D::_clear_monitoring() {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = Object::cast_to<Node>(obj);
- if (!node) //node may have been deleted in previous frame or at other legiminate point
+ if (!node) { //node may have been deleted in previous frame or at other legiminate point
continue;
+ }
//ERR_CONTINUE(!node);
- if (!E->get().in_tree)
+ if (!E->get().in_tree) {
continue;
+ }
for (int i = 0; i < E->get().shapes.size(); i++) {
emit_signal(SceneStringNames::get_singleton()->body_shape_exited, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
@@ -240,12 +246,14 @@ void Area3D::_clear_monitoring() {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = Object::cast_to<Node>(obj);
- if (!node) //node may have been deleted in previous frame or at other legiminate point
+ if (!node) { //node may have been deleted in previous frame or at other legiminate point
continue;
+ }
//ERR_CONTINUE(!node);
- if (!E->get().in_tree)
+ if (!E->get().in_tree) {
continue;
+ }
for (int i = 0; i < E->get().shapes.size(); i++) {
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
@@ -268,8 +276,9 @@ void Area3D::_notification(int p_what) {
void Area3D::set_monitoring(bool p_enable) {
ERR_FAIL_COND_MSG(locked, "Function blocked during in/out signal. Use set_deferred(\"monitoring\", true/false).");
- if (p_enable == monitoring)
+ if (p_enable == monitoring) {
return;
+ }
monitoring = p_enable;
@@ -342,8 +351,9 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
}
}
E->get().rc++;
- if (node)
+ if (node) {
E->get().shapes.insert(AreaShapePair(p_area_shape, p_self_shape));
+ }
if (!node || E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->area_shape_entered, objid, node, p_area_shape, p_self_shape);
@@ -352,8 +362,9 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
} else {
E->get().rc--;
- if (node)
+ if (node) {
E->get().shapes.erase(AreaShapePair(p_area_shape, p_self_shape));
+ }
bool eraseit = false;
@@ -372,8 +383,9 @@ void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, i
emit_signal(SceneStringNames::get_singleton()->area_shape_exited, objid, obj, p_area_shape, p_self_shape);
}
- if (eraseit)
+ if (eraseit) {
area_map.erase(E);
+ }
}
locked = false;
@@ -403,8 +415,9 @@ TypedArray<Node3D> Area3D::get_overlapping_bodies() const {
void Area3D::set_monitorable(bool p_enable) {
ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer3D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false).");
- if (p_enable == monitorable)
+ if (p_enable == monitorable) {
return;
+ }
monitorable = p_enable;
@@ -435,16 +448,18 @@ TypedArray<Area3D> Area3D::get_overlapping_areas() const {
bool Area3D::overlaps_area(Node *p_area) const {
ERR_FAIL_NULL_V(p_area, false);
const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_id());
- if (!E)
+ if (!E) {
return false;
+ }
return E->get().in_tree;
}
bool Area3D::overlaps_body(Node *p_body) const {
ERR_FAIL_NULL_V(p_body, false);
const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_id());
- if (!E)
+ if (!E) {
return false;
+ }
return E->get().in_tree;
}
@@ -468,10 +483,11 @@ uint32_t Area3D::get_collision_layer() const {
void Area3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
@@ -481,10 +497,11 @@ bool Area3D::get_collision_mask_bit(int p_bit) const {
void Area3D::set_collision_layer_bit(int p_bit, bool p_value) {
uint32_t layer = get_collision_layer();
- if (p_value)
+ if (p_value) {
layer |= 1 << p_bit;
- else
+ } else {
layer &= ~(1 << p_bit);
+ }
set_collision_layer(layer);
}
@@ -554,8 +571,9 @@ void Area3D::_validate_property(PropertyInfo &property) const {
if (property.name == "audio_bus_name" || property.name == "reverb_bus_name") {
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- if (i > 0)
+ if (i > 0) {
options += ",";
+ }
String name = AudioServer::get_singleton()->get_bus_name(i);
options += name;
}
diff --git a/scene/3d/area_3d.h b/scene/3d/area_3d.h
index 377cf3ccbb..98f337d3e4 100644
--- a/scene/3d/area_3d.h
+++ b/scene/3d/area_3d.h
@@ -70,10 +70,11 @@ private:
int body_shape;
int area_shape;
bool operator<(const ShapePair &p_sp) const {
- if (body_shape == p_sp.body_shape)
+ if (body_shape == p_sp.body_shape) {
return area_shape < p_sp.area_shape;
- else
+ } else {
return body_shape < p_sp.body_shape;
+ }
}
ShapePair() {}
@@ -100,10 +101,11 @@ private:
int area_shape;
int self_shape;
bool operator<(const AreaShapePair &p_sp) const {
- if (area_shape == p_sp.area_shape)
+ if (area_shape == p_sp.area_shape) {
return self_shape < p_sp.self_shape;
- else
+ } else {
return area_shape < p_sp.area_shape;
+ }
}
AreaShapePair() {}
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index 4f37087d7e..6e4db8f382 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -213,8 +213,9 @@ void AudioStreamPlayer3D::_mix_audio() {
AudioFrame vol_inc = (target_volume - vol_prev) / float(buffer_size);
AudioFrame vol = vol_prev;
- if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.bus_index, k))
+ if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.bus_index, k)) {
continue; //may have been deleted, will be updated on process
+ }
AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.bus_index, k);
current.filter.set_mode(AudioFilterSW::HIGHSHELF);
@@ -258,8 +259,9 @@ void AudioStreamPlayer3D::_mix_audio() {
}
if (current.reverb_bus_index >= 0) {
- if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.reverb_bus_index, k))
+ if (!AudioServer::get_singleton()->thread_has_channel_mix_buffer(current.reverb_bus_index, k)) {
continue; //may have been deleted, will be updated on process
+ }
AudioFrame *rtarget = AudioServer::get_singleton()->thread_get_channel_mix_buffer(current.reverb_bus_index, k);
@@ -388,15 +390,18 @@ void AudioStreamPlayer3D::_notification(int p_what) {
Area3D *area = nullptr;
for (int i = 0; i < areas; i++) {
- if (!sr[i].collider)
+ if (!sr[i].collider) {
continue;
+ }
Area3D *tarea = Object::cast_to<Area3D>(sr[i].collider);
- if (!tarea)
+ if (!tarea) {
continue;
+ }
- if (!tarea->is_overriding_audio_bus() && !tarea->is_using_reverb_bus())
+ if (!tarea->is_overriding_audio_bus() && !tarea->is_using_reverb_bus()) {
continue;
+ }
area = tarea;
break;
@@ -408,8 +413,9 @@ void AudioStreamPlayer3D::_notification(int p_what) {
for (List<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) {
Camera3D *camera = E->get();
Viewport *vp = camera->get_viewport();
- if (!vp->is_audio_listener())
+ if (!vp->is_audio_listener()) {
continue;
+ }
bool listener_is_camera = true;
Node3D *listener_node = camera;
@@ -459,8 +465,9 @@ void AudioStreamPlayer3D::_notification(int p_what) {
Vector3 listenertopos = global_pos - listener_node->get_global_transform().origin;
float c = listenertopos.normalized().dot(get_global_transform().basis.get_axis(2).normalized()); //it's z negative
float angle = Math::rad2deg(Math::acos(c));
- if (angle > emission_angle)
+ if (angle > emission_angle) {
db_att -= -emission_angle_filter_attenuation_db;
+ }
}
output.filter_gain = Math::db2linear(db_att);
@@ -587,8 +594,9 @@ void AudioStreamPlayer3D::_notification(int p_what) {
outputs[new_output_count] = output;
new_output_count++;
- if (new_output_count == MAX_OUTPUTS)
+ if (new_output_count == MAX_OUTPUTS) {
break;
+ }
}
output_count = new_output_count;
@@ -744,10 +752,11 @@ bool AudioStreamPlayer3D::is_autoplay_enabled() {
}
void AudioStreamPlayer3D::_set_playing(bool p_enable) {
- if (p_enable)
+ if (p_enable) {
play();
- else
+ } else {
stop();
+ }
}
bool AudioStreamPlayer3D::_is_active() const {
@@ -758,8 +767,9 @@ void AudioStreamPlayer3D::_validate_property(PropertyInfo &property) const {
if (property.name == "bus") {
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
- if (i > 0)
+ if (i > 0) {
options += ",";
+ }
String name = AudioServer::get_singleton()->get_bus_name(i);
options += name;
}
@@ -852,8 +862,9 @@ AudioStreamPlayer3D::OutOfRangeMode AudioStreamPlayer3D::get_out_of_range_mode()
}
void AudioStreamPlayer3D::set_doppler_tracking(DopplerTracking p_tracking) {
- if (doppler_tracking == p_tracking)
+ if (doppler_tracking == p_tracking) {
return;
+ }
doppler_tracking = p_tracking;
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index 33db919d49..e2f1b3807d 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -275,8 +275,9 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound>
Transform xf = get_global_transform().affine_inverse() * s->get_global_transform();
for (int i = 0; i < bmeshes.size(); i += 2) {
Ref<Mesh> mesh = bmeshes[i];
- if (!mesh.is_valid())
+ if (!mesh.is_valid()) {
continue;
+ }
MeshesFound mf;
@@ -310,8 +311,9 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector<MeshesFound>
for (int i = 0; i < p_at_node->get_child_count(); i++) {
Node *child = p_at_node->get_child(i);
- if (!child->get_owner())
+ if (!child->get_owner()) {
continue; //maybe a helper
+ }
_find_meshes_and_lights(child, meshes, lights, probes);
}
@@ -557,8 +559,9 @@ void BakedLightmap::_plot_triangle_into_octree(GenProbesOctree *p_cell, float p_
subcell.position = Vector3(pos) * p_cell_size;
subcell.size = Vector3(half_size, half_size, half_size) * p_cell_size;
- if (!Geometry::triangle_box_overlap(subcell.position + subcell.size * 0.5, subcell.size * 0.5, p_triangle))
+ if (!Geometry::triangle_box_overlap(subcell.position + subcell.size * 0.5, subcell.size * 0.5, p_triangle)) {
continue;
+ }
if (p_cell->children[i] == nullptr) {
GenProbesOctree *child = memnew(GenProbesOctree);
diff --git a/scene/3d/bone_attachment_3d.cpp b/scene/3d/bone_attachment_3d.cpp
index 5e4b995aa1..68303bbfe5 100644
--- a/scene/3d/bone_attachment_3d.cpp
+++ b/scene/3d/bone_attachment_3d.cpp
@@ -37,8 +37,9 @@ void BoneAttachment3D::_validate_property(PropertyInfo &property) const {
if (parent) {
String names;
for (int i = 0; i < parent->get_bone_count(); i++) {
- if (i > 0)
+ if (i > 0) {
names += ",";
+ }
names += parent->get_bone_name(i);
}
@@ -77,13 +78,15 @@ void BoneAttachment3D::_check_unbind() {
}
void BoneAttachment3D::set_bone_name(const String &p_name) {
- if (is_inside_tree())
+ if (is_inside_tree()) {
_check_unbind();
+ }
bone_name = p_name;
- if (is_inside_tree())
+ if (is_inside_tree()) {
_check_bind();
+ }
}
String BoneAttachment3D::get_bone_name() const {
diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp
index 99d3b68996..8dc5cd4aba 100644
--- a/scene/3d/camera_3d.cpp
+++ b/scene/3d/camera_3d.cpp
@@ -75,8 +75,9 @@ void Camera3D::_validate_property(PropertyInfo &p_property) const {
}
void Camera3D::_update_camera() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
RenderingServer::get_singleton()->camera_set_transform(camera, get_camera_transform());
@@ -86,8 +87,9 @@ void Camera3D::_update_camera() {
get_viewport()->_camera_transform_changed_notify();
*/
- if (get_tree()->is_node_being_edited(this) || !is_current())
+ if (get_tree()->is_node_being_edited(this) || !is_current()) {
return;
+ }
get_viewport()->_camera_transform_changed_notify();
@@ -106,8 +108,9 @@ void Camera3D::_notification(int p_what) {
ERR_FAIL_COND(!viewport);
bool first_camera = viewport->_camera_add(this);
- if (current || first_camera)
+ if (current || first_camera) {
viewport->_camera_set(this);
+ }
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -154,8 +157,9 @@ Transform Camera3D::get_camera_transform() const {
}
void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far) {
- if (!force_change && fov == p_fovy_degrees && p_z_near == near && p_z_far == far && mode == PROJECTION_PERSPECTIVE)
+ if (!force_change && fov == p_fovy_degrees && p_z_near == near && p_z_far == far && mode == PROJECTION_PERSPECTIVE) {
return;
+ }
fov = p_fovy_degrees;
near = p_z_near;
@@ -168,8 +172,9 @@ void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_f
}
void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
- if (!force_change && size == p_size && p_z_near == near && p_z_far == far && mode == PROJECTION_ORTHOGONAL)
+ if (!force_change && size == p_size && p_z_near == near && p_z_far == far && mode == PROJECTION_ORTHOGONAL) {
return;
+ }
size = p_size;
@@ -183,8 +188,9 @@ void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
}
void Camera3D::set_frustum(float p_size, Vector2 p_offset, float p_z_near, float p_z_far) {
- if (!force_change && size == p_size && frustum_offset == p_offset && p_z_near == near && p_z_far == far && mode == PROJECTION_FRUSTUM)
+ if (!force_change && size == p_size && frustum_offset == p_offset && p_z_near == near && p_z_far == far && mode == PROJECTION_FRUSTUM) {
return;
+ }
size = p_size;
frustum_offset = p_offset;
@@ -213,8 +219,9 @@ RID Camera3D::get_camera() const {
void Camera3D::make_current() {
current = true;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
get_viewport()->_camera_set(this);
@@ -223,8 +230,9 @@ void Camera3D::make_current() {
void Camera3D::clear_current(bool p_enable_next) {
current = false;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (get_viewport()->get_camera() == this) {
get_viewport()->_camera_set(nullptr);
@@ -246,8 +254,9 @@ void Camera3D::set_current(bool p_current) {
bool Camera3D::is_current() const {
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
return get_viewport()->get_camera() == this;
- } else
+ } else {
return current;
+ }
}
bool Camera3D::_can_gizmo_scale() const {
@@ -320,10 +329,11 @@ Vector<Vector3> Camera3D::get_near_plane_points() const {
CameraMatrix cm;
- if (mode == PROJECTION_ORTHOGONAL)
+ if (mode == PROJECTION_ORTHOGONAL) {
cm.set_orthogonal(size, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
- else
+ } else {
cm.set_perspective(fov, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
+ }
Vector3 endpoints[8];
cm.get_endpoints(Transform(), endpoints);
@@ -343,10 +353,11 @@ Point2 Camera3D::unproject_position(const Vector3 &p_pos) const {
CameraMatrix cm;
- if (mode == PROJECTION_ORTHOGONAL)
+ if (mode == PROJECTION_ORTHOGONAL) {
cm.set_orthogonal(size, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
- else
+ } else {
cm.set_perspective(fov, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
+ }
Plane p(get_camera_transform().xform_inv(p_pos), 1.0);
@@ -370,10 +381,11 @@ Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const
CameraMatrix cm;
- if (mode == PROJECTION_ORTHOGONAL)
+ if (mode == PROJECTION_ORTHOGONAL) {
cm.set_orthogonal(size, viewport_size.aspect(), p_z_depth, far, keep_aspect == KEEP_WIDTH);
- else
+ } else {
cm.set_perspective(fov, viewport_size.aspect(), p_z_depth, far, keep_aspect == KEEP_WIDTH);
+ }
Vector2 vp_he = cm.get_viewport_half_extents();
@@ -389,10 +401,11 @@ Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const
void Camera3D::set_environment(const Ref<Environment> &p_environment) {
environment = p_environment;
- if (environment.is_valid())
+ if (environment.is_valid()) {
RS::get_singleton()->camera_set_environment(camera, environment->get_rid());
- else
+ } else {
RS::get_singleton()->camera_set_environment(camera, RID());
+ }
_update_camera_mode();
}
@@ -402,10 +415,11 @@ Ref<Environment> Camera3D::get_environment() const {
void Camera3D::set_effects(const Ref<CameraEffects> &p_effects) {
effects = p_effects;
- if (effects.is_valid())
+ if (effects.is_valid()) {
RS::get_singleton()->camera_set_camera_effects(camera, effects->get_rid());
- else
+ } else {
RS::get_singleton()->camera_set_camera_effects(camera, RID());
+ }
_update_camera_mode();
}
@@ -425,8 +439,9 @@ Camera3D::KeepAspect Camera3D::get_keep_aspect_mode() const {
}
void Camera3D::set_doppler_tracking(DopplerTracking p_tracking) {
- if (doppler_tracking == p_tracking)
+ if (doppler_tracking == p_tracking) {
return;
+ }
doppler_tracking = p_tracking;
if (p_tracking != DOPPLER_TRACKING_DISABLED) {
@@ -600,10 +615,11 @@ Vector<Plane> Camera3D::get_frustum() const {
Size2 viewport_size = get_viewport()->get_visible_rect().size;
CameraMatrix cm;
- if (mode == PROJECTION_PERSPECTIVE)
+ if (mode == PROJECTION_PERSPECTIVE) {
cm.set_perspective(fov, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
- else
+ } else {
cm.set_orthogonal(size, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH);
+ }
return cm.get_projection_planes(get_camera_transform());
}
@@ -761,10 +777,11 @@ uint32_t ClippedCamera3D::get_collision_mask() const {
void ClippedCamera3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
@@ -779,8 +796,9 @@ void ClippedCamera3D::add_exception_rid(const RID &p_rid) {
void ClippedCamera3D::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
add_exception_rid(co->get_rid());
}
@@ -791,8 +809,9 @@ void ClippedCamera3D::remove_exception_rid(const RID &p_rid) {
void ClippedCamera3D::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
remove_exception_rid(co->get_rid());
}
diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp
index f1ca3770e0..356992e922 100644
--- a/scene/3d/collision_object_3d.cpp
+++ b/scene/3d/collision_object_3d.cpp
@@ -36,26 +36,29 @@
void CollisionObject3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
- if (area)
+ if (area) {
PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform());
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ }
RID space = get_world_3d()->get_space();
if (area) {
PhysicsServer3D::get_singleton()->area_set_space(rid, space);
- } else
+ } else {
PhysicsServer3D::get_singleton()->body_set_space(rid, space);
+ }
_update_pickable();
//get space
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- if (area)
+ if (area) {
PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform());
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform());
+ }
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -65,8 +68,9 @@ void CollisionObject3D::_notification(int p_what) {
case NOTIFICATION_EXIT_WORLD: {
if (area) {
PhysicsServer3D::get_singleton()->area_set_space(rid, RID());
- } else
+ } else {
PhysicsServer3D::get_singleton()->body_set_space(rid, RID());
+ }
} break;
}
@@ -94,14 +98,16 @@ void CollisionObject3D::_mouse_exit() {
}
void CollisionObject3D::_update_pickable() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
bool pickable = ray_pickable && is_visible_in_tree();
- if (area)
+ if (area) {
PhysicsServer3D::get_singleton()->area_set_ray_pickable(rid, pickable);
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_ray_pickable(rid, pickable);
+ }
}
void CollisionObject3D::set_ray_pickable(bool p_ray_pickable) {
diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp
index 4a87ce0def..bad4a1fddd 100644
--- a/scene/3d/collision_polygon_3d.cpp
+++ b/scene/3d/collision_polygon_3d.cpp
@@ -35,17 +35,20 @@
#include "scene/resources/convex_polygon_shape_3d.h"
void CollisionPolygon3D::_build_polygon() {
- if (!parent)
+ if (!parent) {
return;
+ }
parent->shape_owner_clear_shapes(owner_id);
- if (polygon.size() == 0)
+ if (polygon.size() == 0) {
return;
+ }
Vector<Vector<Vector2>> decomp = Geometry::decompose_polygon_in_convex(polygon);
- if (decomp.size() == 0)
+ if (decomp.size() == 0) {
return;
+ }
//here comes the sun, lalalala
//decompose concave into multiple convex polygons and add them
@@ -73,8 +76,9 @@ void CollisionPolygon3D::_build_polygon() {
void CollisionPolygon3D::_update_in_shape_owner(bool p_xform_only) {
parent->shape_owner_set_transform(owner_id, get_transform());
- if (p_xform_only)
+ if (p_xform_only) {
return;
+ }
parent->shape_owner_set_disabled(owner_id, disabled);
}
diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp
index 711dfd6fb9..56367e9bdd 100644
--- a/scene/3d/collision_shape_3d.cpp
+++ b/scene/3d/collision_shape_3d.cpp
@@ -46,8 +46,9 @@
void CollisionShape3D::make_convex_from_brothers() {
Node *p = get_parent();
- if (!p)
+ if (!p) {
return;
+ }
for (int i = 0; i < p->get_child_count(); i++) {
Node *n = p->get_child(i);
@@ -64,8 +65,9 @@ void CollisionShape3D::make_convex_from_brothers() {
void CollisionShape3D::_update_in_shape_owner(bool p_xform_only) {
parent->shape_owner_set_transform(owner_id, get_transform());
- if (p_xform_only)
+ if (p_xform_only) {
return;
+ }
parent->shape_owner_set_disabled(owner_id, disabled);
}
@@ -162,8 +164,9 @@ void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
}
}
- if (is_inside_tree())
+ if (is_inside_tree()) {
_shape_changed();
+ }
update_configuration_warning();
}
@@ -193,8 +196,9 @@ CollisionShape3D::CollisionShape3D() {
}
CollisionShape3D::~CollisionShape3D() {
- if (!shape.is_null())
+ if (!shape.is_null()) {
shape->unregister_owner(this);
+ }
//RenderingServer::get_singleton()->free(indicator);
}
@@ -207,8 +211,9 @@ void CollisionShape3D::_update_debug_shape() {
}
Ref<Shape3D> s = get_shape();
- if (s.is_null())
+ if (s.is_null()) {
return;
+ }
Ref<Mesh> mesh = s->get_debug_mesh();
MeshInstance3D *mi = memnew(MeshInstance3D);
diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp
index cd80607692..4244a11592 100644
--- a/scene/3d/cpu_particles_3d.cpp
+++ b/scene/3d/cpu_particles_3d.cpp
@@ -44,16 +44,18 @@ Vector<Face3> CPUParticles3D::get_faces(uint32_t p_usage_flags) const {
}
void CPUParticles3D::set_emitting(bool p_emitting) {
- if (emitting == p_emitting)
+ if (emitting == p_emitting) {
return;
+ }
emitting = p_emitting;
if (emitting) {
set_process_internal(true);
// first update before rendering to avoid one frame delay after emitting starts
- if (time == 0)
+ if (time == 0) {
_update_internal();
+ }
}
}
@@ -206,15 +208,17 @@ String CPUParticles3D::get_configuration_warning() const {
anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES);
if (!mesh_found) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("Nothing is visible because no mesh has been assigned.");
}
if (!anim_material_found && (get_param(PARAM_ANIM_SPEED) != 0.0 || get_param(PARAM_ANIM_OFFSET) != 0.0 ||
get_param_curve(PARAM_ANIM_SPEED).is_valid() || get_param_curve(PARAM_ANIM_OFFSET).is_valid())) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("CPUParticles3D animation requires the usage of a StandardMaterial3D whose Billboard Mode is set to \"Particle Billboard\".");
}
@@ -290,8 +294,9 @@ float CPUParticles3D::get_param_randomness(Parameter p_param) const {
static void _adjust_curve_range(const Ref<Curve> &p_curve, float p_min, float p_max) {
Ref<Curve> curve = p_curve;
- if (!curve.is_valid())
+ if (!curve.is_valid()) {
return;
+ }
curve->ensure_default_setup(p_min, p_max);
}
@@ -469,12 +474,14 @@ static uint32_t idhash(uint32_t x) {
static float rand_from_seed(uint32_t &seed) {
int k;
int s = int(seed);
- if (s == 0)
+ if (s == 0) {
s = 305420679;
+ }
k = s / 127773;
s = 16807 * (s - k * 127773) - 2836 * k;
- if (s < 0)
+ if (s < 0) {
s += 2147483647;
+ }
seed = uint32_t(s);
return float(seed % uint32_t(65536)) / 65535.0;
}
@@ -508,10 +515,11 @@ void CPUParticles3D::_update_internal() {
if (time == 0 && pre_process_time > 0.0) {
float frame_time;
- if (fixed_fps > 0)
+ if (fixed_fps > 0) {
frame_time = 1.0 / fixed_fps;
- else
+ } else {
frame_time = 1.0 / 30.0;
+ }
float todo = pre_process_time;
@@ -583,8 +591,9 @@ void CPUParticles3D::_particles_process(float p_delta) {
for (int i = 0; i < pcount; i++) {
Particle &p = parray[i];
- if (!emitting && !p.active)
+ if (!emitting && !p.active) {
continue;
+ }
float local_delta = p_delta;
@@ -707,8 +716,9 @@ void CPUParticles3D::_particles_process(float p_delta) {
case EMISSION_SHAPE_POINTS:
case EMISSION_SHAPE_DIRECTED_POINTS: {
int pc = emission_points.size();
- if (pc == 0)
+ if (pc == 0) {
break;
+ }
int random_idx = Math::rand() % pc;
@@ -955,8 +965,9 @@ void CPUParticles3D::_particles_process(float p_delta) {
//scale by scale
float base_scale = tex_scale * Math::lerp(parameters[PARAM_SCALE], 1.0f, p.scale_rand * randomness[PARAM_SCALE]);
- if (base_scale < 0.000001)
+ if (base_scale < 0.000001) {
base_scale = 0.000001;
+ }
p.transform.basis.scale(Vector3(1, 1, 1) * base_scale);
@@ -1058,8 +1069,9 @@ void CPUParticles3D::_update_particle_data_buffer() {
}
void CPUParticles3D::_set_redraw(bool p_redraw) {
- if (redraw == p_redraw)
+ if (redraw == p_redraw) {
return;
+ }
redraw = p_redraw;
{
@@ -1093,8 +1105,9 @@ void CPUParticles3D::_notification(int p_what) {
set_process_internal(emitting);
// first update before rendering to avoid one frame delay after emitting starts
- if (emitting && (time == 0))
+ if (emitting && (time == 0)) {
_update_internal();
+ }
}
if (p_what == NOTIFICATION_EXIT_TREE) {
@@ -1103,8 +1116,9 @@ void CPUParticles3D::_notification(int p_what) {
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
// first update before rendering to avoid one frame delay after emitting starts
- if (emitting && (time == 0))
+ if (emitting && (time == 0)) {
_update_internal();
+ }
}
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {
@@ -1168,8 +1182,9 @@ void CPUParticles3D::convert_from_particles(Node *p_particles) {
set_mesh(particles->get_draw_pass_mesh(0));
Ref<ParticlesMaterial> material = particles->get_process_material();
- if (material.is_null())
+ if (material.is_null()) {
return;
+ }
set_direction(material->get_direction());
set_spread(material->get_spread());
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 97040f55ef..1b6f9b45b9 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -371,8 +371,9 @@ void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) {
for (int i = 0; i < meshes.size(); i += 2) {
Transform mxf = meshes[i];
Ref<Mesh> mesh = meshes[i + 1];
- if (!mesh.is_valid())
+ if (!mesh.is_valid()) {
continue;
+ }
AABB aabb = mesh->get_aabb();
@@ -407,8 +408,9 @@ Vector3i GIProbe::get_estimated_cell_size() const {
axis_cell_size[longest_axis] = 1 << cell_subdiv;
for (int i = 0; i < 3; i++) {
- if (i == longest_axis)
+ if (i == longest_axis) {
continue;
+ }
axis_cell_size[i] = axis_cell_size[longest_axis];
float axis_size = bounds.size[longest_axis];
@@ -474,8 +476,9 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
} else {
Ref<GIProbeData> probe_data = get_probe_data();
- if (probe_data.is_null())
+ if (probe_data.is_null()) {
probe_data.instance();
+ }
if (bake_step_function) {
bake_step_function(pmc++, RTR("Generating Distance Field"));
diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp
index a87b57bd4d..c4480e3ed2 100644
--- a/scene/3d/gpu_particles_3d.cpp
+++ b/scene/3d/gpu_particles_3d.cpp
@@ -71,12 +71,14 @@ void GPUParticles3D::set_one_shot(bool p_one_shot) {
if (is_emitting()) {
set_process_internal(true);
- if (!one_shot)
+ if (!one_shot) {
RenderingServer::get_singleton()->particles_restart(particles);
+ }
}
- if (!one_shot)
+ if (!one_shot) {
set_process_internal(false);
+ }
}
void GPUParticles3D::set_pre_process_time(float p_time) {
@@ -109,8 +111,9 @@ void GPUParticles3D::set_use_local_coordinates(bool p_enable) {
void GPUParticles3D::set_process_material(const Ref<Material> &p_material) {
process_material = p_material;
RID material_rid;
- if (process_material.is_valid())
+ if (process_material.is_valid()) {
material_rid = process_material->get_rid();
+ }
RS::get_singleton()->particles_set_process_material(particles, material_rid);
update_configuration_warning();
@@ -191,8 +194,9 @@ void GPUParticles3D::set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh) {
draw_passes.write[p_pass] = p_mesh;
RID mesh_rid;
- if (p_mesh.is_valid())
+ if (p_mesh.is_valid()) {
mesh_rid = p_mesh->get_rid();
+ }
RS::get_singleton()->particles_set_draw_pass_mesh(particles, p_pass, mesh_rid);
@@ -241,8 +245,9 @@ String GPUParticles3D::get_configuration_warning() const {
StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(draw_passes[i]->surface_get_material(j).ptr());
anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES);
}
- if (anim_material_found)
+ if (anim_material_found) {
break;
+ }
}
}
@@ -251,22 +256,25 @@ String GPUParticles3D::get_configuration_warning() const {
anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES);
if (!meshes_found) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("Nothing is visible because meshes have not been assigned to draw passes.");
}
if (process_material.is_null()) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("A material to process the particles is not assigned, so no behavior is imprinted.");
} else {
const ParticlesMaterial *process = Object::cast_to<ParticlesMaterial>(process_material.ptr());
if (!anim_material_found && process &&
(process->get_param(ParticlesMaterial::PARAM_ANIM_SPEED) != 0.0 || process->get_param(ParticlesMaterial::PARAM_ANIM_OFFSET) != 0.0 ||
process->get_param_texture(ParticlesMaterial::PARAM_ANIM_SPEED).is_valid() || process->get_param_texture(ParticlesMaterial::PARAM_ANIM_OFFSET).is_valid())) {
- if (warnings != String())
+ if (warnings != String()) {
warnings += "\n";
+ }
warnings += "- " + TTR("Particles animation requires the usage of a StandardMaterial3D whose Billboard Mode is set to \"Particle Billboard\".");
}
}
diff --git a/scene/3d/immediate_geometry_3d.cpp b/scene/3d/immediate_geometry_3d.cpp
index 7f90176271..7ccfd527a1 100644
--- a/scene/3d/immediate_geometry_3d.cpp
+++ b/scene/3d/immediate_geometry_3d.cpp
@@ -32,8 +32,9 @@
void ImmediateGeometry3D::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture2D> &p_texture) {
RS::get_singleton()->immediate_begin(im, (RS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID());
- if (p_texture.is_valid())
+ if (p_texture.is_valid()) {
cached_textures.push_back(p_texture);
+ }
}
void ImmediateGeometry3D::set_normal(const Vector3 &p_normal) {
diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp
index e1ac562e94..814e911372 100644
--- a/scene/3d/light_3d.cpp
+++ b/scene/3d/light_3d.cpp
@@ -163,8 +163,9 @@ Ref<Texture2D> Light3D::get_projector() const {
}
void Light3D::_update_visibility() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
bool editor_ok = true;
@@ -356,8 +357,9 @@ Light3D::Light3D() {
Light3D::~Light3D() {
RS::get_singleton()->instance_set_base(get_instance(), RID());
- if (light.is_valid())
+ if (light.is_valid()) {
RenderingServer::get_singleton()->free(light);
+ }
}
/////////////////////////////////////////
diff --git a/scene/3d/listener_3d.cpp b/scene/3d/listener_3d.cpp
index 2015662401..0a5b9ad09f 100644
--- a/scene/3d/listener_3d.cpp
+++ b/scene/3d/listener_3d.cpp
@@ -46,8 +46,9 @@ bool Listener3D::_set(const StringName &p_name, const Variant &p_value) {
} else {
clear_current();
}
- } else
+ } else {
return false;
+ }
return true;
}
@@ -59,8 +60,9 @@ bool Listener3D::_get(const StringName &p_name, Variant &r_ret) const {
} else {
r_ret = is_current();
}
- } else
+ } else {
return false;
+ }
return true;
}
@@ -79,8 +81,9 @@ void Listener3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
bool first_listener = get_viewport()->_listener_add(this);
- if (!get_tree()->is_node_being_edited(this) && (current || first_listener))
+ if (!get_tree()->is_node_being_edited(this) && (current || first_listener)) {
make_current();
+ }
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
_request_listener_update();
@@ -109,16 +112,18 @@ Transform Listener3D::get_listener_transform() const {
void Listener3D::make_current() {
current = true;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
get_viewport()->_listener_set(this);
}
void Listener3D::clear_current() {
current = false;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (get_viewport()->get_listener() == this) {
get_viewport()->_listener_set(nullptr);
@@ -129,8 +134,9 @@ void Listener3D::clear_current() {
bool Listener3D::is_current() const {
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
return get_viewport()->get_listener() == this;
- } else
+ } else {
return current;
+ }
return false;
}
diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp
index 2e79f08bcd..13f40aed4f 100644
--- a/scene/3d/mesh_instance_3d.cpp
+++ b/scene/3d/mesh_instance_3d.cpp
@@ -40,8 +40,9 @@ bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
//this is not _too_ bad performance wise, really. it only arrives here if the property was not set anywhere else.
//add to it that it's probably found on first call to _set anyway.
- if (!get_instance().is_valid())
+ if (!get_instance().is_valid()) {
return false;
+ }
Map<StringName, BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name);
if (E) {
@@ -52,8 +53,9 @@ bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
if (p_name.operator String().begins_with("material/")) {
int idx = p_name.operator String().get_slicec('/', 1).to_int();
- if (idx >= materials.size() || idx < 0)
+ if (idx >= materials.size() || idx < 0) {
return false;
+ }
set_surface_material(idx, p_value);
return true;
@@ -63,8 +65,9 @@ bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
}
bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
- if (!get_instance().is_valid())
+ if (!get_instance().is_valid()) {
return false;
+ }
const Map<StringName, BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name);
if (E) {
@@ -74,8 +77,9 @@ bool MeshInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name.operator String().begins_with("material/")) {
int idx = p_name.operator String().get_slicec('/', 1).to_int();
- if (idx >= materials.size() || idx < 0)
+ if (idx >= materials.size() || idx < 0) {
return false;
+ }
r_ret = materials[idx];
return true;
}
@@ -102,8 +106,9 @@ void MeshInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
}
void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) {
- if (mesh == p_mesh)
+ if (mesh == p_mesh) {
return;
+ }
if (mesh.is_valid()) {
mesh->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed));
@@ -165,8 +170,9 @@ void MeshInstance3D::_resolve_skeleton_path() {
void MeshInstance3D::set_skin(const Ref<Skin> &p_skin) {
skin_internal = p_skin;
skin = p_skin;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_resolve_skeleton_path();
}
@@ -176,8 +182,9 @@ Ref<Skin> MeshInstance3D::get_skin() const {
void MeshInstance3D::set_skeleton_path(const NodePath &p_skeleton) {
skeleton_path = p_skeleton;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_resolve_skeleton_path();
}
@@ -186,29 +193,34 @@ NodePath MeshInstance3D::get_skeleton_path() {
}
AABB MeshInstance3D::get_aabb() const {
- if (!mesh.is_null())
+ if (!mesh.is_null()) {
return mesh->get_aabb();
+ }
return AABB();
}
Vector<Face3> MeshInstance3D::get_faces(uint32_t p_usage_flags) const {
- if (!(p_usage_flags & (FACES_SOLID | FACES_ENCLOSING)))
+ if (!(p_usage_flags & (FACES_SOLID | FACES_ENCLOSING))) {
return Vector<Face3>();
+ }
- if (mesh.is_null())
+ if (mesh.is_null()) {
return Vector<Face3>();
+ }
return mesh->get_faces();
}
Node *MeshInstance3D::create_trimesh_collision_node() {
- if (mesh.is_null())
+ if (mesh.is_null()) {
return nullptr;
+ }
Ref<Shape3D> shape = mesh->create_trimesh_shape();
- if (shape.is_null())
+ if (shape.is_null()) {
return nullptr;
+ }
StaticBody3D *static_body = memnew(StaticBody3D);
CollisionShape3D *cshape = memnew(CollisionShape3D);
@@ -231,12 +243,14 @@ void MeshInstance3D::create_trimesh_collision() {
}
Node *MeshInstance3D::create_convex_collision_node() {
- if (mesh.is_null())
+ if (mesh.is_null()) {
return nullptr;
+ }
Ref<Shape3D> shape = mesh->create_convex_shape();
- if (shape.is_null())
+ if (shape.is_null()) {
return nullptr;
+ }
StaticBody3D *static_body = memnew(StaticBody3D);
CollisionShape3D *cshape = memnew(CollisionShape3D);
@@ -273,10 +287,11 @@ void MeshInstance3D::set_surface_material(int p_surface, const Ref<Material> &p_
materials.write[p_surface] = p_material;
- if (materials[p_surface].is_valid())
+ if (materials[p_surface].is_valid()) {
RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, materials[p_surface]->get_rid());
- else
+ } else {
RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, RID());
+ }
}
Ref<Material> MeshInstance3D::get_surface_material(int p_surface) const {
@@ -313,18 +328,21 @@ void MeshInstance3D::create_debug_tangents() {
Vector<Color> colors;
Ref<Mesh> mesh = get_mesh();
- if (!mesh.is_valid())
+ if (!mesh.is_valid()) {
return;
+ }
for (int i = 0; i < mesh->get_surface_count(); i++) {
Array arrays = mesh->surface_get_arrays(i);
Vector<Vector3> verts = arrays[Mesh::ARRAY_VERTEX];
Vector<Vector3> norms = arrays[Mesh::ARRAY_NORMAL];
- if (norms.size() == 0)
+ if (norms.size() == 0) {
continue;
+ }
Vector<float> tangents = arrays[Mesh::ARRAY_TANGENT];
- if (tangents.size() == 0)
+ if (tangents.size() == 0) {
continue;
+ }
for (int j = 0; j < verts.size(); j++) {
Vector3 v = verts[j];
@@ -373,10 +391,11 @@ void MeshInstance3D::create_debug_tangents() {
add_child(mi);
#ifdef TOOLS_ENABLED
- if (this == get_tree()->get_edited_scene_root())
+ if (this == get_tree()->get_edited_scene_root()) {
mi->set_owner(this);
- else
+ } else {
mi->set_owner(get_owner());
+ }
#endif
}
}
diff --git a/scene/3d/multimesh_instance_3d.cpp b/scene/3d/multimesh_instance_3d.cpp
index 9892323173..88dff111f7 100644
--- a/scene/3d/multimesh_instance_3d.cpp
+++ b/scene/3d/multimesh_instance_3d.cpp
@@ -38,10 +38,11 @@ void MultiMeshInstance3D::_bind_methods() {
void MultiMeshInstance3D::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
multimesh = p_multimesh;
- if (multimesh.is_valid())
+ if (multimesh.is_valid()) {
set_base(multimesh->get_rid());
- else
+ } else {
set_base(RID());
+ }
}
Ref<MultiMesh> MultiMeshInstance3D::get_multimesh() const {
@@ -53,10 +54,11 @@ Vector<Face3> MultiMeshInstance3D::get_faces(uint32_t p_usage_flags) const {
}
AABB MultiMeshInstance3D::get_aabb() const {
- if (multimesh.is_null())
+ if (multimesh.is_null()) {
return AABB();
- else
+ } else {
return multimesh->get_aabb();
+ }
}
MultiMeshInstance3D::MultiMeshInstance3D() {
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index 4b1e602f77..f8d44506b6 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -108,10 +108,11 @@ void NavigationAgent3D::_notification(int p_what) {
Node *p = get_parent();
while (p != nullptr) {
nav = Object::cast_to<Navigation3D>(p);
- if (nav != nullptr)
+ if (nav != nullptr) {
p = nullptr;
- else
+ } else {
p = p->get_parent();
+ }
}
set_navigation(nav);
@@ -154,8 +155,9 @@ NavigationAgent3D::~NavigationAgent3D() {
}
void NavigationAgent3D::set_navigation(Navigation3D *p_nav) {
- if (navigation == p_nav)
+ if (navigation == p_nav) {
return; // Pointless
+ }
navigation = p_nav;
NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid());
@@ -293,12 +295,15 @@ String NavigationAgent3D::get_configuration_warning() const {
}
void NavigationAgent3D::update_navigation() {
- if (agent_parent == nullptr)
+ if (agent_parent == nullptr) {
return;
- if (navigation == nullptr)
+ }
+ if (navigation == nullptr) {
return;
- if (update_frame_id == Engine::get_singleton()->get_physics_frames())
+ }
+ if (update_frame_id == Engine::get_singleton()->get_physics_frames()) {
return;
+ }
update_frame_id = Engine::get_singleton()->get_physics_frames();
@@ -333,8 +338,9 @@ void NavigationAgent3D::update_navigation() {
emit_signal("path_changed");
}
- if (navigation_path.size() == 0)
+ if (navigation_path.size() == 0) {
return;
+ }
// Check if we can advance the navigation path
if (navigation_finished == false) {
diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp
index daa9222d84..69fd5b02fc 100644
--- a/scene/3d/navigation_obstacle_3d.cpp
+++ b/scene/3d/navigation_obstacle_3d.cpp
@@ -51,10 +51,11 @@ void NavigationObstacle3D::_notification(int p_what) {
Node *p = get_parent();
while (p != nullptr) {
nav = Object::cast_to<Navigation3D>(p);
- if (nav != nullptr)
+ if (nav != nullptr) {
p = nullptr;
- else
+ } else {
p = p->get_parent();
+ }
}
set_navigation(nav);
@@ -93,8 +94,9 @@ NavigationObstacle3D::~NavigationObstacle3D() {
}
void NavigationObstacle3D::set_navigation(Navigation3D *p_nav) {
- if (navigation == p_nav)
+ if (navigation == p_nav) {
return; // Pointless
+ }
navigation = p_nav;
NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid());
@@ -145,8 +147,9 @@ void NavigationObstacle3D::update_agent_shape() {
radius *= MAX(s.x, MAX(s.y, s.z));
}
- if (radius == 0.0)
+ if (radius == 0.0) {
radius = 1.0; // Never a 0 radius
+ }
// Initialize the Agent as an object
NavigationServer3D::get_singleton()->agent_set_neighbor_dist(agent, 0.0);
diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp
index bc13b7097f..15ed448a65 100644
--- a/scene/3d/navigation_region_3d.cpp
+++ b/scene/3d/navigation_region_3d.cpp
@@ -36,12 +36,14 @@
#include "servers/navigation_server_3d.h"
void NavigationRegion3D::set_enabled(bool p_enabled) {
- if (enabled == p_enabled)
+ if (enabled == p_enabled) {
return;
+ }
enabled = p_enabled;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (!enabled) {
NavigationServer3D::get_singleton()->region_set_map(region, RID());
@@ -117,8 +119,9 @@ void NavigationRegion3D::_notification(int p_what) {
}
void NavigationRegion3D::set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh) {
- if (p_navmesh == navmesh)
+ if (p_navmesh == navmesh) {
return;
+ }
if (navmesh.is_valid()) {
navmesh->remove_change_receptor(this);
@@ -182,16 +185,18 @@ void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) {
}
String NavigationRegion3D::get_configuration_warning() const {
- if (!is_visible_in_tree() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree()) {
return String();
+ }
if (!navmesh.is_valid()) {
return TTR("A NavigationMesh resource must be set or created for this node to work.");
}
const Node3D *c = this;
while (c) {
- if (Object::cast_to<Navigation3D>(c))
+ if (Object::cast_to<Navigation3D>(c)) {
return String();
+ }
c = Object::cast_to<Node3D>(c->get_parent());
}
@@ -227,7 +232,8 @@ NavigationRegion3D::NavigationRegion3D() {
}
NavigationRegion3D::~NavigationRegion3D() {
- if (navmesh.is_valid())
+ if (navmesh.is_valid()) {
navmesh->remove_change_receptor(this);
+ }
NavigationServer3D::get_singleton()->free(region);
}
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp
index 2a1b35ae39..73f17060df 100644
--- a/scene/3d/node_3d.cpp
+++ b/scene/3d/node_3d.cpp
@@ -103,8 +103,9 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) {
data.children_lock++;
for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) {
- if (E->get()->data.toplevel_active)
+ if (E->get()->data.toplevel_active) {
continue; //don't propagate to a toplevel
+ }
E->get()->_propagate_transform_changed(p_origin);
}
#ifdef TOOLS_ENABLED
@@ -125,13 +126,15 @@ void Node3D::_notification(int p_what) {
ERR_FAIL_COND(!get_tree());
Node *p = get_parent();
- if (p)
+ if (p) {
data.parent = Object::cast_to<Node3D>(p);
+ }
- if (data.parent)
+ if (data.parent) {
data.C = data.parent->data.children.push_back(this);
- else
+ } else {
data.C = nullptr;
+ }
if (data.toplevel && !Engine::get_singleton()->is_editor_hint()) {
if (data.parent) {
@@ -149,10 +152,12 @@ void Node3D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
notification(NOTIFICATION_EXIT_WORLD, true);
- if (xform_change.in_list())
+ if (xform_change.in_list()) {
get_tree()->xform_change_list.remove(&xform_change);
- if (data.C)
+ }
+ if (data.C) {
data.parent->data.children.erase(data.C);
+ }
data.parent = nullptr;
data.C = nullptr;
data.toplevel_active = false;
@@ -287,15 +292,17 @@ Node3D *Node3D::get_parent_spatial() const {
}
Transform Node3D::get_relative_transform(const Node *p_parent) const {
- if (p_parent == this)
+ if (p_parent == this) {
return Transform();
+ }
ERR_FAIL_COND_V(!data.parent, Transform());
- if (p_parent == data.parent)
+ if (p_parent == data.parent) {
return get_transform();
- else
+ } else {
return data.parent->get_relative_transform(p_parent) * get_transform();
+ }
}
void Node3D::set_translation(const Vector3 &p_translation) {
@@ -373,14 +380,18 @@ Vector3 Node3D::get_scale() const {
void Node3D::update_gizmo() {
#ifdef TOOLS_ENABLED
- if (!is_inside_world())
+ if (!is_inside_world()) {
return;
- if (!data.gizmo.is_valid())
+ }
+ if (!data.gizmo.is_valid()) {
get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
- if (!data.gizmo.is_valid())
+ }
+ if (!data.gizmo.is_valid()) {
return;
- if (data.gizmo_dirty)
+ }
+ if (data.gizmo_dirty) {
return;
+ }
data.gizmo_dirty = true;
MessageQueue::get_singleton()->push_call(this, "_update_gizmo");
#endif
@@ -389,10 +400,12 @@ void Node3D::update_gizmo() {
void Node3D::set_gizmo(const Ref<Node3DGizmo> &p_gizmo) {
#ifdef TOOLS_ENABLED
- if (data.gizmo_disabled)
+ if (data.gizmo_disabled) {
return;
- if (data.gizmo.is_valid() && is_inside_world())
+ }
+ if (data.gizmo.is_valid() && is_inside_world()) {
data.gizmo->free();
+ }
data.gizmo = p_gizmo;
if (data.gizmo.is_valid() && is_inside_world()) {
data.gizmo->create();
@@ -417,14 +430,16 @@ Ref<Node3DGizmo> Node3D::get_gizmo() const {
void Node3D::_update_gizmo() {
#ifdef TOOLS_ENABLED
- if (!is_inside_world())
+ if (!is_inside_world()) {
return;
+ }
data.gizmo_dirty = false;
if (data.gizmo.is_valid()) {
- if (is_visible_in_tree())
+ if (is_visible_in_tree()) {
data.gizmo->redraw();
- else
+ } else {
data.gizmo->clear();
+ }
}
#endif
}
@@ -432,8 +447,9 @@ void Node3D::_update_gizmo() {
#ifdef TOOLS_ENABLED
void Node3D::set_disable_gizmo(bool p_enabled) {
data.gizmo_disabled = p_enabled;
- if (!p_enabled && data.gizmo.is_valid())
+ if (!p_enabled && data.gizmo.is_valid()) {
data.gizmo = Ref<Node3DGizmo>();
+ }
}
#endif
@@ -447,13 +463,15 @@ bool Node3D::is_scale_disabled() const {
}
void Node3D::set_as_toplevel(bool p_enabled) {
- if (data.toplevel == p_enabled)
+ if (data.toplevel == p_enabled) {
return;
+ }
if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
- if (p_enabled)
+ if (p_enabled) {
set_transform(get_global_transform());
- else if (data.parent)
+ } else if (data.parent) {
set_transform(data.parent->get_global_transform().affine_inverse() * get_global_transform());
+ }
data.toplevel = p_enabled;
data.toplevel_active = p_enabled;
@@ -479,38 +497,44 @@ void Node3D::_propagate_visibility_changed() {
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
_change_notify("visible");
#ifdef TOOLS_ENABLED
- if (data.gizmo.is_valid())
+ if (data.gizmo.is_valid()) {
_update_gizmo();
+ }
#endif
for (List<Node3D *>::Element *E = data.children.front(); E; E = E->next()) {
Node3D *c = E->get();
- if (!c || !c->data.visible)
+ if (!c || !c->data.visible) {
continue;
+ }
c->_propagate_visibility_changed();
}
}
void Node3D::show() {
- if (data.visible)
+ if (data.visible) {
return;
+ }
data.visible = true;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_propagate_visibility_changed();
}
void Node3D::hide() {
- if (!data.visible)
+ if (!data.visible) {
return;
+ }
data.visible = false;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_propagate_visibility_changed();
}
@@ -529,10 +553,11 @@ bool Node3D::is_visible_in_tree() const {
}
void Node3D::set_visible(bool p_visible) {
- if (p_visible)
+ if (p_visible) {
show();
- else
+ } else {
hide();
+ }
}
bool Node3D::is_visible() const {
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp
index 6f57bf81c4..dcfdf8efcf 100644
--- a/scene/3d/path_3d.cpp
+++ b/scene/3d/path_3d.cpp
@@ -37,8 +37,9 @@ void Path3D::_notification(int p_what) {
}
void Path3D::_curve_changed() {
- if (is_inside_tree() && Engine::get_singleton()->is_editor_hint())
+ if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
update_gizmo();
+ }
if (is_inside_tree()) {
emit_signal("curve_changed");
}
@@ -88,12 +89,14 @@ Path3D::Path3D() {
//////////////
void PathFollow3D::_update_transform() {
- if (!path)
+ if (!path) {
return;
+ }
Ref<Curve3D> c = path->get_curve();
- if (!c.is_valid())
+ if (!c.is_valid()) {
return;
+ }
if (delta_offset == 0) {
return;
@@ -120,10 +123,11 @@ void PathFollow3D::_update_transform() {
if (rotation_mode == ROTATION_ORIENTED) {
Vector3 forward = c->interpolate_baked(o_next, cubic) - pos;
- if (forward.length_squared() < CMP_EPSILON2)
+ if (forward.length_squared() < CMP_EPSILON2) {
forward = Vector3(0, 0, 1);
- else
+ } else {
forward.normalize();
+ }
Vector3 up = c->interpolate_baked_up_vector(offset, true);
@@ -131,10 +135,11 @@ void PathFollow3D::_update_transform() {
Vector3 up1 = c->interpolate_baked_up_vector(o_next, true);
Vector3 axis = up.cross(up1);
- if (axis.length_squared() < CMP_EPSILON2)
+ if (axis.length_squared() < CMP_EPSILON2) {
axis = forward;
- else
+ } else {
axis.normalize();
+ }
up.rotate(axis, up.angle_to(up1) * 0.5f);
}
@@ -234,16 +239,18 @@ bool PathFollow3D::get_cubic_interpolation() const {
void PathFollow3D::_validate_property(PropertyInfo &property) const {
if (property.name == "offset") {
float max = 10000;
- if (path && path->get_curve().is_valid())
+ if (path && path->get_curve().is_valid()) {
max = path->get_curve()->get_baked_length();
+ }
property.hint_string = "0," + rtos(max) + ",0.01,or_lesser,or_greater";
}
}
String PathFollow3D::get_configuration_warning() const {
- if (!is_visible_in_tree() || !is_inside_tree())
+ if (!is_visible_in_tree() || !is_inside_tree()) {
return String();
+ }
if (!Object::cast_to<Path3D>(get_parent())) {
return TTR("PathFollow3D only works when set as a child of a Path3D node.");
@@ -320,8 +327,9 @@ void PathFollow3D::set_offset(float p_offset) {
void PathFollow3D::set_h_offset(float p_h_offset) {
h_offset = p_h_offset;
- if (path)
+ if (path) {
_update_transform();
+ }
}
float PathFollow3D::get_h_offset() const {
@@ -330,8 +338,9 @@ float PathFollow3D::get_h_offset() const {
void PathFollow3D::set_v_offset(float p_v_offset) {
v_offset = p_v_offset;
- if (path)
+ if (path) {
_update_transform();
+ }
}
float PathFollow3D::get_v_offset() const {
@@ -343,15 +352,17 @@ float PathFollow3D::get_offset() const {
}
void PathFollow3D::set_unit_offset(float p_unit_offset) {
- if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
+ if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) {
set_offset(p_unit_offset * path->get_curve()->get_baked_length());
+ }
}
float PathFollow3D::get_unit_offset() const {
- if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
+ if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) {
return get_offset() / path->get_curve()->get_baked_length();
- else
+ } else {
return 0;
+ }
}
void PathFollow3D::set_rotation_mode(RotationMode p_rotation_mode) {
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index 68a13f5612..385b4e81a8 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -76,10 +76,11 @@ uint32_t PhysicsBody3D::get_collision_mask() const {
void PhysicsBody3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
@@ -89,10 +90,11 @@ bool PhysicsBody3D::get_collision_mask_bit(int p_bit) const {
void PhysicsBody3D::set_collision_layer_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_layer();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_layer(mask);
}
@@ -305,8 +307,9 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
}
}
//E->get().rc++;
- if (node)
+ if (node) {
E->get().shapes.insert(ShapePair(p_body_shape, p_local_shape));
+ }
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_local_shape);
@@ -315,8 +318,9 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
} else {
//E->get().rc--;
- if (node)
+ if (node) {
E->get().shapes.erase(ShapePair(p_body_shape, p_local_shape));
+ }
bool in_tree = E->get().in_tree;
@@ -324,8 +328,9 @@ void RigidBody3D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree));
- if (in_tree)
+ if (in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_exited, node);
+ }
}
contact_monitor->body_map.erase(E);
@@ -357,8 +362,9 @@ void RigidBody3D::_direct_state_changed(Object *p_state) {
sleeping = state->is_sleeping();
emit_signal(SceneStringNames::get_singleton()->sleeping_state_changed);
}
- if (get_script_instance())
+ if (get_script_instance()) {
get_script_instance()->call("_integrate_forces", state);
+ }
set_ignore_transform_notification(false);
if (contact_monitor) {
@@ -564,10 +570,11 @@ void RigidBody3D::set_axis_velocity(const Vector3 &p_axis) {
void RigidBody3D::set_linear_velocity(const Vector3 &p_velocity) {
linear_velocity = p_velocity;
- if (state)
+ if (state) {
state->set_linear_velocity(linear_velocity);
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
+ }
}
Vector3 RigidBody3D::get_linear_velocity() const {
@@ -576,10 +583,11 @@ Vector3 RigidBody3D::get_linear_velocity() const {
void RigidBody3D::set_angular_velocity(const Vector3 &p_velocity) {
angular_velocity = p_velocity;
- if (state)
+ if (state) {
state->set_angular_velocity(angular_velocity);
- else
+ } else {
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
+ }
}
Vector3 RigidBody3D::get_angular_velocity() const {
@@ -587,8 +595,9 @@ Vector3 RigidBody3D::get_angular_velocity() const {
}
void RigidBody3D::set_use_custom_integrator(bool p_enable) {
- if (custom_integrator == p_enable)
+ if (custom_integrator == p_enable) {
return;
+ }
custom_integrator = p_enable;
PhysicsServer3D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
@@ -659,8 +668,9 @@ bool RigidBody3D::is_using_continuous_collision_detection() const {
}
void RigidBody3D::set_contact_monitor(bool p_enabled) {
- if (p_enabled == is_contact_monitor_enabled())
+ if (p_enabled == is_contact_monitor_enabled()) {
return;
+ }
if (!p_enabled) {
ERR_FAIL_COND_MSG(contact_monitor->locked, "Can't disable contact monitoring during in/out callback. Use call_deferred(\"set_contact_monitor\", false) instead.");
@@ -855,8 +865,9 @@ RigidBody3D::RigidBody3D() :
}
RigidBody3D::~RigidBody3D() {
- if (contact_monitor)
+ if (contact_monitor) {
memdelete(contact_monitor);
+ }
}
void RigidBody3D::_reload_physics_characteristics() {
@@ -1014,8 +1025,9 @@ Vector3 KinematicBody3D::move_and_slide(const Vector3 &p_linear_velocity, const
}
}
- if (!found_collision || motion == Vector3())
+ if (!found_collision || motion == Vector3()) {
break;
+ }
--p_max_slides;
}
@@ -1259,8 +1271,9 @@ Vector3 KinematicCollision3D::get_remainder() const {
}
Object *KinematicCollision3D::get_local_shape() const {
- if (!owner)
+ if (!owner) {
return nullptr;
+ }
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
return owner->shape_owner_get_owner(ownerid);
}
@@ -1380,18 +1393,21 @@ bool PhysicalBone3D::PinJointData::_set(const StringName &p_name, const Variant
if ("joint_constraints/bias" == p_name) {
bias = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_BIAS, bias);
+ }
} else if ("joint_constraints/damping" == p_name) {
damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_DAMPING, damping);
+ }
} else if ("joint_constraints/impulse_clamp" == p_name) {
impulse_clamp = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP, impulse_clamp);
+ }
} else {
return false;
@@ -1433,28 +1449,33 @@ bool PhysicalBone3D::ConeJointData::_set(const StringName &p_name, const Variant
if ("joint_constraints/swing_span" == p_name) {
swing_span = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, swing_span);
+ }
} else if ("joint_constraints/twist_span" == p_name) {
twist_span = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN, twist_span);
+ }
} else if ("joint_constraints/bias" == p_name) {
bias = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_BIAS, bias);
+ }
} else if ("joint_constraints/softness" == p_name) {
softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS, softness);
+ }
} else if ("joint_constraints/relaxation" == p_name) {
relaxation = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION, relaxation);
+ }
} else {
return false;
@@ -1502,33 +1523,39 @@ bool PhysicalBone3D::HingeJointData::_set(const StringName &p_name, const Varian
if ("joint_constraints/angular_limit_enabled" == p_name) {
angular_limit_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_flag(j, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, angular_limit_enabled);
+ }
} else if ("joint_constraints/angular_limit_upper" == p_name) {
angular_limit_upper = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, angular_limit_upper);
+ }
} else if ("joint_constraints/angular_limit_lower" == p_name) {
angular_limit_lower = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, angular_limit_lower);
+ }
} else if ("joint_constraints/angular_limit_bias" == p_name) {
angular_limit_bias = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, angular_limit_bias);
+ }
} else if ("joint_constraints/angular_limit_softness" == p_name) {
angular_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, angular_limit_softness);
+ }
} else if ("joint_constraints/angular_limit_relaxation" == p_name) {
angular_limit_relaxation = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, angular_limit_relaxation);
+ }
} else {
return false;
@@ -1579,53 +1606,63 @@ bool PhysicalBone3D::SliderJointData::_set(const StringName &p_name, const Varia
if ("joint_constraints/linear_limit_upper" == p_name) {
linear_limit_upper = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, linear_limit_upper);
+ }
} else if ("joint_constraints/linear_limit_lower" == p_name) {
linear_limit_lower = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, linear_limit_lower);
+ }
} else if ("joint_constraints/linear_limit_softness" == p_name) {
linear_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, linear_limit_softness);
+ }
} else if ("joint_constraints/linear_limit_restitution" == p_name) {
linear_limit_restitution = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, linear_limit_restitution);
+ }
} else if ("joint_constraints/linear_limit_damping" == p_name) {
linear_limit_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, linear_limit_restitution);
+ }
} else if ("joint_constraints/angular_limit_upper" == p_name) {
angular_limit_upper = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, angular_limit_upper);
+ }
} else if ("joint_constraints/angular_limit_lower" == p_name) {
angular_limit_lower = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, angular_limit_lower);
+ }
} else if ("joint_constraints/angular_limit_softness" == p_name) {
angular_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
+ }
} else if ("joint_constraints/angular_limit_restitution" == p_name) {
angular_limit_restitution = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness);
+ }
} else if ("joint_constraints/angular_limit_damping" == p_name) {
angular_limit_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, angular_limit_damping);
+ }
} else {
return false;
@@ -1707,108 +1744,129 @@ bool PhysicalBone3D::SixDOFJointData::_set(const StringName &p_name, const Varia
if ("linear_limit_enabled" == var_name) {
axis_data[axis].linear_limit_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, axis_data[axis].linear_limit_enabled);
+ }
} else if ("linear_limit_upper" == var_name) {
axis_data[axis].linear_limit_upper = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, axis_data[axis].linear_limit_upper);
+ }
} else if ("linear_limit_lower" == var_name) {
axis_data[axis].linear_limit_lower = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, axis_data[axis].linear_limit_lower);
+ }
} else if ("linear_limit_softness" == var_name) {
axis_data[axis].linear_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, axis_data[axis].linear_limit_softness);
+ }
} else if ("linear_spring_enabled" == var_name) {
axis_data[axis].linear_spring_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, axis_data[axis].linear_spring_enabled);
+ }
} else if ("linear_spring_stiffness" == var_name) {
axis_data[axis].linear_spring_stiffness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, axis_data[axis].linear_spring_stiffness);
+ }
} else if ("linear_spring_damping" == var_name) {
axis_data[axis].linear_spring_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, axis_data[axis].linear_spring_damping);
+ }
} else if ("linear_equilibrium_point" == var_name) {
axis_data[axis].linear_equilibrium_point = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].linear_equilibrium_point);
+ }
} else if ("linear_restitution" == var_name) {
axis_data[axis].linear_restitution = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, axis_data[axis].linear_restitution);
+ }
} else if ("linear_damping" == var_name) {
axis_data[axis].linear_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, axis_data[axis].linear_damping);
+ }
} else if ("angular_limit_enabled" == var_name) {
axis_data[axis].angular_limit_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, axis_data[axis].angular_limit_enabled);
+ }
} else if ("angular_limit_upper" == var_name) {
axis_data[axis].angular_limit_upper = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, axis_data[axis].angular_limit_upper);
+ }
} else if ("angular_limit_lower" == var_name) {
axis_data[axis].angular_limit_lower = Math::deg2rad(real_t(p_value));
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, axis_data[axis].angular_limit_lower);
+ }
} else if ("angular_limit_softness" == var_name) {
axis_data[axis].angular_limit_softness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, axis_data[axis].angular_limit_softness);
+ }
} else if ("angular_restitution" == var_name) {
axis_data[axis].angular_restitution = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, axis_data[axis].angular_restitution);
+ }
} else if ("angular_damping" == var_name) {
axis_data[axis].angular_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, axis_data[axis].angular_damping);
+ }
} else if ("erp" == var_name) {
axis_data[axis].erp = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, axis_data[axis].erp);
+ }
} else if ("angular_spring_enabled" == var_name) {
axis_data[axis].angular_spring_enabled = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, axis_data[axis].angular_spring_enabled);
+ }
} else if ("angular_spring_stiffness" == var_name) {
axis_data[axis].angular_spring_stiffness = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, axis_data[axis].angular_spring_stiffness);
+ }
} else if ("angular_spring_damping" == var_name) {
axis_data[axis].angular_spring_damping = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, axis_data[axis].angular_spring_damping);
+ }
} else if ("angular_equilibrium_point" == var_name) {
axis_data[axis].angular_equilibrium_point = p_value;
- if (j.is_valid())
+ if (j.is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].angular_equilibrium_point);
+ }
} else {
return false;
@@ -1925,8 +1983,9 @@ bool PhysicalBone3D::_set(const StringName &p_name, const Variant &p_value) {
if (joint_data) {
if (joint_data->_set(p_name, p_value)) {
#ifdef TOOLS_ENABLED
- if (get_gizmo().is_valid())
+ if (get_gizmo().is_valid()) {
get_gizmo()->redraw();
+ }
#endif
return true;
}
@@ -1954,8 +2013,9 @@ void PhysicalBone3D::_get_property_list(List<PropertyInfo> *p_list) const {
if (parent) {
String names;
for (int i = 0; i < parent->get_bone_count(); i++) {
- if (i > 0)
+ if (i > 0) {
names += ",";
+ }
names += parent->get_bone_name(i);
}
@@ -2130,8 +2190,9 @@ void PhysicalBone3D::_update_joint_offset() {
set_ignore_transform_notification(false);
#ifdef TOOLS_ENABLED
- if (get_gizmo().is_valid())
+ if (get_gizmo().is_valid()) {
get_gizmo()->redraw();
+ }
#endif
}
@@ -2269,11 +2330,13 @@ Skeleton3D *PhysicalBone3D::find_skeleton_parent() {
}
void PhysicalBone3D::set_joint_type(JointType p_joint_type) {
- if (p_joint_type == get_joint_type())
+ if (p_joint_type == get_joint_type()) {
return;
+ }
- if (joint_data)
+ if (joint_data) {
memdelete(joint_data);
+ }
joint_data = nullptr;
switch (p_joint_type) {
case JOINT_TYPE_PIN:
@@ -2299,8 +2362,9 @@ void PhysicalBone3D::set_joint_type(JointType p_joint_type) {
#ifdef TOOLS_ENABLED
_change_notify();
- if (get_gizmo().is_valid())
+ if (get_gizmo().is_valid()) {
get_gizmo()->redraw();
+ }
#endif
}
@@ -2470,8 +2534,9 @@ PhysicalBone3D::PhysicalBone3D() :
}
PhysicalBone3D::~PhysicalBone3D() {
- if (joint_data)
+ if (joint_data) {
memdelete(joint_data);
+ }
}
void PhysicalBone3D::update_bone_id() {
@@ -2501,8 +2566,9 @@ void PhysicalBone3D::update_offset() {
#ifdef TOOLS_ENABLED
if (parent_skeleton) {
Transform bone_transform(parent_skeleton->get_global_transform());
- if (-1 != bone_id)
+ if (-1 != bone_id) {
bone_transform *= parent_skeleton->get_bone_global_pose(bone_id);
+ }
if (gizmo_move_joint) {
bone_transform *= body_offset;
diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h
index 3a5b94e3b7..4c58c73942 100644
--- a/scene/3d/physics_body_3d.h
+++ b/scene/3d/physics_body_3d.h
@@ -139,10 +139,11 @@ protected:
int local_shape;
bool tagged;
bool operator<(const ShapePair &p_sp) const {
- if (body_shape == p_sp.body_shape)
+ if (body_shape == p_sp.body_shape) {
return local_shape < p_sp.local_shape;
- else
+ } else {
return body_shape < p_sp.body_shape;
+ }
}
ShapePair() {}
diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp
index 99d0473d9b..af4d6ae152 100644
--- a/scene/3d/physics_joint_3d.cpp
+++ b/scene/3d/physics_joint_3d.cpp
@@ -32,8 +32,9 @@
void Joint3D::_update_joint(bool p_only_free) {
if (joint.is_valid()) {
- if (ba.is_valid() && bb.is_valid())
+ if (ba.is_valid() && bb.is_valid()) {
PhysicsServer3D::get_singleton()->body_remove_collision_exception(ba, bb);
+ }
PhysicsServer3D::get_singleton()->free(joint);
joint = RID();
@@ -41,8 +42,9 @@ void Joint3D::_update_joint(bool p_only_free) {
bb = RID();
}
- if (p_only_free || !is_inside_tree())
+ if (p_only_free || !is_inside_tree()) {
return;
+ }
Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)nullptr;
Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)nullptr;
@@ -50,29 +52,34 @@ void Joint3D::_update_joint(bool p_only_free) {
PhysicsBody3D *body_a = Object::cast_to<PhysicsBody3D>(node_a);
PhysicsBody3D *body_b = Object::cast_to<PhysicsBody3D>(node_b);
- if (!body_a && body_b)
+ if (!body_a && body_b) {
SWAP(body_a, body_b);
+ }
- if (!body_a)
+ if (!body_a) {
return;
+ }
joint = _configure_joint(body_a, body_b);
- if (!joint.is_valid())
+ if (!joint.is_valid()) {
return;
+ }
PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority);
ba = body_a->get_rid();
- if (body_b)
+ if (body_b) {
bb = body_b->get_rid();
+ }
PhysicsServer3D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
}
void Joint3D::set_node_a(const NodePath &p_node_a) {
- if (a == p_node_a)
+ if (a == p_node_a) {
return;
+ }
a = p_node_a;
_update_joint();
@@ -83,8 +90,9 @@ NodePath Joint3D::get_node_a() const {
}
void Joint3D::set_node_b(const NodePath &p_node_b) {
- if (b == p_node_b)
+ if (b == p_node_b) {
return;
+ }
b = p_node_b;
_update_joint();
}
@@ -95,8 +103,9 @@ NodePath Joint3D::get_node_b() const {
void Joint3D::set_solver_priority(int p_priority) {
solver_priority = p_priority;
- if (joint.is_valid())
+ if (joint.is_valid()) {
PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority);
+ }
}
int Joint3D::get_solver_priority() const {
@@ -117,8 +126,9 @@ void Joint3D::_notification(int p_what) {
}
void Joint3D::set_exclude_nodes_from_collision(bool p_enable) {
- if (exclude_from_collision == p_enable)
+ if (exclude_from_collision == p_enable) {
return;
+ }
exclude_from_collision = p_enable;
_update_joint();
}
@@ -171,8 +181,9 @@ void PinJoint3D::_bind_methods() {
void PinJoint3D::set_param(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, 3);
params[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer3D::PinJointParam(p_param), p_value);
+ }
}
float PinJoint3D::get_param(Param p_param) const {
@@ -185,10 +196,11 @@ RID PinJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
Vector3 local_a = body_a->get_global_transform().affine_inverse().xform(pinpos);
Vector3 local_b;
- if (body_b)
+ if (body_b) {
local_b = body_b->get_global_transform().affine_inverse().xform(pinpos);
- else
+ } else {
local_b = pinpos;
+ }
RID j = PhysicsServer3D::get_singleton()->joint_create_pin(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
for (int i = 0; i < 3; i++) {
@@ -267,8 +279,9 @@ void HingeJoint3D::_bind_methods() {
void HingeJoint3D::set_param(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer3D::HingeJointParam(p_param), p_value);
+ }
update_gizmo();
}
@@ -281,8 +294,9 @@ float HingeJoint3D::get_param(Param p_param) const {
void HingeJoint3D::set_flag(Flag p_flag, bool p_value) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags[p_flag] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer3D::HingeJointFlag(p_flag), p_value);
+ }
update_gizmo();
}
@@ -416,8 +430,9 @@ void SliderJoint3D::_bind_methods() {
void SliderJoint3D::set_param(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer3D::SliderJointParam(p_param), p_value);
+ }
update_gizmo();
}
@@ -521,8 +536,9 @@ void ConeTwistJoint3D::_bind_methods() {
void ConeTwistJoint3D::set_param(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer3D::ConeTwistJointParam(p_param), p_value);
+ }
update_gizmo();
}
@@ -782,8 +798,9 @@ void Generic6DOFJoint3D::_bind_methods() {
void Generic6DOFJoint3D::set_param_x(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_x[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
+ }
update_gizmo();
}
@@ -796,8 +813,9 @@ float Generic6DOFJoint3D::get_param_x(Param p_param) const {
void Generic6DOFJoint3D::set_param_y(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_y[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
+ }
update_gizmo();
}
@@ -809,8 +827,9 @@ float Generic6DOFJoint3D::get_param_y(Param p_param) const {
void Generic6DOFJoint3D::set_param_z(Param p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
params_z[p_param] = p_value;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
+ }
update_gizmo();
}
@@ -822,8 +841,9 @@ float Generic6DOFJoint3D::get_param_z(Param p_param) const {
void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_x[p_flag] = p_enabled;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
+ }
update_gizmo();
}
@@ -835,8 +855,9 @@ bool Generic6DOFJoint3D::get_flag_x(Flag p_flag) const {
void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_y[p_flag] = p_enabled;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
+ }
update_gizmo();
}
@@ -848,8 +869,9 @@ bool Generic6DOFJoint3D::get_flag_y(Flag p_flag) const {
void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags_z[p_flag] = p_enabled;
- if (get_joint().is_valid())
+ if (get_joint().is_valid()) {
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
+ }
update_gizmo();
}
diff --git a/scene/3d/proximity_group_3d.cpp b/scene/3d/proximity_group_3d.cpp
index cef3381fc1..cdc88abf4c 100644
--- a/scene/3d/proximity_group_3d.cpp
+++ b/scene/3d/proximity_group_3d.cpp
@@ -58,8 +58,9 @@ void ProximityGroup3D::clear_groups() {
};
void ProximityGroup3D::update_groups() {
- if (grid_radius == Vector3(0, 0, 0))
+ if (grid_radius == Vector3(0, 0, 0)) {
return;
+ }
++group_version;
diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp
index 1b91e58f8f..68f4b3132c 100644
--- a/scene/3d/ray_cast_3d.cpp
+++ b/scene/3d/ray_cast_3d.cpp
@@ -37,10 +37,12 @@
void RayCast3D::set_cast_to(const Vector3 &p_point) {
cast_to = p_point;
- if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) {
update_gizmo();
- if (is_inside_tree() && get_tree()->is_debugging_collisions_hint())
+ }
+ if (is_inside_tree() && get_tree()->is_debugging_collisions_hint()) {
_update_debug_shape();
+ }
}
Vector3 RayCast3D::get_cast_to() const {
@@ -57,10 +59,11 @@ uint32_t RayCast3D::get_collision_mask() const {
void RayCast3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
@@ -73,8 +76,9 @@ bool RayCast3D::is_colliding() const {
}
Object *RayCast3D::get_collider() const {
- if (against.is_null())
+ if (against.is_null()) {
return nullptr;
+ }
return ObjectDB::get_instance(against);
}
@@ -95,16 +99,19 @@ void RayCast3D::set_enabled(bool p_enabled) {
enabled = p_enabled;
update_gizmo();
- if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint())
+ if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
set_physics_process_internal(p_enabled);
- if (!p_enabled)
+ }
+ if (!p_enabled) {
collided = false;
+ }
if (is_inside_tree() && get_tree()->is_debugging_collisions_hint()) {
- if (p_enabled)
+ if (p_enabled) {
_update_debug_shape();
- else
+ } else {
_clear_debug_shape();
+ }
}
}
@@ -113,19 +120,22 @@ bool RayCast3D::is_enabled() const {
}
void RayCast3D::set_exclude_parent_body(bool p_exclude_parent_body) {
- if (exclude_parent_body == p_exclude_parent_body)
+ if (exclude_parent_body == p_exclude_parent_body) {
return;
+ }
exclude_parent_body = p_exclude_parent_body;
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
if (Object::cast_to<CollisionObject3D>(get_parent())) {
- if (exclude_parent_body)
+ if (exclude_parent_body) {
exclude.insert(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
- else
+ } else {
exclude.erase(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
+ }
}
}
@@ -139,16 +149,19 @@ void RayCast3D::_notification(int p_what) {
if (enabled && !Engine::get_singleton()->is_editor_hint()) {
set_physics_process_internal(true);
- if (get_tree()->is_debugging_collisions_hint())
+ if (get_tree()->is_debugging_collisions_hint()) {
_update_debug_shape();
- } else
+ }
+ } else {
set_physics_process_internal(false);
+ }
if (Object::cast_to<CollisionObject3D>(get_parent())) {
- if (exclude_parent_body)
+ if (exclude_parent_body) {
exclude.insert(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
- else
+ } else {
exclude.erase(Object::cast_to<CollisionObject3D>(get_parent())->get_rid());
+ }
}
} break;
@@ -157,13 +170,15 @@ void RayCast3D::_notification(int p_what) {
set_physics_process_internal(false);
}
- if (debug_shape)
+ if (debug_shape) {
_clear_debug_shape();
+ }
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
- if (!enabled)
+ if (!enabled) {
break;
+ }
bool prev_collision_state = collided;
_update_raycast_state();
@@ -188,8 +203,9 @@ void RayCast3D::_update_raycast_state() {
Transform gt = get_global_transform();
Vector3 to = cast_to;
- if (to == Vector3())
+ if (to == Vector3()) {
to = Vector3(0, 0.01, 0);
+ }
PhysicsDirectSpaceState3D::RayResult rr;
@@ -217,8 +233,9 @@ void RayCast3D::add_exception_rid(const RID &p_rid) {
void RayCast3D::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
add_exception_rid(co->get_rid());
}
@@ -229,8 +246,9 @@ void RayCast3D::remove_exception_rid(const RID &p_rid) {
void RayCast3D::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object);
- if (!co)
+ if (!co) {
return;
+ }
remove_exception_rid(co->get_rid());
}
@@ -321,15 +339,18 @@ void RayCast3D::_create_debug_shape() {
}
void RayCast3D::_update_debug_shape() {
- if (!enabled)
+ if (!enabled) {
return;
+ }
- if (!debug_shape)
+ if (!debug_shape) {
_create_debug_shape();
+ }
MeshInstance3D *mi = static_cast<MeshInstance3D *>(debug_shape);
- if (!mi->get_mesh().is_valid())
+ if (!mi->get_mesh().is_valid()) {
return;
+ }
Ref<ArrayMesh> mesh = mi->get_mesh();
mesh->clear_surfaces();
@@ -347,14 +368,16 @@ void RayCast3D::_update_debug_shape() {
}
void RayCast3D::_clear_debug_shape() {
- if (!debug_shape)
+ if (!debug_shape) {
return;
+ }
MeshInstance3D *mi = static_cast<MeshInstance3D *>(debug_shape);
- if (mi->is_inside_tree())
+ if (mi->is_inside_tree()) {
mi->queue_delete();
- else
+ } else {
memdelete(mi);
+ }
debug_shape = nullptr;
}
diff --git a/scene/3d/remote_transform_3d.cpp b/scene/3d/remote_transform_3d.cpp
index 7872a8ee1c..95fce6b802 100644
--- a/scene/3d/remote_transform_3d.cpp
+++ b/scene/3d/remote_transform_3d.cpp
@@ -43,18 +43,22 @@ void RemoteTransform3D::_update_cache() {
}
void RemoteTransform3D::_update_remote() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
- if (cache.is_null())
+ if (cache.is_null()) {
return;
+ }
Node3D *n = Object::cast_to<Node3D>(ObjectDB::get_instance(cache));
- if (!n)
+ if (!n) {
return;
+ }
- if (!n->is_inside_tree())
+ if (!n->is_inside_tree()) {
return;
+ }
//todo make faster
if (use_global_coordinates) {
@@ -63,11 +67,13 @@ void RemoteTransform3D::_update_remote() {
} else {
Transform our_trans = get_global_transform();
- if (update_remote_rotation)
+ if (update_remote_rotation) {
n->set_rotation(our_trans.basis.get_rotation());
+ }
- if (update_remote_scale)
+ if (update_remote_scale) {
n->set_scale(our_trans.basis.get_scale());
+ }
if (update_remote_position) {
Transform n_trans = n->get_global_transform();
@@ -83,11 +89,13 @@ void RemoteTransform3D::_update_remote() {
} else {
Transform our_trans = get_transform();
- if (update_remote_rotation)
+ if (update_remote_rotation) {
n->set_rotation(our_trans.basis.get_rotation());
+ }
- if (update_remote_scale)
+ if (update_remote_scale) {
n->set_scale(our_trans.basis.get_scale());
+ }
if (update_remote_position) {
Transform n_trans = n->get_transform();
@@ -106,8 +114,9 @@ void RemoteTransform3D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
break;
+ }
if (cache.is_valid()) {
_update_remote();
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp
index 899579fdbc..7516cf95b0 100644
--- a/scene/3d/skeleton_3d.cpp
+++ b/scene/3d/skeleton_3d.cpp
@@ -69,8 +69,9 @@ SkinReference::~SkinReference() {
bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
String path = p_path;
- if (!path.begins_with("bones/"))
+ if (!path.begins_with("bones/")) {
return false;
+ }
int which = path.get_slicec('/', 1).to_int();
String what = path.get_slicec('/', 2);
@@ -82,15 +83,15 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
ERR_FAIL_INDEX_V(which, bones.size(), false);
- if (what == "parent")
+ if (what == "parent") {
set_bone_parent(which, p_value);
- else if (what == "rest")
+ } else if (what == "rest") {
set_bone_rest(which, p_value);
- else if (what == "enabled")
+ } else if (what == "enabled") {
set_bone_enabled(which, p_value);
- else if (what == "pose")
+ } else if (what == "pose") {
set_bone_pose(which, p_value);
- else if (what == "bound_children") {
+ } else if (what == "bound_children") {
Array children = p_value;
if (is_inside_tree()) {
@@ -114,25 +115,26 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const {
String path = p_path;
- if (!path.begins_with("bones/"))
+ if (!path.begins_with("bones/")) {
return false;
+ }
int which = path.get_slicec('/', 1).to_int();
String what = path.get_slicec('/', 2);
ERR_FAIL_INDEX_V(which, bones.size(), false);
- if (what == "name")
+ if (what == "name") {
r_ret = get_bone_name(which);
- else if (what == "parent")
+ } else if (what == "parent") {
r_ret = get_bone_parent(which);
- else if (what == "rest")
+ } else if (what == "rest") {
r_ret = get_bone_rest(which);
- else if (what == "enabled")
+ } else if (what == "enabled") {
r_ret = is_bone_enabled(which);
- else if (what == "pose")
+ } else if (what == "pose") {
r_ret = get_bone_pose(which);
- else if (what == "bound_children") {
+ } else if (what == "bound_children") {
Array children;
for (const List<ObjectID>::Element *E = bones[which].nodes_bound.front(); E; E = E->next()) {
@@ -145,8 +147,9 @@ bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const {
}
r_ret = children;
- } else
+ } else {
return false;
+ }
return true;
}
@@ -164,8 +167,9 @@ void Skeleton3D::_get_property_list(List<PropertyInfo> *p_list) const {
}
void Skeleton3D::_update_process_order() {
- if (!process_order_dirty)
+ if (!process_order_dirty) {
return;
+ }
Bone *bonesptr = bones.ptrw();
int len = bones.size();
@@ -189,8 +193,9 @@ void Skeleton3D::_update_process_order() {
bool swapped = false;
for (int i = 0; i < len; i++) {
int parent_idx = bonesptr[order[i]].parent;
- if (parent_idx < 0)
+ if (parent_idx < 0) {
continue; //do nothing because it has no parent
+ }
//swap indices
int parent_order = bonesptr[parent_idx].sort_index;
if (parent_order > i) {
@@ -202,8 +207,9 @@ void Skeleton3D::_update_process_order() {
}
}
- if (!swapped)
+ if (!swapped) {
break;
+ }
pass_count++;
}
@@ -387,8 +393,9 @@ void Skeleton3D::set_bone_global_pose_override(int p_bone, const Transform &p_po
Transform Skeleton3D::get_bone_global_pose(int p_bone) const {
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
- if (dirty)
+ if (dirty) {
const_cast<Skeleton3D *>(this)->notification(NOTIFICATION_UPDATE_SKELETON);
+ }
return bones[p_bone].pose_global;
}
@@ -411,8 +418,9 @@ void Skeleton3D::add_bone(const String &p_name) {
int Skeleton3D::find_bone(const String &p_name) const {
for (int i = 0; i < bones.size(); i++) {
- if (bones[i].name == p_name)
+ if (bones[i].name == p_name) {
return i;
+ }
}
return -1;
@@ -427,11 +435,13 @@ String Skeleton3D::get_bone_name(int p_bone) const {
bool Skeleton3D::is_bone_parent_of(int p_bone, int p_parent_bone_id) const {
int parent_of_bone = get_bone_parent(p_bone);
- if (-1 == parent_of_bone)
+ if (-1 == parent_of_bone) {
return false;
+ }
- if (parent_of_bone == p_parent_bone_id)
+ if (parent_of_bone == p_parent_bone_id) {
return true;
+ }
return is_bone_parent_of(parent_of_bone, p_parent_bone_id);
}
@@ -514,8 +524,9 @@ void Skeleton3D::bind_child_node_to_bone(int p_bone, Node *p_node) {
ObjectID id = p_node->get_instance_id();
for (const List<ObjectID>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) {
- if (E->get() == id)
+ if (E->get() == id) {
return; // already here
+ }
}
bones.write[p_bone].nodes_bound.push_back(id);
@@ -578,8 +589,9 @@ Transform Skeleton3D::get_bone_custom_pose(int p_bone) const {
}
void Skeleton3D::_make_dirty() {
- if (dirty)
+ if (dirty) {
return;
+ }
MessageQueue::get_singleton()->push_notification(this, NOTIFICATION_UPDATE_SKELETON);
dirty = true;
@@ -679,8 +691,9 @@ void Skeleton3D::_rebuild_physical_bones_cache() {
PhysicalBone3D *parent_pb = _get_physical_bone_parent(i);
if (parent_pb != bones[i].physical_bone) {
bones.write[i].cache_parent_physical_bone = parent_pb;
- if (bones[i].physical_bone)
+ if (bones[i].physical_bone) {
bones[i].physical_bone->_on_bone_parent_changed();
+ }
}
}
}
@@ -730,8 +743,9 @@ void Skeleton3D::physical_bones_start_simulation_on(const TypedArray<StringName>
int c = 0;
for (int i = sim_bones.size() - 1; 0 <= i; --i) {
int bone_id = find_bone(p_bones[i]);
- if (bone_id != -1)
+ if (bone_id != -1) {
sim_bones.write[c++] = bone_id;
+ }
}
sim_bones.resize(c);
}
diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp
index 40c91fca69..9023f3c68a 100644
--- a/scene/3d/skeleton_ik_3d.cpp
+++ b/scene/3d/skeleton_ik_3d.cpp
@@ -113,8 +113,9 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain
}
}
- if (!middle_chain_item_id)
+ if (!middle_chain_item_id) {
chain.middle_chain_item = nullptr;
+ }
// Initialize current tip
chain.tips.write[x].chain_item = sub_chain;
@@ -132,8 +133,9 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain
}
void FabrikInverseKinematic::update_chain(const Skeleton3D *p_sk, ChainItem *p_chain_item) {
- if (!p_chain_item)
+ if (!p_chain_item) {
return;
+ }
p_chain_item->initial_transform = p_sk->get_bone_global_pose(p_chain_item->bone);
p_chain_item->current_pos = p_chain_item->initial_transform.origin;
@@ -246,8 +248,9 @@ FabrikInverseKinematic::Task *FabrikInverseKinematic::create_simple_task(Skeleto
}
void FabrikInverseKinematic::free_task(Task *p_task) {
- if (p_task)
+ if (p_task) {
memdelete(p_task);
+ }
}
void FabrikInverseKinematic::set_goal(Task *p_task, const Transform &p_goal) {
@@ -309,18 +312,20 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
}
} else {
// Set target orientation to tip
- if (override_tip_basis)
+ if (override_tip_basis) {
new_bone_pose.basis = p_task->chain.tips[0].end_effector->goal_transform.basis;
- else
+ } else {
new_bone_pose.basis = new_bone_pose.basis * p_task->chain.tips[0].end_effector->goal_transform.basis;
+ }
}
p_task->skeleton->set_bone_global_pose_override(ci->bone, new_bone_pose, 1.0, true);
- if (!ci->children.empty())
+ if (!ci->children.empty()) {
ci = &ci->children.write[0];
- else
+ } else {
ci = nullptr;
+ }
}
}
@@ -329,8 +334,9 @@ void SkeletonIK3D::_validate_property(PropertyInfo &property) const {
if (skeleton) {
String names("--,");
for (int i = 0; i < skeleton->get_bone_count(); i++) {
- if (i > 0)
+ if (i > 0) {
names += ",";
+ }
names += skeleton->get_bone_name(i);
}
@@ -400,8 +406,9 @@ void SkeletonIK3D::_notification(int p_what) {
reload_chain();
} break;
case NOTIFICATION_INTERNAL_PROCESS: {
- if (target_node_override)
+ if (target_node_override) {
reload_goal();
+ }
_solve_chain();
@@ -515,21 +522,24 @@ void SkeletonIK3D::stop() {
}
Transform SkeletonIK3D::_get_target_transform() {
- if (!target_node_override && !target_node_path_override.is_empty())
+ if (!target_node_override && !target_node_path_override.is_empty()) {
target_node_override = Object::cast_to<Node3D>(get_node(target_node_path_override));
+ }
- if (target_node_override)
+ if (target_node_override) {
return target_node_override->get_global_transform();
- else
+ } else {
return target;
+ }
}
void SkeletonIK3D::reload_chain() {
FabrikInverseKinematic::free_task(task);
task = nullptr;
- if (!skeleton)
+ if (!skeleton) {
return;
+ }
task = FabrikInverseKinematic::create_simple_task(skeleton, skeleton->find_bone(root_bone), skeleton->find_bone(tip_bone), _get_target_transform());
if (task) {
@@ -539,15 +549,17 @@ void SkeletonIK3D::reload_chain() {
}
void SkeletonIK3D::reload_goal() {
- if (!task)
+ if (!task) {
return;
+ }
FabrikInverseKinematic::set_goal(task, _get_target_transform());
}
void SkeletonIK3D::_solve_chain() {
- if (!task)
+ if (!task) {
return;
+ }
FabrikInverseKinematic::solve(task, interpolation, override_tip_basis, use_magnet, magnet_position);
}
diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp
index 47c568e9b4..a267c57f5e 100644
--- a/scene/3d/soft_body_3d.cpp
+++ b/scene/3d/soft_body_3d.cpp
@@ -115,8 +115,9 @@ SoftBody3D::PinnedPoint SoftBody3D::PinnedPoint::operator=(const PinnedPoint &ob
}
void SoftBody3D::_update_pickable() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
bool pickable = ray_pickable && is_visible_in_tree();
PhysicsServer3D::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable);
}
@@ -196,8 +197,9 @@ bool SoftBody3D::_set_property_pinned_points_indices(const Array &p_indices) {
for (int i = 0; i < p_indices_size; ++i) {
point_index = p_indices.get(i);
if (w[i].point_index != point_index) {
- if (-1 != w[i].point_index)
+ if (-1 != w[i].point_index) {
pin_point(w[i].point_index, false);
+ }
w[i].point_index = point_index;
pin_point(w[i].point_index, true);
}
@@ -265,8 +267,9 @@ void SoftBody3D::_notification(int p_what) {
prepare_physics_server();
} break;
case NOTIFICATION_READY: {
- if (!parent_collision_ignore.is_empty())
+ if (!parent_collision_ignore.is_empty()) {
add_collision_exception_with(get_node(parent_collision_ignore));
+ }
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -377,16 +380,18 @@ String SoftBody3D::get_configuration_warning() const {
String warning = MeshInstance3D::get_configuration_warning();
if (get_mesh().is_null()) {
- if (!warning.empty())
+ if (!warning.empty()) {
warning += "\n\n";
+ }
warning += TTR("This body will be ignored until you set a mesh.");
}
Transform t = get_transform();
if ((ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 || ABS(t.basis.get_axis(2).length() - 1.0) > 0.05)) {
- if (!warning.empty())
+ if (!warning.empty()) {
warning += "\n\n";
+ }
warning += TTR("Size changes to SoftBody3D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.");
}
@@ -395,8 +400,9 @@ String SoftBody3D::get_configuration_warning() const {
}
void SoftBody3D::_update_physics_server() {
- if (!simulation_started)
+ if (!simulation_started) {
return;
+ }
_update_cache_pin_points_datas();
// Submit bone attachment
@@ -410,8 +416,9 @@ void SoftBody3D::_update_physics_server() {
}
void SoftBody3D::_draw_soft_mesh() {
- if (get_mesh().is_null())
+ if (get_mesh().is_null()) {
return;
+ }
if (!rendering_server_handler.is_ready()) {
rendering_server_handler.prepare(get_mesh()->get_rid(), 0);
@@ -433,10 +440,11 @@ void SoftBody3D::_draw_soft_mesh() {
void SoftBody3D::prepare_physics_server() {
if (Engine::get_singleton()->is_editor_hint()) {
- if (get_mesh().is_valid())
+ if (get_mesh().is_valid()) {
PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh());
- else
+ } else {
PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, nullptr);
+ }
return;
}
@@ -454,8 +462,9 @@ void SoftBody3D::prepare_physics_server() {
}
void SoftBody3D::become_mesh_owner() {
- if (mesh.is_null())
+ if (mesh.is_null()) {
return;
+ }
if (!mesh_owner) {
mesh_owner = true;
@@ -507,10 +516,11 @@ uint32_t SoftBody3D::get_collision_layer() const {
void SoftBody3D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
- if (p_value)
+ if (p_value) {
mask |= 1 << p_bit;
- else
+ } else {
mask &= ~(1 << p_bit);
+ }
set_collision_mask(mask);
}
@@ -520,10 +530,11 @@ bool SoftBody3D::get_collision_mask_bit(int p_bit) const {
void SoftBody3D::set_collision_layer_bit(int p_bit, bool p_value) {
uint32_t layer = get_collision_layer();
- if (p_value)
+ if (p_value) {
layer |= 1 << p_bit;
- else
+ } else {
layer &= ~(1 << p_bit);
+ }
set_collision_layer(layer);
}
@@ -702,8 +713,9 @@ void SoftBody3D::_make_cache_dirty() {
}
void SoftBody3D::_update_cache_pin_points_datas() {
- if (!pinned_points_cache_dirty)
+ if (!pinned_points_cache_dirty) {
return;
+ }
pinned_points_cache_dirty = false;
@@ -749,17 +761,20 @@ void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_
}
void SoftBody3D::_reset_points_offsets() {
- if (!Engine::get_singleton()->is_editor_hint())
+ if (!Engine::get_singleton()->is_editor_hint()) {
return;
+ }
const PinnedPoint *r = pinned_points.ptr();
PinnedPoint *w = pinned_points.ptrw();
for (int i = pinned_points.size() - 1; 0 <= i; --i) {
- if (!r[i].spatial_attachment)
+ if (!r[i].spatial_attachment) {
w[i].spatial_attachment = Object::cast_to<Node3D>(get_node(r[i].spatial_attachment_path));
+ }
- if (!r[i].spatial_attachment)
+ if (!r[i].spatial_attachment) {
continue;
+ }
w[i].offset = (r[i].spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, r[i].point_index));
}
diff --git a/scene/3d/spring_arm_3d.cpp b/scene/3d/spring_arm_3d.cpp
index 3f94645bae..9775ecc6c6 100644
--- a/scene/3d/spring_arm_3d.cpp
+++ b/scene/3d/spring_arm_3d.cpp
@@ -83,8 +83,9 @@ float SpringArm3D::get_length() const {
}
void SpringArm3D::set_length(float p_length) {
- if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
+ if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_collisions_hint())) {
update_gizmo();
+ }
spring_length = p_length;
}
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index b6f71fcbf8..3b76cb6499 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -34,13 +34,15 @@
#include "scene/scene_string_names.h"
Color SpriteBase3D::_get_color_accum() {
- if (!color_dirty)
+ if (!color_dirty) {
return color_accum;
+ }
- if (parent_sprite)
+ if (parent_sprite) {
color_accum = parent_sprite->_get_color_accum();
- else
+ } else {
color_accum = Color(1, 1, 1, 1);
+ }
color_accum.r *= modulate.r;
color_accum.g *= modulate.g;
@@ -51,8 +53,9 @@ Color SpriteBase3D::_get_color_accum() {
}
void SpriteBase3D::_propagate_color_changed() {
- if (color_dirty)
+ if (color_dirty) {
return;
+ }
color_dirty = true;
_queue_update();
@@ -64,8 +67,9 @@ void SpriteBase3D::_propagate_color_changed() {
void SpriteBase3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (!pending_update)
+ if (!pending_update) {
_im_update();
+ }
parent_sprite = Object::cast_to<SpriteBase3D>(get_parent());
if (parent_sprite) {
@@ -163,8 +167,9 @@ void SpriteBase3D::_im_update() {
}
void SpriteBase3D::_queue_update() {
- if (pending_update)
+ if (pending_update) {
return;
+ }
triangle_mesh.unref();
update_gizmo();
@@ -182,8 +187,9 @@ Vector<Face3> SpriteBase3D::get_faces(uint32_t p_usage_flags) const {
}
Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
- if (triangle_mesh.is_valid())
+ if (triangle_mesh.is_valid()) {
return triangle_mesh;
+ }
Vector<Vector3> faces;
faces.resize(6);
@@ -191,8 +197,9 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
Rect2 final_rect = get_item_rect();
- if (final_rect.size.x == 0 || final_rect.size.y == 0)
+ if (final_rect.size.x == 0 || final_rect.size.y == 0) {
return Ref<TriangleMesh>();
+ }
float pixel_size = get_pixel_size();
@@ -340,8 +347,9 @@ SpriteBase3D::SpriteBase3D() {
parent_sprite = nullptr;
pI = nullptr;
- for (int i = 0; i < FLAG_MAX; i++)
+ for (int i = 0; i < FLAG_MAX; i++) {
flags[i] = i == FLAG_TRANSPARENT || i == FLAG_DOUBLE_SIDED;
+ }
alpha_cut = ALPHA_CUT_DISABLED;
billboard_mode = StandardMaterial3D::BILLBOARD_DISABLED;
@@ -364,35 +372,41 @@ void Sprite3D::_draw() {
RID immediate = get_immediate();
RS::get_singleton()->immediate_clear(immediate);
- if (!texture.is_valid())
+ if (!texture.is_valid()) {
return;
+ }
Vector2 tsize = texture->get_size();
- if (tsize.x == 0 || tsize.y == 0)
+ if (tsize.x == 0 || tsize.y == 0) {
return;
+ }
Rect2 base_rect;
- if (region)
+ if (region) {
base_rect = region_rect;
- else
+ } else {
base_rect = Rect2(0, 0, texture->get_width(), texture->get_height());
+ }
Size2 frame_size = base_rect.size / Size2(hframes, vframes);
Point2 frame_offset = Point2(frame % hframes, frame / hframes);
frame_offset *= frame_size;
Point2 dest_offset = get_offset();
- if (is_centered())
+ if (is_centered()) {
dest_offset -= frame_size / 2;
+ }
Rect2 src_rect(base_rect.position + frame_offset, frame_size);
Rect2 final_dst_rect(dest_offset, frame_size);
Rect2 final_rect;
Rect2 final_src_rect;
- if (!texture->get_rect_region(final_dst_rect, src_rect, final_rect, final_src_rect))
+ if (!texture->get_rect_region(final_dst_rect, src_rect, final_rect, final_src_rect)) {
return;
+ }
- if (final_rect.size.x == 0 || final_rect.size.y == 0)
+ if (final_rect.size.x == 0 || final_rect.size.y == 0) {
return;
+ }
Color color = _get_color_accum();
color.a *= get_opacity();
@@ -496,8 +510,9 @@ void Sprite3D::_texture_changed() {
}
void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) {
- if (p_texture == texture)
+ if (p_texture == texture) {
return;
+ }
if (texture.is_valid()) {
texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Sprite3D::_texture_changed));
}
@@ -513,8 +528,9 @@ Ref<Texture2D> Sprite3D::get_texture() const {
}
void Sprite3D::set_region(bool p_region) {
- if (p_region == region)
+ if (p_region == region) {
return;
+ }
region = p_region;
_queue_update();
@@ -586,8 +602,9 @@ int Sprite3D::get_hframes() const {
}
Rect2 Sprite3D::get_item_rect() const {
- if (texture.is_null())
+ if (texture.is_null()) {
return Rect2(0, 0, 1, 1);
+ }
/*
if (texture.is_null())
return CanvasItem::get_item_rect();
@@ -603,11 +620,13 @@ Rect2 Sprite3D::get_item_rect() const {
}
Point2 ofs = get_offset();
- if (is_centered())
+ if (is_centered()) {
ofs -= s / 2;
+ }
- if (s == Size2(0, 0))
+ if (s == Size2(0, 0)) {
s = Size2(1, 1);
+ }
return Rect2(ofs, s);
}
@@ -685,11 +704,13 @@ void AnimatedSprite3D::_draw() {
}
Ref<Texture2D> texture = frames->get_frame(animation, frame);
- if (!texture.is_valid())
+ if (!texture.is_valid()) {
return; //no texuture no life
+ }
Vector2 tsize = texture->get_size();
- if (tsize.x == 0 || tsize.y == 0)
+ if (tsize.x == 0 || tsize.y == 0) {
return;
+ }
Size2i s = tsize;
Rect2 src_rect;
@@ -697,18 +718,21 @@ void AnimatedSprite3D::_draw() {
src_rect.size = s;
Point2 ofs = get_offset();
- if (is_centered())
+ if (is_centered()) {
ofs -= s / 2;
+ }
Rect2 dst_rect(ofs, s);
Rect2 final_rect;
Rect2 final_src_rect;
- if (!texture->get_rect_region(dst_rect, src_rect, final_rect, final_src_rect))
+ if (!texture->get_rect_region(dst_rect, src_rect, final_rect, final_src_rect)) {
return;
+ }
- if (final_rect.size.x == 0 || final_rect.size.y == 0)
+ if (final_rect.size.x == 0 || final_rect.size.y == 0) {
return;
+ }
Color color = _get_color_accum();
color.a *= get_opacity();
@@ -812,8 +836,9 @@ void AnimatedSprite3D::_draw() {
}
void AnimatedSprite3D::_validate_property(PropertyInfo &property) const {
- if (!frames.is_valid())
+ if (!frames.is_valid()) {
return;
+ }
if (property.name == "animation") {
property.hint = PROPERTY_HINT_ENUM;
List<StringName> names;
@@ -854,16 +879,20 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &property) const {
void AnimatedSprite3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_INTERNAL_PROCESS: {
- if (frames.is_null())
+ if (frames.is_null()) {
return;
- if (!frames->has_animation(animation))
+ }
+ if (!frames->has_animation(animation)) {
return;
- if (frame < 0)
+ }
+ if (frame < 0) {
return;
+ }
float speed = frames->get_animation_speed(animation);
- if (speed == 0)
+ if (speed == 0) {
return; //do nothing
+ }
float remaining = get_process_delta_time();
@@ -895,11 +924,13 @@ void AnimatedSprite3D::_notification(int p_what) {
}
void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
- if (frames.is_valid())
+ if (frames.is_valid()) {
frames->disconnect("changed", callable_mp(this, &AnimatedSprite3D::_res_changed));
+ }
frames = p_frames;
- if (frames.is_valid())
+ if (frames.is_valid()) {
frames->connect("changed", callable_mp(this, &AnimatedSprite3D::_res_changed));
+ }
if (!frames.is_valid()) {
frame = 0;
@@ -924,15 +955,18 @@ void AnimatedSprite3D::set_frame(int p_frame) {
if (frames->has_animation(animation)) {
int limit = frames->get_frame_count(animation);
- if (p_frame >= limit)
+ if (p_frame >= limit) {
p_frame = limit - 1;
+ }
}
- if (p_frame < 0)
+ if (p_frame < 0) {
p_frame = 0;
+ }
- if (frame == p_frame)
+ if (frame == p_frame) {
return;
+ }
frame = p_frame;
_reset_timeout();
@@ -951,18 +985,22 @@ Rect2 AnimatedSprite3D::get_item_rect() const {
}
Ref<Texture2D> t;
- if (animation)
+ if (animation) {
t = frames->get_frame(animation, frame);
- if (t.is_null())
+ }
+ if (t.is_null()) {
return Rect2(0, 0, 1, 1);
+ }
Size2i s = t->get_size();
Point2 ofs = get_offset();
- if (centered)
+ if (centered) {
ofs -= s / 2;
+ }
- if (s == Size2(0, 0))
+ if (s == Size2(0, 0)) {
s = Size2(1, 1);
+ }
return Rect2(ofs, s);
}
@@ -975,8 +1013,9 @@ void AnimatedSprite3D::_res_changed() {
}
void AnimatedSprite3D::_set_playing(bool p_playing) {
- if (playing == p_playing)
+ if (playing == p_playing) {
return;
+ }
playing = p_playing;
_reset_timeout();
set_process_internal(playing);
@@ -987,8 +1026,9 @@ bool AnimatedSprite3D::_is_playing() const {
}
void AnimatedSprite3D::play(const StringName &p_animation) {
- if (p_animation)
+ if (p_animation) {
set_animation(p_animation);
+ }
_set_playing(true);
}
@@ -1001,8 +1041,9 @@ bool AnimatedSprite3D::is_playing() const {
}
void AnimatedSprite3D::_reset_timeout() {
- if (!playing)
+ if (!playing) {
return;
+ }
if (frames.is_valid() && frames->has_animation(animation)) {
float speed = frames->get_animation_speed(animation);
@@ -1017,8 +1058,9 @@ void AnimatedSprite3D::_reset_timeout() {
}
void AnimatedSprite3D::set_animation(const StringName &p_animation) {
- if (animation == p_animation)
+ if (animation == p_animation) {
return;
+ }
animation = p_animation;
_reset_timeout();
diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp
index 1e70b30d66..9c6b940b00 100644
--- a/scene/3d/vehicle_body_3d.cpp
+++ b/scene/3d/vehicle_body_3d.cpp
@@ -81,8 +81,9 @@ public:
void VehicleWheel3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
VehicleBody3D *cb = Object::cast_to<VehicleBody3D>(get_parent());
- if (!cb)
+ if (!cb) {
return;
+ }
body = cb;
local_xform = get_transform();
cb->wheels.push_back(this);
@@ -93,8 +94,9 @@ void VehicleWheel3D::_notification(int p_what) {
}
if (p_what == NOTIFICATION_EXIT_TREE) {
VehicleBody3D *cb = Object::cast_to<VehicleBody3D>(get_parent());
- if (!cb)
+ if (!cb) {
return;
+ }
cb->wheels.erase(this);
body = nullptr;
}
@@ -434,8 +436,9 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) {
wheel.m_raycastInfo.m_contactNormalWS = rr.normal;
wheel.m_raycastInfo.m_isInContact = true;
- if (rr.collider)
+ if (rr.collider) {
wheel.m_raycastInfo.m_groundObject = Object::cast_to<PhysicsBody3D>(rr.collider);
+ }
real_t hitDistance = param * raylen;
wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelRadius;
@@ -541,15 +544,17 @@ void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState3D *s, const
Vector3 rel_pos1 = pos1 - s->get_transform().origin;
Vector3 rel_pos2;
- if (body2)
+ if (body2) {
rel_pos2 = pos2 - body2->get_global_transform().origin;
+ }
//this jacobian entry could be re-used for all iterations
Vector3 vel1 = s->get_linear_velocity() + (s->get_angular_velocity()).cross(rel_pos1); // * mPos);
Vector3 vel2;
- if (body2)
+ if (body2) {
vel2 = body2->get_linear_velocity() + body2->get_angular_velocity().cross(rel_pos2);
+ }
Vector3 vel = vel1 - vel2;
@@ -644,8 +649,9 @@ real_t VehicleBody3D::_calc_rolling_friction(btVehicleWheelContactPoint &contact
Vector3 rel_pos1 = contactPosWorld - contactPoint.m_s->get_transform().origin;
Vector3 rel_pos2;
- if (contactPoint.m_body1)
+ if (contactPoint.m_body1) {
rel_pos2 = contactPosWorld - contactPoint.m_body1->get_global_transform().origin;
+ }
real_t maxImpulse = contactPoint.m_maxImpulse;
@@ -670,8 +676,9 @@ static const real_t sideFrictionStiffness2 = real_t(1.0);
void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) {
//calculate the impulse, so that the wheels don't move sidewards
int numWheel = wheels.size();
- if (!numWheel)
+ if (!numWheel) {
return;
+ }
m_forwardWS.resize(numWheel);
m_axle.resize(numWheel);
@@ -885,8 +892,9 @@ void VehicleBody3D::set_engine_force(float p_engine_force) {
engine_force = p_engine_force;
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel3D &wheelInfo = *wheels[i];
- if (wheelInfo.engine_traction)
+ if (wheelInfo.engine_traction) {
wheelInfo.m_engineForce = p_engine_force;
+ }
}
}
@@ -910,8 +918,9 @@ void VehicleBody3D::set_steering(float p_steering) {
m_steeringValue = p_steering;
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel3D &wheelInfo = *wheels[i];
- if (wheelInfo.steers)
+ if (wheelInfo.steers) {
wheelInfo.m_steering = p_steering;
+ }
}
}
diff --git a/scene/3d/velocity_tracker_3d.cpp b/scene/3d/velocity_tracker_3d.cpp
index 216330939a..db10f3273b 100644
--- a/scene/3d/velocity_tracker_3d.cpp
+++ b/scene/3d/velocity_tracker_3d.cpp
@@ -88,8 +88,9 @@ Vector3 VelocityTracker3D::get_tracked_linear_velocity() const {
delta = double(diff) / 1000000.0;
}
- if (base_time + time_accum + delta > max_time)
+ if (base_time + time_accum + delta > max_time) {
break;
+ }
distance_accum += distance;
time_accum += delta;
diff --git a/scene/3d/visibility_notifier_3d.cpp b/scene/3d/visibility_notifier_3d.cpp
index afc7293b13..a64b0df1cc 100644
--- a/scene/3d/visibility_notifier_3d.cpp
+++ b/scene/3d/visibility_notifier_3d.cpp
@@ -60,8 +60,9 @@ void VisibilityNotifier3D::_exit_camera(Camera3D *p_camera) {
}
void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) {
- if (aabb == p_aabb)
+ if (aabb == p_aabb) {
return;
+ }
aabb = p_aabb;
if (is_inside_world()) {
@@ -157,8 +158,9 @@ void VisibilityEnabler3D::_find_nodes(Node *p_node) {
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
- if (c->get_filename() != String())
+ if (c->get_filename() != String()) {
continue; //skip, instance
+ }
_find_nodes(c);
}
@@ -166,24 +168,28 @@ void VisibilityEnabler3D::_find_nodes(Node *p_node) {
void VisibilityEnabler3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
Node *from = this;
//find where current scene starts
- while (from->get_parent() && from->get_filename() == String())
+ while (from->get_parent() && from->get_filename() == String()) {
from = from->get_parent();
+ }
_find_nodes(from);
}
if (p_what == NOTIFICATION_EXIT_TREE) {
- if (Engine::get_singleton()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint()) {
return;
+ }
for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
- if (!visible)
+ if (!visible) {
_change_node_state(E->key(), true);
+ }
E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler3D::_node_removed));
}
@@ -196,9 +202,9 @@ void VisibilityEnabler3D::_change_node_state(Node *p_node, bool p_enabled) {
if (enabler[ENABLER_FREEZE_BODIES]) {
RigidBody3D *rb = Object::cast_to<RigidBody3D>(p_node);
- if (rb)
-
+ if (rb) {
rb->set_sleeping(!p_enabled);
+ }
}
if (enabler[ENABLER_PAUSE_ANIMATIONS]) {
@@ -211,8 +217,9 @@ void VisibilityEnabler3D::_change_node_state(Node *p_node, bool p_enabled) {
}
void VisibilityEnabler3D::_node_removed(Node *p_node) {
- if (!visible)
+ if (!visible) {
_change_node_state(p_node, true);
+ }
nodes.erase(p_node);
}
@@ -239,8 +246,9 @@ bool VisibilityEnabler3D::is_enabler_enabled(Enabler p_enabler) const {
}
VisibilityEnabler3D::VisibilityEnabler3D() {
- for (int i = 0; i < ENABLER_MAX; i++)
+ for (int i = 0; i < ENABLER_MAX; i++) {
enabler[i] = true;
+ }
visible = false;
}
diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp
index cf67ba71c9..a1c498e8ab 100644
--- a/scene/3d/visual_instance_3d.cpp
+++ b/scene/3d/visual_instance_3d.cpp
@@ -39,8 +39,9 @@ AABB VisualInstance3D::get_transformed_aabb() const {
}
void VisualInstance3D::_update_visibility() {
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return;
+ }
_change_notify("visible");
RS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree());
diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp
index 886ec89c28..9fc3feb49a 100644
--- a/scene/3d/voxelizer.cpp
+++ b/scene/3d/voxelizer.cpp
@@ -151,8 +151,9 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
Vector2 uv;
Vector3 lnormal;
get_uv_and_normal(intersection, p_vtx, p_uv, p_normal, uv, lnormal);
- if (lnormal == Vector3()) //just in case normal as nor provided
+ if (lnormal == Vector3()) { //just in case normal as nor provided
lnormal = normal;
+ }
int uv_x = CLAMP(int(Math::fposmod(uv.x, 1.0f) * bake_texture_size), 0, bake_texture_size - 1);
int uv_y = CLAMP(int(Math::fposmod(uv.y, 1.0f) * bake_texture_size), 0, bake_texture_size - 1);
@@ -182,8 +183,9 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
Vector3 lnormal;
Vector2 uv;
get_uv_and_normal(inters, p_vtx, p_uv, p_normal, uv, normal);
- if (lnormal == Vector3()) //just in case normal as nor provided
+ if (lnormal == Vector3()) { //just in case normal as nor provided
lnormal = normal;
+ }
int uv_x = CLAMP(Math::fposmod(uv.x, 1.0f) * bake_texture_size, 0, bake_texture_size - 1);
int uv_y = CLAMP(Math::fposmod(uv.y, 1.0f) * bake_texture_size, 0, bake_texture_size - 1);
@@ -256,8 +258,9 @@ void Voxelizer::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, co
nz += half;
}
//make sure to not plot beyond limits
- if (nx < 0 || nx >= axis_cell_size[0] || ny < 0 || ny >= axis_cell_size[1] || nz < 0 || nz >= axis_cell_size[2])
+ if (nx < 0 || nx >= axis_cell_size[0] || ny < 0 || ny >= axis_cell_size[1] || nz < 0 || nz >= axis_cell_size[2]) {
continue;
+ }
{
AABB test_aabb = aabb;
@@ -377,8 +380,9 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref<Material> p_material
void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vector<Ref<Material>> &p_materials, const Ref<Material> &p_override_material) {
for (int i = 0; i < p_mesh->get_surface_count(); i++) {
- if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
+ if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) {
continue; //only triangles
+ }
Ref<Material> src_material;
@@ -435,8 +439,9 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vec
}
//test against original bounds
- if (!Geometry::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs))
+ if (!Geometry::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs)) {
continue;
+ }
//plot
_plot_face(0, 0, 0, 0, 0, vtxs, normal, uvs, material, po2_bounds);
}
@@ -466,8 +471,9 @@ void Voxelizer::plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, const Vec
}
//test against original bounds
- if (!Geometry::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs))
+ if (!Geometry::triangle_box_overlap(original_bounds.position + original_bounds.size * 0.5, original_bounds.size * 0.5, vtxs)) {
continue;
+ }
//plot face
_plot_face(0, 0, 0, 0, 0, vtxs, normal, uvs, material, po2_bounds);
}
@@ -597,8 +603,9 @@ void Voxelizer::_fixup_plot(int p_idx, int p_level) {
for (int i = 0; i < 8; i++) {
uint32_t child = bake_cells[p_idx].children[i];
- if (child == CHILD_EMPTY)
+ if (child == CHILD_EMPTY) {
continue;
+ }
_fixup_plot(child, p_level + 1);
alpha_average += bake_cells[child].alpha;
@@ -625,8 +632,9 @@ void Voxelizer::begin_bake(int p_subdiv, const AABB &p_bounds) {
leaf_voxel_count = 0;
for (int i = 0; i < 3; i++) {
- if (i == longest_axis)
+ if (i == longest_axis) {
continue;
+ }
axis_cell_size[i] = axis_cell_size[longest_axis];
float axis_size = po2_bounds.size[longest_axis];
@@ -798,8 +806,9 @@ static void edt(float *f, int stride, int n) {
k = 0;
for (int q = 0; q <= n - 1; q++) {
- while (z[k + 1] < q)
+ while (z[k + 1] < q) {
k++;
+ }
d[q] = square(q - v[k]) + f[v[k] * stride];
}
@@ -898,18 +907,22 @@ void Voxelizer::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<Mult
for (int i = 0; i < 8; i++) {
uint32_t child = bake_cells[p_idx].children[i];
- if (child == CHILD_EMPTY || child >= (uint32_t)max_original_cells)
+ if (child == CHILD_EMPTY || child >= (uint32_t)max_original_cells) {
continue;
+ }
AABB aabb = p_aabb;
aabb.size *= 0.5;
- if (i & 1)
+ if (i & 1) {
aabb.position.x += aabb.size.x;
- if (i & 2)
+ }
+ if (i & 2) {
aabb.position.y += aabb.size.y;
- if (i & 4)
+ }
+ if (i & 4) {
aabb.position.z += aabb.size.z;
+ }
_debug_mesh(bake_cells[p_idx].children[i], p_level + 1, aabb, p_multimesh, idx);
}
@@ -948,10 +961,11 @@ Ref<MultiMesh> Voxelizer::create_debug_multimesh() {
v[2] = v[1] * (1 - 2 * (j & 1));
for (int k = 0; k < 3; k++) {
- if (i < 3)
+ if (i < 3) {
face_points[j][(i + k) % 3] = v[k];
- else
+ } else {
face_points[3 - j][(i + k) % 3] = -v[k];
+ }
}
}
diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp
index ac314e005b..24071f31f3 100644
--- a/scene/3d/world_environment.cpp
+++ b/scene/3d/world_environment.cpp
@@ -113,8 +113,9 @@ String WorldEnvironment::get_configuration_warning() const {
return TTR("WorldEnvironment requires its \"Environment\" property to contain an Environment to have a visible effect.");
}
- if (!is_inside_tree())
+ if (!is_inside_tree()) {
return String();
+ }
List<Node *> nodes;
get_tree()->get_nodes_in_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id()), &nodes);
diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp
index 1d01a8b5b4..f9f6b6905c 100644
--- a/scene/3d/xr_nodes.cpp
+++ b/scene/3d/xr_nodes.cpp
@@ -55,8 +55,9 @@ void XRCamera3D::_notification(int p_what) {
};
String XRCamera3D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible() || !is_inside_tree()) {
return String();
+ }
// must be child node of XROrigin3D!
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
@@ -364,8 +365,9 @@ XRPositionalTracker::TrackerHand XRController3D::get_hand() const {
};
String XRController3D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible() || !is_inside_tree()) {
return String();
+ }
// must be child node of XROrigin!
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
@@ -490,8 +492,9 @@ bool XRAnchor3D::get_is_active() const {
};
String XRAnchor3D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible() || !is_inside_tree()) {
return String();
+ }
// must be child node of XROrigin3D!
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
@@ -531,11 +534,13 @@ XRAnchor3D::~XRAnchor3D(){
////////////////////////////////////////////////////////////////////////////////////////////////////
String XROrigin3D::get_configuration_warning() const {
- if (!is_visible() || !is_inside_tree())
+ if (!is_visible() || !is_inside_tree()) {
return String();
+ }
- if (tracked_camera == nullptr)
+ if (tracked_camera == nullptr) {
return TTR("XROrigin3D requires an XRCamera3D child node.");
+ }
return String();
};