Skip to content

Commit

Permalink
Fix SWI not working / frame rate issues
Browse files Browse the repository at this point in the history
Also fixes warnings due to data not clearing correctly.
  • Loading branch information
daleeidd committed Aug 14, 2024
1 parent 6377bc5 commit e352343
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public partial class SphereWaterInteraction : CustomMonoBehaviour, ILodDataInput

internal static List<SphereWaterInteraction> s_Instances = new List<SphereWaterInteraction>();
static int s_InstanceIndex;
static bool s_InstanceDataNeedsClearing;
static int s_ClearedFrameCount = -1;

static int sp_velocity = Shader.PropertyToID("_Velocity");
static int sp_weight = Shader.PropertyToID("_Weight");
Expand Down Expand Up @@ -144,12 +144,12 @@ static void ClearInstanceData()
s_MPB?.Clear();

s_InstanceIndex = 0;
s_InstanceDataNeedsClearing = false;
s_ClearedFrameCount = Time.frameCount;
}

void LateUpdate()
{
if (s_InstanceDataNeedsClearing)
if (Time.frameCount != s_ClearedFrameCount)
{
ClearInstanceData();
}
Expand Down Expand Up @@ -363,8 +363,6 @@ public static void SubmitDraws(LodDataMgr manager, int lodIndex, CommandBuffer b
// Clear any arrays modified in Draw as this is per LOD.
s_WeightProperties.Clear();
s_InstanceIndex = 0;
// Other arrays are cleared next frame.
s_InstanceDataNeedsClearing = true;
}

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
Expand Down

0 comments on commit e352343

Please sign in to comment.