1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Apply infinite inertia checks to Godot physics 3D

This commit is contained in:
Marcel Admiraal
2020-10-08 08:43:34 +01:00
parent caaac22240
commit 01dd6b0593

View File

@@ -783,6 +783,13 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
const CollisionObjectSW *col_obj = intersection_query_results[i]; const CollisionObjectSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i]; int shape_idx = intersection_query_subindex_results[i];
if (CollisionObjectSW::TYPE_BODY == col_obj->get_type()) {
const BodySW *b = static_cast<const BodySW *>(col_obj);
if (p_infinite_inertia && PhysicsServer::BODY_MODE_STATIC != b->get_mode() && PhysicsServer::BODY_MODE_KINEMATIC != b->get_mode()) {
continue;
}
}
if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, nullptr, p_margin)) { if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, nullptr, p_margin)) {
collided = cbk.amount > 0; collided = cbk.amount > 0;
} }
@@ -865,6 +872,13 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
const CollisionObjectSW *col_obj = intersection_query_results[i]; const CollisionObjectSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i]; int shape_idx = intersection_query_subindex_results[i];
if (CollisionObjectSW::TYPE_BODY == col_obj->get_type()) {
const BodySW *b = static_cast<const BodySW *>(col_obj);
if (p_infinite_inertia && PhysicsServer::BODY_MODE_STATIC != b->get_mode() && PhysicsServer::BODY_MODE_KINEMATIC != b->get_mode()) {
continue;
}
}
//test initial overlap, does it collide if going all the way? //test initial overlap, does it collide if going all the way?
Vector3 point_A, point_B; Vector3 point_A, point_B;
Vector3 sep_axis = motion_normal; Vector3 sep_axis = motion_normal;
@@ -971,6 +985,13 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
const CollisionObjectSW *col_obj = intersection_query_results[i]; const CollisionObjectSW *col_obj = intersection_query_results[i];
int shape_idx = intersection_query_subindex_results[i]; int shape_idx = intersection_query_subindex_results[i];
if (CollisionObjectSW::TYPE_BODY == col_obj->get_type()) {
const BodySW *b = static_cast<const BodySW *>(col_obj);
if (p_infinite_inertia && PhysicsServer::BODY_MODE_STATIC != b->get_mode() && PhysicsServer::BODY_MODE_KINEMATIC != b->get_mode()) {
continue;
}
}
rcd.object = col_obj; rcd.object = col_obj;
rcd.shape = shape_idx; rcd.shape = shape_idx;
rcd.local_shape = j; rcd.local_shape = j;