GodotCollisionSolver2D::solve_concave: fix culling in case of motion
This commit is contained in:
parent
4e990cd7e5
commit
87446fd9b3
|
@ -189,8 +189,7 @@ bool GodotCollisionSolver2D::solve_concave(const GodotShape2D *p_shape_A, const
|
||||||
Transform2D rel_transform = p_transform_A;
|
Transform2D rel_transform = p_transform_A;
|
||||||
rel_transform.columns[2] -= p_transform_B.get_origin();
|
rel_transform.columns[2] -= p_transform_B.get_origin();
|
||||||
|
|
||||||
//quickly compute a local Rect2
|
// Quickly compute a local Rect2.
|
||||||
|
|
||||||
Rect2 local_aabb;
|
Rect2 local_aabb;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
Vector2 axis(p_transform_B.columns[i]);
|
Vector2 axis(p_transform_B.columns[i]);
|
||||||
|
@ -205,6 +204,12 @@ bool GodotCollisionSolver2D::solve_concave(const GodotShape2D *p_shape_A, const
|
||||||
local_aabb.position[i] = smin;
|
local_aabb.position[i] = smin;
|
||||||
local_aabb.size[i] = smax - smin;
|
local_aabb.size[i] = smax - smin;
|
||||||
}
|
}
|
||||||
|
// In case of motion, expand the Rect2 in the motion direction.
|
||||||
|
if (p_motion_A != Vector2()) {
|
||||||
|
Rect2 moved_aabb = local_aabb;
|
||||||
|
moved_aabb.position += p_motion_A;
|
||||||
|
local_aabb = local_aabb.merge(moved_aabb);
|
||||||
|
}
|
||||||
|
|
||||||
concave_B->cull(local_aabb, concave_callback, &cinfo);
|
concave_B->cull(local_aabb, concave_callback, &cinfo);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue