Performance Questions - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html) +--- Thread: Performance Questions (/thread-703.html) |
Performance Questions - rosedev - 01-10-2018 Hello, I have two questions on performance. 1) Unity Profiler shows spikes approximately once per second on the Oni.WaitForAllTasks() method, even when the fluid is not moving. Is it normal? I also checked with ObiProfiler, but I didn't notice anything unusual, except the long "Idle (15ms)" label, which seems to be shown on every spike. I attached screenshots of ObiSolver, Unity Profiler, ObiProfiler and Emitter material. 2) I have a big level with many (about 20) colliders (some of them are EdgeCollider2D). Does it make sence to disable all colliders which are far away from the fluid? I have an idea to fetch the fluid grid each frame using Oni.GetParticleGrid() and disable all colliders that don't contains/intersects with any of the fluid cells. Something like that: Code: // Solver.OnFrameEnd += UpdateCollidersState; Thank you. RE: Performance Questions - rosedev - 02-10-2018 Any update? We are going to release the game soon RE: Performance Questions - josemendez - 03-10-2018 (02-10-2018, 06:48 PM)rosedev Wrote: Any update? We are going to release the game soon Hi rosedev, 1.- Those spikes are probably due to FixedUpdate() being called more than once those frames. This is the way physics work in Unity (and in any fixed-tilmestep engine): time is accumulated in the regular render update loop (deltaTime), then each frame evenly sized (fixedDeltaTime) chunks are processed. If enough time to require a second (or third, or fourth) physics update in a frame has been accumulated, then that particular frame will take more time to process. Note that this can sometimes lead to a phenomenon called "death spiral" in which the game enters a downwards performance spiral due to too much accumulated physics time, and that Unity offers a way of determining the maximum amount of times FixedUpdate is called in a frame (max fixed timestep) in order to alleviate this. See: https://docs.unity3d.com/Manual/class-TimeManager.html 2.- Obi only considers colliders that are very close to particles, as it internally uses a hierarchical spatial partitioning structure to store them and determine those that might collide with particles in the particle grid. Static colliders away from particles have zero cost (they aren't even updated). Dynamic colliders away from particles are slightly more expensive as the internal structure has to be updated, but still their cost is near minimal as they generate no contacts. Only colliders actually in contact will particles affect performance. Anything you do to enable/disable colliders at runtime will most likely only worsen performance. RE: Performance Questions - rosedev - 07-10-2018 (03-10-2018, 08:49 AM)josemendez Wrote: Hi rosedev, Thank you for the help! I have one more issue with Obi colliders. Unity Editor crashes when I'm trying to set negative scale to a GameObject with EdgeCollider2D and ObiCollider2D attached. The same happens when I'm trying to set negative scale (x=-1) to the bucket in the sample scene. Is there some workaround for this? Tested with 2018.2.1 and 2018.3 beta RE: Performance Questions - josemendez - 07-10-2018 (07-10-2018, 03:32 AM)rosedev Wrote: Thank you for the help! I have one more issue with Obi colliders. Unity Editor crashes when I'm trying to set negative scale to a GameObject with EdgeCollider2D and ObiCollider2D attached. The same happens when I'm trying to set negative scale (x=-1) to the bucket in the sample scene. Hi, We'll test it asap. However I would recommend avoiding negative scales in general, when using any kind of physics engine. Most colliders will work in different and unexpected ways when using negative scales (crashing is not one of them though, that would be a bug), as that generally turns them "inside out". In the case of a box colliders for instance, it would flip its normals. Edit: Found the cause of the crash. Only happens to edge/mesh colliders. It is a bug, will provide a workaround as soon as I find one. RE: Performance Questions - rosedev - 08-10-2018 (07-10-2018, 04:01 PM)josemendez Wrote: Hi, Thanks, it would be nice to workaround this problem. I need to flip an object with edge colliders by horizontal axis and it seems that scaling is the only way to do that in this particular case. |