diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/physics/collision_solver_sat.cpp | 6 | ||||
-rw-r--r-- | servers/physics/joints/cone_twist_joint_sw.cpp | 6 | ||||
-rw-r--r-- | servers/physics/joints/generic_6dof_joint_sw.cpp | 2 | ||||
-rw-r--r-- | servers/physics/joints/hinge_joint_sw.cpp | 6 | ||||
-rw-r--r-- | servers/physics_2d/collision_solver_2d_sat.cpp | 4 | ||||
-rw-r--r-- | servers/visual/visual_server_canvas.h | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_scene.cpp | 4 |
7 files changed, 15 insertions, 15 deletions
diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp index baf7431e28..3073cc8b11 100644 --- a/servers/physics/collision_solver_sat.cpp +++ b/servers/physics/collision_solver_sat.cpp @@ -98,7 +98,7 @@ static void _generate_contacts_edge_edge(const Vector3 *p_points_A, int p_point_ Vector3 c = rel_A.cross(rel_B).cross(rel_B); - if (Math::abs(rel_A.dot(c)) < CMP_EPSILON) { + if (Math::is_zero_approx(rel_A.dot(c))) { // should handle somehow.. //ERR_PRINT("TODO FIX"); @@ -678,7 +678,7 @@ static void _collision_box_box(const ShapeSW *p_a, const Transform &p_transform_ Vector3 axis = p_transform_a.basis.get_axis(i).cross(p_transform_b.basis.get_axis(j)); - if (axis.length_squared() < CMP_EPSILON) + if (Math::is_zero_approx(axis.length_squared())) continue; axis.normalize(); @@ -767,7 +767,7 @@ static void _collision_box_capsule(const ShapeSW *p_a, const Transform &p_transf // cylinder Vector3 box_axis = p_transform_a.basis.get_axis(i); Vector3 axis = box_axis.cross(cyl_axis); - if (axis.length_squared() < CMP_EPSILON) + if (Math::is_zero_approx(axis.length_squared())) continue; if (!separator.test_axis(axis.normalized())) diff --git a/servers/physics/joints/cone_twist_joint_sw.cpp b/servers/physics/joints/cone_twist_joint_sw.cpp index 268b9eefeb..1b3de3e913 100644 --- a/servers/physics/joints/cone_twist_joint_sw.cpp +++ b/servers/physics/joints/cone_twist_joint_sw.cpp @@ -127,10 +127,10 @@ bool ConeTwistJointSW::setup(real_t p_timestep) { Vector3 relPos = pivotBInW - pivotAInW; Vector3 normal[3]; - if (relPos.length_squared() > CMP_EPSILON) { - normal[0] = relPos.normalized(); - } else { + if (Math::is_zero_approx(relPos.length_squared())) { normal[0] = Vector3(real_t(1.0), 0, 0); + } else { + normal[0] = relPos.normalized(); } plane_space(normal[0], normal[1], normal[2]); diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp index 756348f448..813d9b7704 100644 --- a/servers/physics/joints/generic_6dof_joint_sw.cpp +++ b/servers/physics/joints/generic_6dof_joint_sw.cpp @@ -107,7 +107,7 @@ real_t G6DOFRotationalLimitMotorSW::solveAngularLimits( // correction velocity real_t motor_relvel = m_limitSoftness * (target_velocity - m_damping * rel_vel); - if (motor_relvel < CMP_EPSILON && motor_relvel > -CMP_EPSILON) { + if (Math::is_zero_approx(motor_relvel)) { return 0.0f; //no need for applying force } diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics/joints/hinge_joint_sw.cpp index e972496b2b..1d1b30286e 100644 --- a/servers/physics/joints/hinge_joint_sw.cpp +++ b/servers/physics/joints/hinge_joint_sw.cpp @@ -167,10 +167,10 @@ bool HingeJointSW::setup(real_t p_step) { Vector3 relPos = pivotBInW - pivotAInW; Vector3 normal[3]; - if (relPos.length_squared() > CMP_EPSILON) { - normal[0] = relPos.normalized(); - } else { + if (Math::is_zero_approx(relPos.length_squared())) { normal[0] = Vector3(real_t(1.0), 0, 0); + } else { + normal[0] = relPos.normalized(); } plane_space(normal[0], normal[1], normal[2]); diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp index d6c3fff421..f4bff66389 100644 --- a/servers/physics_2d/collision_solver_2d_sat.cpp +++ b/servers/physics_2d/collision_solver_2d_sat.cpp @@ -237,8 +237,8 @@ public: Vector2 axis = p_axis; - if (Math::abs(axis.x) < CMP_EPSILON && - Math::abs(axis.y) < CMP_EPSILON) { + if (Math::is_zero_approx(axis.x) && + Math::is_zero_approx(axis.y)) { // strange case, try an upwards separator axis = Vector2(0.0, 1.0); } diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index 4e99bb3676..26424f927e 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -82,7 +82,7 @@ public: _FORCE_INLINE_ bool operator()(const Item *p_left, const Item *p_right) const { - if (Math::abs(p_left->ysort_pos.y - p_right->ysort_pos.y) < CMP_EPSILON) + if (Math::is_equal_approx(p_left->ysort_pos.y, p_right->ysort_pos.y)) return p_left->ysort_pos.x < p_right->ysort_pos.x; else return p_left->ysort_pos.y < p_right->ysort_pos.y; diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index c1dc94daa2..af580d6794 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -2654,7 +2654,7 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, co for (int i = 0; i < 3; i++) { - if (ABS(light_axis[i]) < CMP_EPSILON) + if (Math::is_zero_approx(light_axis[i])) continue; clip[clip_planes].normal[i] = 1.0; @@ -2789,7 +2789,7 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, co for (int c = 0; c < 3; c++) { - if (ABS(light_axis[c]) < CMP_EPSILON) + if (Math::is_zero_approx(light_axis[c])) continue; clip[clip_planes].normal[c] = 1.0; |