diff --git a/crest/Assets/Crest/Crest/Scripts/Interaction/SphereWaterInteraction.cs b/crest/Assets/Crest/Crest/Scripts/Interaction/SphereWaterInteraction.cs index b0927e568..412c79bab 100644 --- a/crest/Assets/Crest/Crest/Scripts/Interaction/SphereWaterInteraction.cs +++ b/crest/Assets/Crest/Crest/Scripts/Interaction/SphereWaterInteraction.cs @@ -92,7 +92,7 @@ public partial class SphereWaterInteraction : CustomMonoBehaviour, ILodDataInput internal static List s_Instances = new List(); 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"); @@ -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(); } @@ -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)]