From 8e13e7e2874adc8982e16d1d2ed2e28d7480b45f Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Sun, 19 May 2024 16:05:58 +0800 Subject: +1.57 --- .../NGS.MeshFusionPro/SimpleMeshMoverSTD.cs | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Thronefall_1_57/Decompile/NGS.MeshFusionPro/SimpleMeshMoverSTD.cs (limited to 'Thronefall_1_57/Decompile/NGS.MeshFusionPro/SimpleMeshMoverSTD.cs') diff --git a/Thronefall_1_57/Decompile/NGS.MeshFusionPro/SimpleMeshMoverSTD.cs b/Thronefall_1_57/Decompile/NGS.MeshFusionPro/SimpleMeshMoverSTD.cs new file mode 100644 index 0000000..5a56ec3 --- /dev/null +++ b/Thronefall_1_57/Decompile/NGS.MeshFusionPro/SimpleMeshMoverSTD.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace NGS.MeshFusionPro; + +public class SimpleMeshMoverSTD : ICombinedMeshMover +{ + private MeshDataListsSTD _meshData; + + public SimpleMeshMoverSTD(MeshDataListsSTD meshData) + { + _meshData = meshData; + } + + public void MoveParts(IList moveInfos) + { + List vertices = _meshData.Vertices; + List normals = _meshData.Normals; + List tangents = _meshData.Tangents; + List partsBounds = _meshData.PartsBounds; + List partsBoundsLocal = _meshData.PartsBoundsLocal; + Bounds bounds = _meshData.GetBounds(); + bounds.size = Vector3.zero; + for (int i = 0; i < moveInfos.Count; i++) + { + PartMoveInfo partMoveInfo = moveInfos[i]; + int partIndex = partMoveInfo.partIndex; + int vertexStart = partMoveInfo.vertexStart; + int num = vertexStart + partMoveInfo.vertexCount; + Matrix4x4 targetTransform = partMoveInfo.targetTransform; + Matrix4x4 inverse = partMoveInfo.currentTransform.inverse; + for (int j = vertexStart; j < num; j++) + { + Vector3 point = vertices[j]; + Vector3 vector = normals[j]; + Vector4 vector2 = tangents[j]; + float w = vector2.w; + point = inverse.MultiplyPoint3x4(point); + point = targetTransform.MultiplyPoint3x4(point); + vector = inverse.MultiplyVector(vector); + vector = targetTransform.MultiplyVector(vector); + vector2 = inverse.MultiplyVector(vector2); + vector2 = targetTransform.MultiplyVector(vector2); + vector2.w = w; + vertices[j] = point; + normals[j] = vector; + tangents[j] = vector2; + } + partsBounds[partIndex] = partsBoundsLocal[partIndex].Transform(targetTransform); + } + for (int k = 0; k < partsBounds.Count; k++) + { + bounds.Encapsulate(partsBounds[k]); + } + _meshData.Bounds = bounds; + } + + public void ApplyData() + { + _meshData.ApplyDataToMesh(); + } +} -- cgit v1.1-26-g67d0