Any way to get, and store, a `ColliderDesc`

#1

I’m trying to migrate this mess of NCollide code to NPhysics and just use kinematic bodies so I can handle my own motion. Seems like a cleaner solution than essentially duplicating my own sensor code, writing a contact handler to keep objects from overlapping, etc.

I’m trying for the easiest Amethyst integration I can get, though, which currently looks like:

struct Body(Vec<ColliderDesc<f32>>);

My shapes are all pretty simple, so this seems like it should be sufficient. My physics system creates a body, then iterates through the colliders on the component and adds them all in turn. But ColliderDesc::new(...) returns &self, ColliderDesc isn’t clonable, and I’m not sure how to store it. I could create my own struct and copy those values onto ColliderDesc, but the best code is the kind I don’t have to write.

Is there any way to get an actual ColliderDesc rather than a reference? I can’t use * since that won’t let me add to the Vec.

And could this be made to derive Clone? Or is there some other way I can create my own colliders and stash them in a component such that I only have to sync to and from the physics world in a single place?

Thanks.

0 Likes

#2

Ack, sorry for the noise. As can be seen in my pull request shenanigans, I was trying to chain method calls, and I really should stop that as it has bitten me more than once. Things work fine when I just create a mutable reference and call the setters.

0 Likes