diff options
Diffstat (limited to 'servers/physics_server_3d.cpp')
-rw-r--r-- | servers/physics_server_3d.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp index c8f5ae985e..2dd8ea3edb 100644 --- a/servers/physics_server_3d.cpp +++ b/servers/physics_server_3d.cpp @@ -45,13 +45,15 @@ void PhysicsDirectBodyState3D::integrate_forces() { float linear_damp = 1.0 - step * get_total_linear_damp(); - if (linear_damp < 0) // reached zero in the given time + if (linear_damp < 0) { // reached zero in the given time linear_damp = 0; + } float angular_damp = 1.0 - step * get_total_angular_damp(); - if (angular_damp < 0) // reached zero in the given time + if (angular_damp < 0) { // reached zero in the given time angular_damp = 0; + } lv *= linear_damp; av *= angular_damp; @@ -173,8 +175,9 @@ int PhysicsShapeQueryParameters3D::get_collision_mask() const { void PhysicsShapeQueryParameters3D::set_exclude(const Vector<RID> &p_exclude) { exclude.clear(); - for (int i = 0; i < p_exclude.size(); i++) + for (int i = 0; i < p_exclude.size(); i++) { exclude.insert(p_exclude[i]); + } } Vector<RID> PhysicsShapeQueryParameters3D::get_exclude() const { @@ -248,13 +251,15 @@ PhysicsShapeQueryParameters3D::PhysicsShapeQueryParameters3D() { Dictionary PhysicsDirectSpaceState3D::_intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { RayResult inters; Set<RID> exclude; - for (int i = 0; i < p_exclude.size(); i++) + for (int i = 0; i < p_exclude.size(); i++) { exclude.insert(p_exclude[i]); + } bool res = intersect_ray(p_from, p_to, inters, exclude, p_collision_mask, p_collide_with_bodies, p_collide_with_areas); - if (!res) + if (!res) { return Dictionary(); + } Dictionary d; d["position"] = inters.position; @@ -292,8 +297,9 @@ Array PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParamet float closest_safe, closest_unsafe; bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); - if (!res) + if (!res) { return Array(); + } Array ret; ret.resize(2); ret[0] = closest_safe; @@ -308,12 +314,14 @@ Array PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParam ret.resize(p_max_results * 2); int rc = 0; bool res = collide_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, ret.ptrw(), p_max_results, rc, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); - if (!res) + if (!res) { return Array(); + } Array r; r.resize(rc * 2); - for (int i = 0; i < rc * 2; i++) + for (int i = 0; i < rc * 2; i++) { r[i] = ret[i]; + } return r; } @@ -324,8 +332,9 @@ Dictionary PhysicsDirectSpaceState3D::_get_rest_info(const Ref<PhysicsShapeQuery bool res = rest_info(p_shape_query->shape, p_shape_query->transform, p_shape_query->margin, &sri, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); Dictionary r; - if (!res) + if (!res) { return r; + } r["point"] = sri.point; r["normal"] = sri.normal; |