Init
This commit is contained in:
34
Assets/Script/Buffers.cs
Normal file
34
Assets/Script/Buffers.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
|
||||
public static class Buffers
|
||||
{
|
||||
public static ComputeBuffer pointsBuffer;
|
||||
public static ComputeBuffer triangleBuffer;
|
||||
public static ComputeBuffer triCountBuffer;
|
||||
|
||||
public static void Create(int numPointsPerAxis)
|
||||
{
|
||||
Release();
|
||||
int numPoints = numPointsPerAxis * numPointsPerAxis * numPointsPerAxis;
|
||||
int numVoxelsPerAxis = numPointsPerAxis - 1;
|
||||
int numVoxels = numVoxelsPerAxis * numVoxelsPerAxis * numVoxelsPerAxis;
|
||||
int maxTriangleCount = numVoxels * 5;
|
||||
|
||||
|
||||
triangleBuffer = new ComputeBuffer (maxTriangleCount, sizeof (float) * 3 * 3, ComputeBufferType.Append);
|
||||
pointsBuffer = new ComputeBuffer (numPoints, sizeof (float) * 4);
|
||||
triCountBuffer = new ComputeBuffer (1, sizeof (int), ComputeBufferType.Raw);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void Release()
|
||||
{
|
||||
if (triangleBuffer != null)
|
||||
{
|
||||
triangleBuffer.Release();
|
||||
pointsBuffer.Release();
|
||||
triCountBuffer.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user