Skip to content

QueryOptions parameters (GjkOptions) #298

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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

Vrixyz
Copy link
Contributor

@Vrixyz Vrixyz commented Dec 17, 2024

Following discussion on discord, a shape cast of a ball sometimes fails when it should not.

Current status

  • Exposes gjk parameters through GjkOptions, this is very breaking as it impacts PointQuery trait.
    • DefaultQueryDispatcher stores relevant options to pass to their algorithms.
  • Use a QueryOoptionsNotUsed in algorithms to make it easier to understand which paths need an option and which don´t. Ideally an associated trait would be used but it makes it difficult to mix different shapes...
  • 🤔 Maybe we should consider making new methods to pass parameters, like contains_local_point_with_option ? to make the API more straightforward by default, but I'm not a huge fan of duplicated entries
  • 🤔 Can we improve the type safety ? Currently an incorrect parameter leads to using default and logging a warning, I think it's good enough ™️ but not amazing

Before this PR:

Screenshot failed

After this PR, with customizable Gjk epsilon changing each frame:

Screencast.from.07-24-2025.04.49.01.PM.webm

I added an example for compound shape point query (using convex polygon, to test dispatching gjk options), and the result was showing false negatives (without custom gjk options ; multiplying the epsilon by 100 fixes it.):

Screencast.from.07-16-2025.04.09.26.PM.webm

@Vrixyz Vrixyz changed the title heavy wip ; I could reproduce a wrong shapecast 🤔 Add shapecast example + loosen gjk epsilon Dec 18, 2024
@Vrixyz Vrixyz requested a review from sebcrozet December 18, 2024 08:25
…fix more path to eps_tol(), but serves as discussion starter
Vrixyz added 2 commits July 8, 2025 15:31
It's not straightforward to do, that will likely need a solution similar to a dispatcher
@Vrixyz Vrixyz force-pushed the incorrect-shapecast branch from 02a37ec to ca45b43 Compare July 9, 2025 13:14
#[cfg(feature = "alloc")] // TODO: can’t be used without alloc because of EPA
{
let Some(options) = options.as_any().downcast_ref() else {
warn!("Incorrect option passed to project_local_point: using default options.");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not a huge fan of these warnings:

  • I'd like to make it easy for users to use the "simple API" (pass default options)
    • We can make a project_local_point_with_query_options, but I'm not sure duplicating API is great
    • I chose to support &() as parameter which will be interpreted as default options later
      • Going this path means we should not warn if user passed &().

@Vrixyz Vrixyz changed the title Add shapecast example + loosen gjk epsilon QueryOptions parameters (GjkOptions) Jul 17, 2025
@Vrixyz
Copy link
Contributor Author

Vrixyz commented Jul 17, 2025

Comment on lines +46 to +53
(TypeId::of::<Compound>(), self_ref),
#[cfg(feature = "dim2")]
(
TypeId::of::<crate::shape::ConvexPolygon>(),
gjk_options.clone(),
),
#[cfg(feature = "dim3")]
(TypeId::of::<crate::shape::ConvexPolyhedron>(), gjk_options),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do roundshapes and other container shapes need to be specific ? like TypeId::of::<RolunShape<crate::shape::ConvexPolyhedron>>() ?

Copy link
Contributor Author

@Vrixyz Vrixyz Jul 23, 2025

Choose a reason for hiding this comment

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

No: roundshapes use support point algorithm which is gjk options.

Comment on lines +62 to +65
// FIXME: This needs a query option dispatcher, because a user custom shape against a ball may need a different option.
// Currently, some paths lead to an unused option.
// (Gjk is used for intersections with convex shapes and cylinder)
&self.gjk_options,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an important point to tackle.

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.

1 participant