Skip to content

Commit fafbb69

Browse files
committed
Release IndexBuffer on destroy. Separate VParticle definition to GPUVoxelParticle file.
1 parent ca6c1f9 commit fafbb69

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace VoxelSystem.Demo
6+
{
7+
8+
public struct VParticle_t
9+
{
10+
public Vector3 position;
11+
public Vector3 size;
12+
public Quaternion rotation;
13+
public Vector3 velocity;
14+
public float speed;
15+
};
16+
17+
}
18+
19+

Assets/Packages/Voxelizer/Demo/Scripts/GPUVoxelParticle.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Packages/Voxelizer/Demo/Scripts/GPUVoxelParticleSystem.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,11 @@
1010
namespace VoxelSystem.Demo
1111
{
1212

13-
public struct VParticle_t
14-
{
15-
public Vector3 position;
16-
public Vector3 size;
17-
public Quaternion rotation;
18-
public Vector3 velocity;
19-
public float speed;
20-
};
21-
2213
public class GPUVoxelParticleSystem : MonoBehaviour {
2314

24-
[SerializeField] protected Mesh mesh;
25-
[SerializeField] protected ComputeShader voxelizer, particleUpdate;
26-
[SerializeField] protected int count = 64;
15+
[SerializeField] protected Mesh mesh;
16+
[SerializeField] protected ComputeShader voxelizer, particleUpdate;
17+
[SerializeField] protected int count = 64;
2718

2819
#region Particle properties
2920

@@ -118,6 +109,12 @@ void OnDestroy ()
118109
particleBuffer.Release();
119110
particleBuffer = null;
120111
}
112+
113+
if(indexBuffer != null)
114+
{
115+
indexBuffer.Release();
116+
indexBuffer = null;
117+
}
121118
}
122119

123120
void OnRenderObject()

0 commit comments

Comments
 (0)