Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Adding Collisions with ArticulationBody
#1
Bombilla 
I'd like to try to get collisions between ArticulationBody and Obi ropes working.
Is it just a matter of replicating the functionality in ObiRigidbody for a new ObiArticulationbody class? I'm guessing I could inherit from ObiRigidbodyBase too and just treat them as rigidbodies, is it only the UpdateVelocities method that's important here?
(I bet I'm missing loads of the hidden complexities!)
thanks in advance
Reply
#2
(17-11-2021, 01:38 PM)spakment Wrote: I'd like to try to get collisions between ArticulationBody and Obi ropes working.
Is it just a matter of replicating the functionality in ObiRigidbody for a new ObiArticulationbody class? I'm guessing I could inherit from ObiRigidbodyBase too and just treat them as rigidbodies, is it only the UpdateVelocities method that's important here?
(I bet I'm missing loads of the hidden complexities!)
thanks in advance

Hi there!

Articulation bodies are very different from rigidbodies. A rigidbody is basically a center of mass, linear/angular velocity, and linear/angular mass. An articulation body however, is a collection of individual bodies defined in their parent's local space, each one with different coordinates/properties depending on the joint configuration. It's not possible to add support for them without diving deep in Obi's physics engine and modifying both backends.

Obi achieves two-way coupling with rigidbodies by applying impulses to them, it does this by:

1) storing their velocities prior to the particle update
2) modifying these velocities according to the impulses applied by the particles
3) then writing the new velocities back (the UpdateVelocities method)

Steps 1) and 3) are trivial and happen outside of the engine's core. Step 2) is where 99% of the stuff takes place.

In an articulation body, applying an impulse involves traversing the entire hierarchy propagating the change in velocity to each individual body. It's not just a matter of modifying a single velocity vector (like it is for rigidbodies). Here's an article that explains it in detail (page 22 onwards): http://www.cs.unc.edu/~lin/COMP768-F07/LEC/20.pdf

Support for articulations will eventually be added to Obi, however it is a quite complex task: making articulation data available to Obi's core laid out in a way that allows for efficient parallel processing, and figuring out a way to apply impulses concurrently to the same articulation body.
Reply
#3
Okay, I'll assume its beyond my level Sonrisa but doesn't the physx engine's solver takes care of the distribution across the articulation?

Every "joint" in an articulation (in the PhysX implementation) has an ArticulationBody component (its not one for the whole articulation its one per joint), and each one can be affected as if they are individual rigid bodies by setting any particular articulation's velocity and angularVelocity.

Each articulation has a collider (in my case it's usually a capsule on each articulation) to have the rope be affected by the articulation with a collider component can I just add a ObiCollider to it? So long as the articulation affects the rope it doesn't matter in this instance that the rope doesn't affect the articulation body...
Reply
#4
(17-11-2021, 02:32 PM)spakment Wrote: but doesn't the physx engine's solver takes care of the distribution across the articulation?

Yes, but no: I mean, when you call articulation.AddForce(), PhysX does this stuff under the hood for you. The problem with this is that you can only call this from Unity's main thread. Obi is fully multithreaded, using Unity's single-threaded API would absolutely obliterate performance: stall the task queue, bring impulse data to the main thread, call AddForce for each one, then write back data and resume simulation.

Also, this would only take care of one-way coupling: particles would be able to affect articulation bodies, but articulation bodies would not be able to affect particles (since they know nothing about them).

Obi internally uses its own representation of all collider types as well as rigidbodies. At runtime it keeps both PhysX's representation of these objects and its own representation in sync. This allows it to interface with PhysX as if both were part of the same simulation. This is what ObiCollider and ObiRigidbody components do in a nutshell.

So we need to similarly replicate articulation bodies and implement a good chunk of their functionality in Obi.

(17-11-2021, 02:32 PM)spakment Wrote: Each articulation has a collider (in my case it's usually a capsule on each articulation) to have the rope be affected by the articulation with a collider component can I just add a ObiCollider to it? So long as the articulation affects the rope it doesn't matter in this instance that the rope doesn't affect the articulation body...

Haven't tried it, but there's a pretty high chance this will work. Colliders are completely independent from rigidbodies, so a collider in an articulation body would seem like a regular static collider to Obi. The articulation will behave as if no rope was present though.
Reply
#5
Dedo arriba 
(17-11-2021, 02:44 PM)josemendez Wrote: Haven't tried it, but there's a pretty high chance this will work. Colliders are completely independent from rigidbodies, so a collider in an articulation body would seem like a regular static collider to Obi. The articulation will behave as if no rope was present though.

Brilliant - that worked, thank you.
Reply