Skip to content

Commit

Permalink
native collection alllocation moved from Awake() to (field) constru…
Browse files Browse the repository at this point in the history
…ctor
  • Loading branch information
andrew-raphael-lukasik committed Oct 2, 2022
1 parent 121a594 commit 2e3f2f7
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions Assets/Scripts/Internal/DaggerfallBillboardBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public class DaggerfallBillboardBatch : MonoBehaviour
[SerializeField, HideInInspector]
Mesh billboardMesh;

NativeList<BillboardItem> billboardData;
NativeArray<float3> meshVertices;
NativeArray<float3> meshNormals;
NativeArray<ushort> meshIndices;
NativeArray<float4> meshTangents;
NativeArray<float2> meshUVs;
NativeArray<Bounds> meshAABB;
NativeList<BillboardItem> billboardData = new NativeList<BillboardItem>(initialCapacity: maxBillboardCount, Allocator.Persistent);
NativeArray<float3> meshVertices = new NativeArray<float3>(0, Allocator.Persistent);
NativeArray<float3> meshNormals = new NativeArray<float3>(0, Allocator.Persistent);
NativeArray<ushort> meshIndices = new NativeArray<ushort>(0, Allocator.Persistent);
NativeArray<float4> meshTangents = new NativeArray<float4>(0, Allocator.Persistent);
NativeArray<float2> meshUVs = new NativeArray<float2>(0, Allocator.Persistent);
NativeArray<Bounds> meshAABB = new NativeArray<Bounds>(1, Allocator.Persistent);
JobHandle Dependency;
JobHandle UvAnimationDependency;

Expand Down Expand Up @@ -131,17 +131,6 @@ static readonly ProfilerMarker

#endregion

void Awake()
{
billboardData = new NativeList<BillboardItem>(initialCapacity: maxBillboardCount, Allocator.Persistent);
meshVertices = new NativeArray<float3>(0, Allocator.Persistent);
meshNormals = new NativeArray<float3>(0, Allocator.Persistent);
meshIndices = new NativeArray<ushort>(0, Allocator.Persistent);
meshTangents = new NativeArray<float4>(0, Allocator.Persistent);
meshUVs = new NativeArray<float2>(0, Allocator.Persistent);
meshAABB = new NativeArray<Bounds>(1, Allocator.Persistent);
}

void OnDestroy()
{
// make sure there are no unfinished jobs:
Expand Down

0 comments on commit 2e3f2f7

Please sign in to comment.