Skip to content

Add kinematic collide-and-slide helper. - #6546

Closed
rhailrake wants to merge 1 commit into
space-wizards:masterfrom
rhailrake:ray_kinematica
Closed

Add kinematic collide-and-slide helper.#6546
rhailrake wants to merge 1 commit into
space-wizards:masterfrom
rhailrake:ray_kinematica

Conversation

@rhailrake

Copy link
Copy Markdown
Contributor

Adds a small CollideAndSlide helper on RayCastSystem for swept kinematic movement.
This builds on the existing shape cast path and clips the remaining translation along hit planes without changing physics solver behavior. It intentionally does not depenetrate initial overlaps, matching existing shape cast behavior.

@rhailrake

Copy link
Copy Markdown
Contributor Author

I believe this test failure is unrelated to my changes.

Comment on lines +248 to +261

private static bool CanKinematicMoveCastShape(IPhysShape shape)
{
return shape switch
{
PhysShapeCircle => true,
PolygonShape => true,
Polygon => true,
SlimPolygon => true,
_ => false,
};
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this box them as some shapes have been ported to structs.

Comment on lines +193 to +200
private bool TryCastShapeClosest(
MapId mapId,
IPhysShape shape,
Transform origin,
Vector2 translation,
QueryFilter filter,
out KinematicMoveHit hit)
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generics better as below r.e. boxing.

Comment on lines +160 to +163
if (!fixture.Hard ||
fixture.CollisionLayer == 0x0 ||
fixture.CollisionMask == 0x0 ||
!CanKinematicMoveCastShape(fixture.Shape))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a box2d port because box2d uses AND for layer / mask collisions but we still use godot's OR so are you really sure it should filter out if layer or mask is 0 atm?

Comment on lines +12 to +15
{
private const int DefaultKinematicMoveIterations = 4;
private const float DefaultKinematicMoveSkin = 0f;
private const float KinematicMoveEpsilon = float.Epsilon;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These really should not be constants as they look like they were built for single-purpose and should be CVars. All the other physics constants have purpose for being constants but even the solver iterations are configurable.

They also need documenting.

@metalgearsloth

Copy link
Copy Markdown
Contributor

Rest looks good fwiw.

@metalgearsloth

Copy link
Copy Markdown
Contributor

Box2D includes these now so I would prefer to port those to use ideally.

@rhailrake
rhailrake deleted the ray_kinematica branch July 20, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants