Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Normal positions vs Renderable positions
#1
Hello.

We're using Obi Cloth in our VR app. There are two pieces of cloth that the user must grab and drop on the floor. So we must check if the controller is within range of a particle to grab the cloth, and if majority of the particles are on the floor.

Previously, we were checking the position of the particles by doing actor.GetParticlePositions().

If I understand correctly, that returns renderable positions, and only works appropriately if you tell the solver of the actor to RequireRenderablePositions? Otherwise those renderable positions don't move if the cloth moves. Then you can call RelinquishRenderablePositions when you're done, and the main reason for that is that renderable positions are a little expensive?

I also discovered an alternative way to do this by calling actor.PullDataFromSolver(ParticleData.POSITIONS), then the actor has a vector3 positions array of all the particles. The documentation referred to this as "normal positions".

Three questions:
  1. Is that more or less expensive than doing renderable positions?
  2. If it's less expensive, how often do you have to call PullDataFromSolver()? Every frame?
  3. And am I on the right track here, or is there a better way we should be checking the position of the particles?

Thank you.
Reply
#2
(25-04-2019, 10:49 PM)tsantoro Wrote: Hello.

We're using Obi Cloth in our VR app. There are two pieces of cloth that the user must grab and drop on the floor. So we must check if the controller is within range of a particle to grab the cloth, and if majority of the particles are on the floor.

Previously, we were checking the position of the particles by doing actor.GetParticlePositions().

If I understand correctly, that returns renderable positions, and only works appropriately if you tell the solver of the actor to RequireRenderablePositions? Otherwise those renderable positions don't move if the cloth moves. Then you can call RelinquishRenderablePositions when you're done, and the main reason for that is that renderable positions are a little expensive?

I also discovered an alternative way to do this by calling actor.PullDataFromSolver(ParticleData.POSITIONS), then the actor has a vector3 positions array of all the particles. The documentation referred to this as "normal positions".

Three questions:
  1. Is that more or less expensive than doing renderable positions?
  2. If it's less expensive, how often do you have to call PullDataFromSolver()? Every frame?
  3. And am I on the right track here, or is there a better way we should be checking the position of the particles?

Thank you.

Hi,

In 4.x, Require/Relinquish RenderablePositions does no longer exist, and using renderable positions is not any more expensive than using positions. All per-particle arrays are memory mapped between C++ and C#, so they are always available and reading/writing from/to them incurs no extra cost.

If you're using 3.x, then yes, using renderable positions is a bit more expensive because memory must be copied around, and that's why you need to call require/relinquish when appropriate. Note however, than calling actor.PullDataFromSolver(ParticleData.POSITIONS); is exactly as expensive as calling RequireRenderablePositions(), which instructs the solver to call actor.PullDataFromSolver(ParticleData.RENDERABLE_POSITIONS) internally every frame. If you need to retrieve particle positions from the solver, you can use either method as the cost is essentially the same.

The difference between renderable and "normal" positions, is that renderable positions are iterpolated between physics steps if your solver has "Interpolation" enabled. Otherwise, they're exactly the same.

kind regards,
Reply
#3
Thank you for the swift reply. Sounds like we're on the right track, and that an upgrade to 4.x is worth it for us.

Appreciate it.
Reply