Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Can't access useBody internal UUID when adding constraints against instance mesh bodies #146

Open
IRobot1 opened this issue Aug 19, 2022 · 2 comments

Comments

@IRobot1
Copy link
Contributor

IRobot1 commented Aug 19, 2022

Physics bodies can be created against instance meshes. The index can be passed to the body function

  sphereProps = this.physicBody.useParticle((index: number) => ({

Internally, this creates a virtual UUID that's passed to cannon.

However, constraints are missing a way to refer to instance bodies using the virtual UUID. Currently, only non instance bodies are supported.

My guess is a check if objects are InstanceMesh would need to be added here to lookup the internal UUID.

Am I on the right track?

@IRobot1
Copy link
Contributor Author

IRobot1 commented Aug 20, 2022

I found NgtCannonUtils.getUUID(ref, index). This could be called like

this.physicConstraint.useDistanceConstraint(
NgtCannonUtils.getUUID(instancebody.ref, instanceA),
NgtCannonUtils.getUUID(instancebody.ref, instanceB),
{});

but unfortunately, there's no useXXXConstraint method that takes two uuid strings. Perhaps there could be a duplicate methods that supports instance body and two indices

useDistanceConstraint(instBody: Ref, indexA: number, indexB: number, optns:...)

The existing private useConstraint could be split up to handle objects or uuids and the new methods could use the uuid version.

Does this seem reasonable?

@IRobot1
Copy link
Contributor Author

IRobot1 commented Aug 20, 2022

Created pull request for supporting constraints against instance mesh.

Added variation of physics clump to sandbox examples that limits distance from center using fixed distance constraint using instance bodies.

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant