Use approximate equallity methods in many places
This commit is contained in:
parent
c577ec6ae4
commit
b659e1eb2b
21 changed files with 66 additions and 66 deletions
|
|
@ -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()))
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue