05-08-2021, 02:54 PM
(05-08-2021, 11:06 AM)josemendez Wrote: From scripting particles:
http://obi.virtualmethodstudio.com/manua...icles.html
Longer answer: vectorized or SIMD instructions (single instruction, multiple data) typically process 4 pairs of operands in parallel. This allows the CPU to for instance, add together two Vector4s in the same time it would take to add two floats. However these instructions only work on 2, 4, or 8 pairs of operands, and they have to be aligned in memory in a very specific way. For this reason Obi exposes multidimensional data as Vector4s, with the last component (w) being 0. This allows it to perform arithmetic operations up to 75% faster than it would otherwise.
Another, less important reason is that matrix algebra usually involves multiplying 4x4 matrices against points/vectors. Using Vector4s directly avoids having to internally convert Vector3 to Vector4 and back, which results in even better performance and more streamlined code.
If you want to for instance modulate sound volume depending on impact "force", use the normal impulse magnitude. Tangent and bitangent impulses are used for friction, and stick impulses are used for well...sticky contacts
Depends on how you do it and what your budget is. Obi generates and deals with tens of thousands of contacts every frame, but it does it in a extremely optimized way. This data is made available to you, then it's your turn to process it in any way you like: simplest is a for loop over all of them, will do fine if you're not on a tight budget or want something simple. This is of course not very efficient: runs in the main thread and no vectorization is taken advantage of.
You could also process all this data in parallel using jobs, and exploit vectorization, which is the way Obi does it. Will result in orders of magnitude better performance at the cost of slightly more complex code.
Thank you so much for that detailed answer ! I managed to make it work just as I wanted For now it's using a basic foreach loop, and it seems to be good enough performance wise.
Have a nice day !