Skip to content

Commit c7748c7

Browse files
committed
Fix decal rotation
1 parent 6713ef4 commit c7748c7

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

Assets/Scripts/OpenTS2/Scenes/ParticleEffects/SwarmDecal.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,6 @@ public void Initialize()
6161
transform.localScale = Vector3.one;
6262
}
6363

64-
private Vector2 RotateUV(Vector2 uv, float angle)
65-
{
66-
var cos = Mathf.Cos(angle);
67-
var sin = Mathf.Sin(angle);
68-
var x = uv.x * cos - uv.y * sin;
69-
var y = uv.x * sin + uv.y * cos;
70-
return new Vector2(x, y);
71-
}
72-
73-
private Vector2 GetUV(Vector3 point)
74-
{
75-
var radius = 80f;
76-
var radiusHalf = radius * 0.5f;
77-
var minPos = _position;
78-
minPos -= new Vector3(radiusHalf, radiusHalf, radiusHalf);
79-
var maxPos = minPos + new Vector3(radius, radius, radius);
80-
81-
point -= minPos;
82-
point /= radius;
83-
84-
var uv = new Vector2(point.x - 0.5f, point.z - 0.5f);
85-
uv = RotateUV(GetUV(uv), _rotation.y * Mathf.Deg2Rad);
86-
uv += new Vector2(0.5f, 0.5f);
87-
return uv;
88-
}
8964
private void BuildDecalMesh(Mesh terrainMesh)
9065
{
9166
_decalMesh = new Mesh();
@@ -98,7 +73,7 @@ private void BuildDecalMesh(Mesh terrainMesh)
9873
var radius = 80f;
9974
var radiusHalf = radius * 0.5f;
10075
var decalPositionMatrix = Matrix4x4.Translate(new Vector3(-_position.x + radiusHalf, 0f, -_position.z + radiusHalf));
101-
var decalRotationMatrix = Matrix4x4.Rotate(Quaternion.Euler(0f, _rotation.y, 0f));
76+
var decalRotationMatrix = Matrix4x4.Rotate(Quaternion.Euler(0f, -_rotation.y, 0f));
10277

10378
for(var i = 0; i < vertices.Length; i++)
10479
{

0 commit comments

Comments
 (0)