ncollide icon indicating copy to clipboard operation
ncollide copied to clipboard

Extensible Shape dispatch.

Open Ralith opened this issue 6 years ago • 1 comments

Presently, supporting a new shape requires defining a new ContactDispatcher, which is boilerplate-heavy, awkward to compose, and does not account for CCD or high-level query functions. This could be improved by relying something like on one or more dynamic containers that map (TypeId, TypeId) -> T for various query functions T, and which can easily be mutated by the user to add new cases. However, implementation of some queries in terms of abstract interfaces like &dyn SupportMap complicates this as the desired algorithm is associated with an unbounded set of concrete TypeIds.

Ralith avatar Aug 18 '19 18:08 Ralith

Given the potential complexity and diversity of dispatch logic, maybe the most pragmatic option is to define something like

pub trait Dispatcher<T> {
    fn get(&self, a: &dyn Shape, b: &dyn Shape) -> Option<T>;
}

and use it more pervasively in the API. Then at least combinators can be defined for improved composition.

Ralith avatar Aug 18 '19 19:08 Ralith