Comments (4)
If external crates are to composably define shapes that need to dispatch recursively (i.e. compound shapes similar to HeightField), then I don't see any alternatives to the original proposal. However, end-user ergonomics could be preserved by relegating the root_dispatcher
argument to a trait for use only by shape implementers, and turning QueryDispatcher
into a blanket-implemented trait that encapsulates the self.query(self, ...)
dance, and provides a chain
helper for composition. How does that sound?
from parry.
Hi! I feel like adding a root_dispatcher
arguments to all dispatch methods are a bit too intrusive, and makes it weird to use by the end-user (who has do call something like dispatcher.distance(dispatcher, ...)
.
A more transparent way of doing this is through composition:
- Change the existing
DefaultQueryDispatcher
to a:
struct BaseQueryDispatcher<'a, D> {
root_dispatcher: &'a D
}
impl QueryDispatcher for BaseQueryDispatcher {
fn distance(...) {
// ...
if let Some(c1) = shape1.as_composite_shape() {
Ok(query::details::distance_composite_shape_shape(
self.root_dispatcher, pos12, c1, shape2,
))
}
// ....
}
}
- Redefine a new
DefaultQueryDispatcher
that calls theBaseQueryDispatcher
methods (to avoid code duplication):
struct DefaultQueryDispatcher;
impl QueryDispatcher for DefaultQueryDispatcher {
fn distance(...) {
let dispatcher = BaseQueryDispatcher { root_dispatcher: self };
dispatcher.distance(...)
}
}
And then you can write your own dispatcher that passes itself to the BaseQueryDispatcher
.
That way there is no need to change the signature of the dispatcher trait methods.
from parry.
That does look better. It might take some creativity to make composing dispatchers ergonomic (so that independently implemented custom shapes can be used without the end user writing a ton of boilerplate), but I think it's tractable; I'll play with it.
from parry.
Consider two libraries that define custom compound shapes, and an application that wants to use both. Ideally the application, which does not itself define any custom shapes, should not have to implement QueryDispatcher
. I don't think the revised proposal supports that, since there's no way for parry to provide for composition of recursive dispatch logic, unless I'm missing something.
from parry.
Related Issues (20)
- QBVH `rebalance` still panics at 'attempt to add with overflow' HOT 6
- Export `size_32/size_64` features from `rkyv` HOT 1
- Add method to scale an AABB wrt its center HOT 1
- Contact query giving incorrect result for Frustums HOT 5
- Pathtracer ?
- Large convex hulls produce incorrect contact manifolds HOT 2
- Ray casts which touch a TriMesh edge report intersection with a backface HOT 1
- Point in polygon 2D test failure
- Doc info for VHACD best parameters
- `Aabb::vertices()` returns the vertices in incorrect order
- Entered unreachable code HOT 4
- Implement Debug for TriMesh HOT 1
- Incorrect docs in TriMeshFlags
- `time_of_impact_support_map_support_map` returns `None` when it shouldn't with very specific inputs HOT 2
- Convex decomposition in 2d produces bad shapes HOT 3
- Matrix index out of bounds when using convex decomposition 2d HOT 1
- Shape casting returns incorrect normals
- project_local_point fails to find the correct projection when the point lies on a triangle edge
- panicked at epa3.rs HOT 2
- EPA convergence failure on capsules
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parry.