22-09-2017, 09:18 AM
(This post was last modified: 22-09-2017, 09:31 AM by josemendez.)
(22-09-2017, 08:31 AM)sunyifeng83 Wrote: Hi jose,
Thank you. Understood. I saw in the exmple scene FaucetAndBucket, The bucket has 2880 tris, With 1000 particles, This will cause 2.88 million triangle/particle collision tests with the fluid per frame. Why that sample's performance not that bad?
In that particular example, the triangles are evenly distributed across the bucket's mesh.
Obi uses a spatial partitioning structure known as "bounding interval hierarchy" to store the mesh triangle's and ignore those that are not near a given particle when testing for collisions. This structure uses the triangle's bounding boxes to discard those far away from the particle.
So the collision test for each particle first traverses this structure, and in a few steps it has determined most of the triangles in the mesh that can be ignored. Then it only performs the expensive triangle/point test for the remaining triangles, which are usually just 3-4 tris per particle. For 1000 particles this means only 3000-4000 tests, which is doable.
Your mesh however is a worst-case for this, because most triangles are clumped in two zones: the top of the bottle, and the bottom. This means that the bounding boxes of the triangles overlap almost completely those of their neighbors, making any efforts to discard any of them ineffective. So in the end, each particle needs to be tested with almost all the triangles.
3,6 million tests/frame is an upper bound estimation and not a fixed number, probably less tests are being actually performed as the bottom triangles and the top triangles are far from each other -thus easily culled- but still enough to cause performance problems. Also the fact that the triangles are smaller that the particles means that each particle hits more bounding boxes, making the problem worse.
Best luck with the project, if you need further help or have questions do not hesitate to ask
