summaryrefslogtreecommitdiff
path: root/servers/physics_2d
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-07-20 12:00:13 +0200
committerGitHub <noreply@github.com>2019-07-20 12:00:13 +0200
commitd15cf7b672ac9911b4e82fed52b4c5e8d4312b0d (patch)
tree68ab08fafd7e14710ce245a47f3bb518ebf03307 /servers/physics_2d
parent700938bff772924941c4e1ea61bbfd2abe34d8d2 (diff)
parent6cbaf7662f5ee3ca1d02c0ebc85854fceee057af (diff)
Merge pull request #30576 from qarmin/lgtm_coverage
Changed some code reported by LGTM and Coverity
Diffstat (limited to 'servers/physics_2d')
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp
index f4bff66389..9d75f71ff0 100644
--- a/servers/physics_2d/collision_solver_2d_sat.cpp
+++ b/servers/physics_2d/collision_solver_2d_sat.cpp
@@ -313,10 +313,12 @@ public:
if (best_axis == Vector2(0.0, 0.0))
return;
- callback->collided = true;
+ if (callback) {
+ callback->collided = true;
- if (!callback->callback)
- return; //only collide, no callback
+ if (!callback->callback)
+ return; //only collide, no callback
+ }
static const int max_supports = 2;
Vector2 supports_A[max_supports];
@@ -354,12 +356,13 @@ public:
supports_B[i] += best_axis * margin_B;
}
}
+ if (callback) {
+ callback->normal = best_axis;
+ _generate_contacts_from_supports(supports_A, support_count_A, supports_B, support_count_B, callback);
- callback->normal = best_axis;
- _generate_contacts_from_supports(supports_A, support_count_A, supports_B, support_count_B, callback);
-
- if (callback && callback->sep_axis && *callback->sep_axis != Vector2())
- *callback->sep_axis = Vector2(); //invalidate previous axis (no test)
+ if (callback->sep_axis && *callback->sep_axis != Vector2())
+ *callback->sep_axis = Vector2(); //invalidate previous axis (no test)
+ }
}
_FORCE_INLINE_ SeparatorAxisTest2D(const ShapeA *p_shape_A, const Transform2D &p_transform_a, const ShapeB *p_shape_B, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_A = Vector2(), const Vector2 &p_motion_B = Vector2(), real_t p_margin_A = 0, real_t p_margin_B = 0) {