Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Adding Solvers to Obi Updaters at Runtime
#4
(17-09-2023, 07:17 AM)scionious Wrote:
Code:
        ///WINDZONES
        //Copy current weather system state to a temp list
        tempSolverList.Clear();
        foreach (ObiSolver solver in obiMasterWindZone.affectedSolvers)
        {
            tempSolverList.Add(solver);
        }

        //Add new solvers to list for inheriting wind
        foreach (ObiSolver solver in obiSolversToInheritWind)
        {
            tempSolverList.Add(solver);
        }

        //Write all solvers to array
        obiMasterWindZone.affectedSolvers = tempSolverList.ToArray();

And figured out the Force Zones. This is a pretty ok way to do this?

Also, why am I getting huge 20ms spikes in LateFixedUpdate from Obi when I'm only using FixedUpdate as far as I know? 
Is this a side-effect of using a bunch of Proxies?

I have around 70 solvers in the scene, with a Single ObiFixedUpdater component and and an AmbientForceZone component.
I'm using proxies on those 70 solvers  - is this why?

Any other way I can get double sided cloth in URP with proper lighting?

Hi!

While this will work, it is an extremely inefficient way of doing it since you're copying all items twice (one when adding them to a temp list, then another when converting to an array), and the first time you do it one by one which will cause a lot of list reallocations - lists work by scrapping their entire contents and moving them to a new internal array of twice its original length every time they reach max capacity.

Regular C# arrays have a Resize() function you can call to set a new size for the array, which only reallocates once.


(17-09-2023, 07:17 AM)scionious Wrote: Any other way I can get double sided cloth in URP with proper lighting?

You can just use 2 materials per mesh (one front-facing and one back-facing, this works in all render pipelines and is what all included sample scenes do) or just use a single, two-sided material. In URP this is very easy to do as the Lit shader has a two-sided version, just set "Render Face" to "Both":

This has close to zero cost.

(17-09-2023, 07:17 AM)scionious Wrote: Also, why am I getting huge 20ms spikes in LateFixedUpdate from Obi when I'm only using FixedUpdate as far as I know?
Is this a side-effect of using a bunch of Proxies?

I have around 70 solvers in the scene, with a Single ObiFixedUpdater component and and an AmbientForceZone component.
I'm using proxies on those 70 solvers  - is this why?

No, proxies are updated in Update. LateFixedUpdate is only used when using ObiLateFixedUpdater component.

Anyway, if you're using proxies to get double-sided cloth, using double-sided materials (see above) is much simpler and a whole lot faster.

let me know if I can be of further help,

kind regards
Reply


Messages In This Thread
RE: Adding Solvers to Obi Updaters at Runtime - by josemendez - 18-09-2023, 05:59 AM