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:
What do you think, will it increase the performace? I'm asking because I can't test it quickly (I have to change a lot of code to implement that)
Thank you.
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;
private void UpdateCollidersState(object sender, System.EventArgs e)
{
var cellCount = Oni.GetParticleGridSize(Solver.OniSolver);
CurrentFluidGridCells = new Oni.GridCell[cellCount];
Oni.GetParticleGrid(Solver.OniSolver, CurrentFluidGridCells);
for (var i = 0; i < Colliders.Count; i++)
{
var c = Colliders[i];
var shouldBeEnabled = false;
for (var j = 0; j < CurrentFluidGridCells.Length; i++)
{
if (IsColliderAABBIntersectsWithFluidGridCell(c.SourceCollider, CurrentFluidGridCells[j].center, CurrentFluidGridCells[j].size*2)) // compare collider.bounds with cell bounds
{
shouldBeEnabled = true;
break;
}
}
c.enabled = shouldBeEnabled;
c.SourceCollider.enabled = shouldBeEnabled;
}
}
Thank you.