diff options
| author | chai <215380520@qq.com> | 2024-05-19 16:05:58 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2024-05-19 16:05:58 +0800 |
| commit | 8e13e7e2874adc8982e16d1d2ed2e28d7480b45f (patch) | |
| tree | 63ef85c460288891f5a593d69afeca16cba050b3 /Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataListsSTD.cs | |
| parent | c5f145786f4c6d2fe4bea831dfc16e52228920a5 (diff) | |
+1.57
Diffstat (limited to 'Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataListsSTD.cs')
| -rw-r--r-- | Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataListsSTD.cs | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataListsSTD.cs b/Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataListsSTD.cs new file mode 100644 index 0000000..1bf34eb --- /dev/null +++ b/Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataListsSTD.cs @@ -0,0 +1,83 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace NGS.MeshFusionPro; + +public class MeshDataListsSTD : CombinedMeshDataInternal +{ + private CombinedMesh _root; + + private List<Vector3> _vertices; + + private List<Vector3> _normals; + + private List<Vector4> _tangents; + + private List<Bounds> _partsBounds; + + private List<Bounds> _partsBoundsLocal; + + public List<Vector3> Vertices => _vertices; + + public List<Vector3> Normals => _normals; + + public List<Vector4> Tangents => _tangents; + + public List<Bounds> PartsBounds => _partsBounds; + + public List<Bounds> PartsBoundsLocal => _partsBoundsLocal; + + public Bounds Bounds { get; set; } + + public override Bounds GetBounds() + { + return Bounds; + } + + public override Bounds GetBounds(CombinedMeshPart part) + { + return _partsBounds[part.Index]; + } + + public void ApplyDataToMesh() + { + Mesh mesh = _root.Mesh; + mesh.SetVertices(_vertices); + mesh.SetNormals(_normals); + mesh.SetTangents(_tangents); + mesh.bounds = Bounds; + } + + protected override void OnInitialized() + { + _root = base.Root; + _vertices = new List<Vector3>(); + _normals = new List<Vector3>(); + _tangents = new List<Vector4>(); + _partsBounds = new List<Bounds>(); + _partsBoundsLocal = new List<Bounds>(); + } + + protected override void OnAddPart(CombinedMeshPart part, Mesh mesh, Matrix4x4 transform) + { + Bounds bounds = mesh.bounds; + Bounds item = bounds.Transform(transform); + _partsBounds.Add(item); + _partsBoundsLocal.Add(bounds); + } + + protected override void OnRemovePart(CombinedMeshPart part) + { + _partsBounds.RemoveAt(part.Index); + _partsBoundsLocal.RemoveAt(part.Index); + } + + protected override void OnMeshUpdated() + { + Mesh mesh = _root.Mesh; + mesh.GetVertices(_vertices); + mesh.GetNormals(_normals); + mesh.GetTangents(_tangents); + Bounds = mesh.bounds; + } +} |
