Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Might be a dumb question
#2
(28-04-2022, 08:31 PM)snowtv Wrote: From the look of it, seems like they are actual class objects, but I can't seem to find for example, if I know the index of a particle in an actor, how can I retrieve that particle object.
So maybe this "scripting particle" is just an arbitrary thing that exists in the form of all the arrays of data about it?

HI there!

"Scripting particles" refers to the act of controlling particles via script. It's not the name of a thing Sonrisa.

Particles are not classes or structs. Obi uses a data-oriented approach, which means particles are just an index, that you can use to access data in several arrays of the same length. Quoting the manual:

Quote:*Lists all properties* [...] Each ObiSolver has an array for each one of these properties, that stores the current data for all particles in use by any actor managed by the solver.

So to access the position of the Nth particle in a cloth, you do:

Code:
var pos = solver.positions[cloth.solverIndices[N]];

Similarly, to access its velocity:

Code:
var pos = solver.velocities[cloth.solverIndices[N]];


FYI, Unity's DOTS (data-oriented technology stack) uses the same approach: entities are not classes or structs, an entity is just an index into arrays of components.

The main advantage of this approach is the ability to deal with large amounts of data in a very performant way, because cache misses are minimized and memory is used efficiently: when you need to operate over say, particle positions and velocities, you *only* operate on that. No need to bring single every property from memory (mass, radius, color, etc) like you'd be forced to do if particles were structs - since you could not have partial access to a particle.

(28-04-2022, 08:31 PM)snowtv Wrote: Additional question, when I inspect solver.orientations array, it seems that all the values are (0, 0, 0, 1), no matter how I'm moving my ObiCloth in the scene. Which makes me a bit confused...

Orientations are only used by some actors, and cloth isn't one of them: cloth particles are just points in space with no orientation.

Currently, only rods (ObiRope) and soft bodies (ObiSoftbody) use oriented particles.


kind regards,
Reply


Messages In This Thread
Might be a dumb question - by snowtv - 28-04-2022, 08:31 PM
RE: Might be a dumb question - by josemendez - 28-04-2022, 11:02 PM
RE: Might be a dumb question - by snowtv - 29-04-2022, 03:58 PM
RE: Might be a dumb question - by josemendez - 02-05-2022, 08:52 PM
RE: Might be a dumb question - by snowtv - 03-05-2022, 08:24 PM
RE: Might be a dumb question - by josemendez - 04-05-2022, 09:48 AM
RE: Might be a dumb question - by snowtv - 05-05-2022, 07:49 PM
RE: Might be a dumb question - by josemendez - 06-05-2022, 08:01 AM
RE: Might be a dumb question - by snowtv - 11-05-2022, 04:37 PM
RE: Might be a dumb question - by snowtv - 12-05-2022, 09:39 PM
RE: Might be a dumb question - by josemendez - 13-05-2022, 09:05 AM