Skip to content

Commit

Permalink
fix: sub-emitter particles may not render correctly in certain scenarios
Browse files Browse the repository at this point in the history
close #248
  • Loading branch information
mob-sakai committed Jan 3, 2025
1 parent 27551a4 commit ef4dbc3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Packages/src/Runtime/UIParticleRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,24 @@ private Matrix4x4 GetWorldMatrix(Vector3 psPos, Vector3 scale)
* Matrix4x4.Scale(scale)
* Matrix4x4.Translate(-psPos);
}

if (_mainEmitter)
{
if (_mainEmitter.IsLocalSpace())
{
return Matrix4x4.Translate(psPos)
* Matrix4x4.Scale(scale)
* Matrix4x4.Translate(-psPos);
}
else
{
psPos = _particleSystem.transform.position - _mainEmitter.transform.position;
return Matrix4x4.Translate(psPos)
* Matrix4x4.Scale(scale)
* Matrix4x4.Translate(-psPos);
}
}

return Matrix4x4.Scale(scale);
case ParticleSystemSimulationSpace.Custom:
return Matrix4x4.Translate(_particleSystem.main.customSimulationSpace.position.GetScaled(scale))
Expand Down

0 comments on commit ef4dbc3

Please sign in to comment.