Skip to content

Commit

Permalink
fix: the ParticleSystem's localPosition drifts at certain scales due …
Browse files Browse the repository at this point in the history
…to floating-point precision issues

close #299, close #312
  • Loading branch information
mob-sakai committed May 24, 2024
1 parent fc3fbdd commit a9c2b19
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Packages/src/Runtime/UIParticleRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ private void Simulate(Vector3 scale, bool paused)
// get world position.
var isLocalSpace = _particleSystem.IsLocalSpace();
var psTransform = _particleSystem.transform;
var originLocalPosition = psTransform.localPosition;
var originLocalRotation = psTransform.localRotation;
var originWorldPosition = psTransform.position;
var originWorldRotation = psTransform.rotation;
var emission = _particleSystem.emission;
Expand All @@ -636,7 +638,8 @@ private void Simulate(Vector3 scale, bool paused)
: originWorldPosition.GetScaled(scale.Inverse());
psTransform.SetPositionAndRotation(scaledPos, originWorldRotation);
_particleSystem.Simulate(deltaTime, false, false, false);
psTransform.SetPositionAndRotation(originWorldPosition, originWorldRotation);
psTransform.localPosition = originLocalPosition;
psTransform.localRotation = originLocalRotation;
}

#if UNITY_EDITOR
Expand Down

0 comments on commit a9c2b19

Please sign in to comment.