Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GodotCollisionSolver2D::solve_concave: Fix culling in case of motion #88282

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions servers/physics_2d/godot_collision_solver_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ bool GodotCollisionSolver2D::solve_concave(const GodotShape2D *p_shape_A, const
Transform2D rel_transform = p_transform_A;
rel_transform.columns[2] -= p_transform_B.get_origin();

//quickly compute a local Rect2

// Quickly compute a local Rect2.
Rect2 local_aabb;
for (int i = 0; i < 2; i++) {
Vector2 axis(p_transform_B.columns[i]);
Expand All @@ -205,6 +204,12 @@ bool GodotCollisionSolver2D::solve_concave(const GodotShape2D *p_shape_A, const
local_aabb.position[i] = 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);

Expand Down
Loading