summaryrefslogtreecommitdiff
path: root/Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataNativeArraysLW.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-19 17:03:57 +0800
committerchai <215380520@qq.com>2024-05-19 17:03:57 +0800
commitcf58771365b5953c6eac548b172aae880d1f0acd (patch)
treea49757a4b5c447cbf877584d482367a6bfe33b10 /Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataNativeArraysLW.cs
parenteed315deae356ddfb17f28305e7cde6cdfc43313 (diff)
* rename
Diffstat (limited to 'Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataNativeArraysLW.cs')
-rw-r--r--Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataNativeArraysLW.cs131
1 files changed, 0 insertions, 131 deletions
diff --git a/Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataNativeArraysLW.cs b/Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataNativeArraysLW.cs
deleted file mode 100644
index 939d022..0000000
--- a/Thronefall_1_57/Decompile/NGS.MeshFusionPro/MeshDataNativeArraysLW.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-using System.Collections.Generic;
-using Unity.Collections;
-using UnityEngine;
-
-namespace NGS.MeshFusionPro;
-
-public class MeshDataNativeArraysLW : CombinedMeshDataInternal
-{
- private CombinedMesh _root;
-
- private NativeList<LightweightVertex> _vertices;
-
- private NativeList<Bounds> _partsBounds;
-
- private NativeArray<Bounds> _bounds;
-
- private NativeList<LightweightVertex> _verticesLocal;
-
- private NativeList<Bounds> _partsBoundsLocal;
-
- private List<Vector3> _tempVertices;
-
- private List<Vector3> _tempNormals;
-
- private List<Vector4> _tempTangents;
-
- private List<Vector2> _tempUV;
-
- private List<Vector2> _tempUV2;
-
- public NativeArray<LightweightVertex> Vertices => _vertices;
-
- public NativeArray<Bounds> PartsBounds => _partsBounds;
-
- public NativeArray<Bounds> Bounds => _bounds;
-
- public NativeArray<LightweightVertex> VerticesLocal => _verticesLocal;
-
- public NativeArray<Bounds> PartsBoundsLocal => _partsBoundsLocal;
-
- public override Bounds GetBounds()
- {
- return _bounds[0];
- }
-
- public override Bounds GetBounds(CombinedMeshPart part)
- {
- return _partsBounds[part.Index];
- }
-
- public void ApplyDataToMesh()
- {
- Mesh mesh = _root.Mesh;
- mesh.SetVertexBufferData(Vertices, 0, 0, _vertices.Length);
- mesh.bounds = _bounds[0];
- }
-
- protected override void OnInitialized()
- {
- _root = base.Root;
- VertexBufferUtil.ToLightweightBuffer(_root.Mesh);
- _vertices = new NativeList<LightweightVertex>(Allocator.Persistent);
- _partsBounds = new NativeList<Bounds>(Allocator.Persistent);
- _bounds = new NativeArray<Bounds>(1, Allocator.Persistent);
- _verticesLocal = new NativeList<LightweightVertex>(Allocator.Persistent);
- _partsBoundsLocal = new NativeList<Bounds>(Allocator.Persistent);
- _tempVertices = new List<Vector3>();
- _tempNormals = new List<Vector3>();
- _tempTangents = new List<Vector4>();
- _tempUV = new List<Vector2>();
- _tempUV2 = new List<Vector2>();
- }
-
- protected override void OnAddPart(CombinedMeshPart part, Mesh mesh, Matrix4x4 transform)
- {
- Bounds value = mesh.bounds;
- Bounds value2 = value.Transform(transform);
- _partsBounds.Add(in value2);
- _partsBoundsLocal.Add(in value);
- mesh.GetVertices(_tempVertices);
- mesh.GetNormals(_tempNormals);
- mesh.GetTangents(_tempTangents);
- mesh.GetUVs(0, _tempUV);
- mesh.GetUVs(1, _tempUV2);
- int vertexCount = mesh.vertexCount;
- for (int i = 0; i < vertexCount; i++)
- {
- LightweightVertex value3 = default(LightweightVertex);
- value3.Position = _tempVertices[i];
- value3.Normal = _tempNormals[i];
- value3.Tangent = _tempTangents[i];
- if (_tempUV.Count > 0)
- {
- value3.UV = _tempUV[i];
- }
- if (_tempUV2.Count > 0)
- {
- value3.UV2 = _tempUV2[i];
- }
- _verticesLocal.Add(in value3);
- }
- }
-
- protected override void OnRemovePart(CombinedMeshPart part)
- {
- _partsBounds.RemoveAt(part.Index);
- _verticesLocal.RemoveRange(part.VertexStart, part.VertexCount);
- _partsBoundsLocal.RemoveAt(part.Index);
- }
-
- protected override void OnMeshUpdated()
- {
- Mesh mesh = _root.Mesh;
- using (Mesh.MeshDataArray meshDataArray = Mesh.AcquireReadOnlyMeshData(mesh))
- {
- Mesh.MeshData meshData = meshDataArray[0];
- _vertices.Clear();
- _vertices.AddRange(meshData.GetVertexData<LightweightVertex>());
- }
- _bounds[0] = mesh.bounds;
- }
-
- protected override void OnDispose()
- {
- _vertices.Dispose();
- _partsBounds.Dispose();
- _bounds.Dispose();
- _verticesLocal.Dispose();
- _partsBoundsLocal.Dispose();
- }
-}