aboutsummaryrefslogtreecommitdiff
path: root/examples/UnityExample/Assets/Plugins
diff options
context:
space:
mode:
authorBryan Galdrikian <[email protected]>2018-05-31 11:36:08 -0700
committerBryan Galdrikian <[email protected]>2018-05-31 11:36:08 -0700
commit7115f60b91b5717d90f643fd692010905c7004db (patch)
treeeffd68c6978751c517d54c2f2bb5bb6e7dc93e18 /examples/UnityExample/Assets/Plugins
parentUpdating BlastTool zip (diff)
downloadblast-1.1.3_rc1.tar.xz
blast-1.1.3_rc1.zip
Blast 1.1.3. See docs/release_notes.txt.v1.1.3_rc1
Diffstat (limited to 'examples/UnityExample/Assets/Plugins')
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast.meta18
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs82
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs.meta24
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs40
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs.meta24
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs1174
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs.meta24
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/x64.meta18
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dllbin239616 -> 239616 bytes
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll.meta136
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dllbin54272 -> 54272 bytes
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll.meta108
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dllbin61952 -> 61952 bytes
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll.meta136
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dllbin99328 -> 99328 bytes
-rwxr-xr-x[-rw-r--r--]examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll.meta108
16 files changed, 946 insertions, 946 deletions
diff --git a/examples/UnityExample/Assets/Plugins/Blast.meta b/examples/UnityExample/Assets/Plugins/Blast.meta
index 2413c51..8958724 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast.meta
+++ b/examples/UnityExample/Assets/Plugins/Blast.meta
@@ -1,9 +1,9 @@
-fileFormatVersion: 2
-guid: ba11cec7e53a49943b7e620c809850c9
-folderAsset: yes
-timeCreated: 1483018139
-licenseType: Free
-DefaultImporter:
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: ba11cec7e53a49943b7e620c809850c9
+folderAsset: yes
+timeCreated: 1483018139
+licenseType: Free
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs
index 68b311d..21e208c 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs
+++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs
@@ -1,42 +1,42 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using UnityEngine;
-
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastExtRadialDamageDesc
-{
- public float compressive; //!< compressive (radial) damage component
- public float p0;
- public float p1;
- public float p2;
- public float minRadius; //!< inner radius of damage action
- public float maxRadius; //!< outer radius of damage action
-};
-
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastExtMaterial
-{
- public float singleChunkThreshold; //!< subsupport chunks only take damage surpassing this value
- public float graphChunkThreshold; //!< support chunks only take damage surpassing this value
- public float bondTangentialThreshold; //!< bond only take damage surpassing this value
- public float bondNormalThreshold; //!< currently unused - forward damage propagation
- public float damageAttenuation; //!< factor of damage attenuation while forwarding
-};
-
-
-public static class NvBlastExtShadersWrapper
-{
- public const string DLL_NAME = "NvBlastExtShaders" + NvBlastWrapper.DLL_POSTFIX + "_" + NvBlastWrapper.DLL_PLATFORM;
-
- #region Dll
- [DllImport(DLL_NAME)]
- private static extern bool NvBlastExtDamageActorRadialFalloff(IntPtr actor, NvBlastFractureBuffers buffers, NvBlastExtRadialDamageDesc damageDescBuffer, UInt32 damageDescCount, NvBlastExtMaterial material, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers);
- #endregion
-
- public static bool DamageRadialFalloff(this NvBlastActor actor, NvBlastFractureBuffers buffers, NvBlastExtRadialDamageDesc damageDescBuffer, UInt32 damageDescCount, NvBlastExtMaterial material)
- {
- return NvBlastExtDamageActorRadialFalloff(actor.ptr, buffers, damageDescBuffer, damageDescCount, material, NvBlastWrapper.Log, null);
- }
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using UnityEngine;
+
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastExtRadialDamageDesc
+{
+ public float compressive; //!< compressive (radial) damage component
+ public float p0;
+ public float p1;
+ public float p2;
+ public float minRadius; //!< inner radius of damage action
+ public float maxRadius; //!< outer radius of damage action
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastExtMaterial
+{
+ public float singleChunkThreshold; //!< subsupport chunks only take damage surpassing this value
+ public float graphChunkThreshold; //!< support chunks only take damage surpassing this value
+ public float bondTangentialThreshold; //!< bond only take damage surpassing this value
+ public float bondNormalThreshold; //!< currently unused - forward damage propagation
+ public float damageAttenuation; //!< factor of damage attenuation while forwarding
+};
+
+
+public static class NvBlastExtShadersWrapper
+{
+ public const string DLL_NAME = "NvBlastExtShaders" + NvBlastWrapper.DLL_POSTFIX + "_" + NvBlastWrapper.DLL_PLATFORM;
+
+ #region Dll
+ [DllImport(DLL_NAME)]
+ private static extern bool NvBlastExtDamageActorRadialFalloff(IntPtr actor, NvBlastFractureBuffers buffers, NvBlastExtRadialDamageDesc damageDescBuffer, UInt32 damageDescCount, NvBlastExtMaterial material, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers);
+ #endregion
+
+ public static bool DamageRadialFalloff(this NvBlastActor actor, NvBlastFractureBuffers buffers, NvBlastExtRadialDamageDesc damageDescBuffer, UInt32 damageDescCount, NvBlastExtMaterial material)
+ {
+ return NvBlastExtDamageActorRadialFalloff(actor.ptr, buffers, damageDescBuffer, damageDescCount, material, NvBlastWrapper.Log, null);
+ }
} \ No newline at end of file
diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs.meta b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs.meta
index edf8ac2..d4ad7e2 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs.meta
+++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs.meta
@@ -1,12 +1,12 @@
-fileFormatVersion: 2
-guid: 47339a6d798176c41969193e9b3ecb30
-timeCreated: 1481725762
-licenseType: Free
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: 47339a6d798176c41969193e9b3ecb30
+timeCreated: 1481725762
+licenseType: Free
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs
index 8f81a2e..94ca399 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs
+++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs
@@ -1,21 +1,21 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using UnityEngine;
-
-
-public static class NvBlastExtUtilsWrapper
-{
- public const string DLL_NAME = "NvBlastExtUtils" + NvBlastWrapper.DLL_POSTFIX + "_" + NvBlastWrapper.DLL_PLATFORM;
-
- #region Dll
- [DllImport(DLL_NAME)]
- private static extern void NvBlastReorderAssetDescChunks([In, Out] NvBlastChunkDesc[] chunkDescs, uint chunkCount, [In, Out] NvBlastBondDesc[] bondDescs, uint bondCount, [In, Out] uint[] chunkReorderMap);
- #endregion
-
- public static void ReorderAssetDescChunks(NvBlastAssetDesc assetDesc, uint[] chunkReorderMap)
- {
- NvBlastReorderAssetDescChunks(assetDesc.chunkDescs, assetDesc.chunkCount, assetDesc.bondDescs, assetDesc.bondCount, chunkReorderMap);
- }
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using UnityEngine;
+
+
+public static class NvBlastExtUtilsWrapper
+{
+ public const string DLL_NAME = "NvBlastExtUtils" + NvBlastWrapper.DLL_POSTFIX + "_" + NvBlastWrapper.DLL_PLATFORM;
+
+ #region Dll
+ [DllImport(DLL_NAME)]
+ private static extern void NvBlastReorderAssetDescChunks([In, Out] NvBlastChunkDesc[] chunkDescs, uint chunkCount, [In, Out] NvBlastBondDesc[] bondDescs, uint bondCount, [In, Out] uint[] chunkReorderMap);
+ #endregion
+
+ public static void ReorderAssetDescChunks(NvBlastAssetDesc assetDesc, uint[] chunkReorderMap)
+ {
+ NvBlastReorderAssetDescChunks(assetDesc.chunkDescs, assetDesc.chunkCount, assetDesc.bondDescs, assetDesc.bondCount, chunkReorderMap);
+ }
} \ No newline at end of file
diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs.meta b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs.meta
index caf4278..5e49418 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs.meta
+++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs.meta
@@ -1,12 +1,12 @@
-fileFormatVersion: 2
-guid: 79da9e4b8c3adf543b406ce704084d62
-timeCreated: 1481725762
-licenseType: Free
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: 79da9e4b8c3adf543b406ce704084d62
+timeCreated: 1481725762
+licenseType: Free
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs b/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs
index ccda6c4..13822f8 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs
+++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs
@@ -1,587 +1,587 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using UnityEngine;
-using UnityEngine.Assertions;
-
-public struct NvBlastChunkDesc
-{
- public enum Flags
- {
- NoFlags = 0,
- SupportFlag = (1 << 0)
- };
-
- /** Central position in chunk. */
- public Single c0;
- public Single c1;
- public Single c2;
-
-
- /** Volume of chunk. */
- public Single volume;
-
- /** Index of this chunk's parent. If this is a root chunk, then this value must be UINT32_MAX. */
- public UInt32 parentChunkIndex;
-
- /** See Flags enum for possible flags. */
- public UInt32 flags;
-
- /** User-supplied data which will be accessible to the user in chunk fracture events. */
- public UInt32 userData;
-}
-
-public struct NvBlastBond
-{
- public Single n0;
- public Single n1;
- public Single n2;
-
- public Single area;
-
- public Single c0;
- public Single c1;
- public Single c2;
-
- UInt32 userData;
-};
-
-public struct NvBlastBondDesc
-{
- /** The indices of the chunks linked by this bond. They must be different support chunk indices. */
- public UInt32 chunk0;
- public UInt32 chunk1;
-
- /** Bond data (see NvBlastBond). */
- public NvBlastBond bond;
-}
-
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastAssetDesc
-{
- public UInt32 chunkCount;
- public NvBlastChunkDesc[] chunkDescs;
- public UInt32 bondCount;
- public NvBlastBondDesc[] bondDescs;
-}
-
-/**
-Actor descriptor, used to create an instance of an NvBlastAsset with NvBlastActorCreate
- 6
-See NvBlastActorCreate.
-*/
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastActorDesc
-{
- /**
- Initial health of all bonds, if initialBondHealths is NULL (see initialBondHealths).
- */
- public Single uniformInitialBondHealth;
-
- /**
- Initial bond healths. If not NULL, this array must be of length NvBlastAssetGetChunkCount(asset, ... ).
- If NULL, uniformInitialBondHealth must be set.
- */
- public Single[] initialBondHealths = null;
-
- /**
- Initial health of all lower-support chunks, if initialSupportChunkHealths is NULL (see initialSupportChunkHealths).
- */
- public Single uniformInitialLowerSupportChunkHealth;
-
- /**
- Initial health of all support chunks. If not NULL, this must be of length
- NvBlastAssetGetSupportGraph(asset, ... ).nodeCount. The elements in the initialSupportChunkHealth
- array will correspond to the chunk indices in the NvBlastAssetGetSupportGraph(asset, ... ).chunkIndices
- array. Every descendent of a support chunk will have its health initialized to its ancestor support
- chunk's health, so this initializes all lower-support chunk healths.
- If NULL, uniformInitialLowerSupportChunkHealth must be set.
- */
- public Single[] initialSupportChunkHealths = null;
-};
-
-
-public struct NvBlastChunk
-{
- /**
- Central position for the chunk's volume
- */
- public Single c0;
- public Single c1;
- public Single c2;
-
- /**
- Volume of the chunk
- */
- public Single volume;
-
- /**
- Index of parent (UINT32_MAX denotes no parent)
- */
- public UInt32 parentChunkIndex;
-
- /**
- Index of first child
- */
- public UInt32 firstChildIndex;
-
- /**
- Stop for child indices
- */
- public UInt32 childIndexStop;
-
- /**
- Field for user to associate with external data
- */
- public UInt32 userData;
-};
-
-public struct NvBlastChunkGraph
-{
- UInt32 nodeCount;
- public IntPtr chunkIndices;
- public IntPtr adjacencyPartition;
- public IntPtr adjacentNodeIndices;
- public IntPtr adjacentBondIndices;
-};
-
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastTimers
-{
- public Int64 material; //!< Time spent in material function
- public Int64 fracture; //!< Time spent applying damage
- public Int64 island; //!< Time spent discovering islands
- public Int64 partition; //!< Time spent partitioning the graph
- public Int64 visibility; //!< Time spent updating visibility
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-// Types used for damage and fracturing
-///////////////////////////////////////////////////////////////////////////////
-
-public struct NvBlastChunkFractureData
-{
- public UInt32 userdata; //!< chunk's user data
- public UInt32 chunkIndex; //!< asset chunk index
- public Single health; //!< health value (damage or remains)
-};
-
-public struct NvBlastBondFractureData
-{
- public UInt32 userdata; //!< bond's user data
- public UInt32 nodeIndex0; //!< graph node index of bond
- public UInt32 nodeIndex1; //!< pair graph node index of bond
- public Single health; //!< health value (damage or remains)
-};
-
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastFractureBuffers
-{
- public UInt32 bondFractureCount;
- public UInt32 chunkFractureCount;
- public IntPtr bondFractures; // NvBlastBondFractureData[]
- public IntPtr chunkFractures; // NvBlastChunkFractureData[]
-};
-
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastActorSplitEvent
-{
- public IntPtr deletedActor; //!< deleted actor or nullptr if actor has not changed
- public IntPtr newActors; //!< list of created actors
-};
-
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastGraphShaderActor
-{
- UInt32 firstGraphNodeIndex; //<! Entry index for graphNodeIndexLinks
- public UInt32[] graphNodeIndexLinks; //<! Linked index list of connected nodes. Traversable with nextIndex = graphNodeIndexLinks[currentIndex], terminates with 0xFFFFFFFF.
- public UInt32[] chunkIndices; //<! Graph's map from node index to support chunk index.
- public UInt32[] adjacencyPartition; //<! See NvBlastChunkGraph::adjacencyPartition.
- public UInt32[] adjacentNodeIndices; //<! See NvBlastChunkGraph::adjacentNodeIndices.
- public UInt32[] adjacentBondIndices; //<! See NvBlastChunkGraph::adjacentBondIndices.
- public NvBlastBond[] assetBonds; //<! NvBlastBonds geometry in the NvBlastAsset.
- public Single[] familyBondHealths; //<! Actual bond health values for broken bond detection.
-};
-
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastProgramParams
-{
- public IntPtr damageDescBuffer; //!< array of damage descriptions
- public UInt32 damageDescCount; //!< number of damage descriptions in array
- public IntPtr material; //!< pointer to material
-};
-
-[StructLayout(LayoutKind.Sequential)]
-public class NvBlastSubgraphShaderActor
-{
- public UInt32 chunkIndex; //<! Index of chunk represented by this actor.
- public NvBlastChunk[] assetChunks; //<! NvBlastChunks geometry in the NvBlastAsset.
-};
-
-public struct NvBlastDamageProgram
-{
- public delegate void NvBlastGraphShaderFunction(System.IntPtr commandBuffers, System.IntPtr actor, System.IntPtr p);
- public delegate void NvBlastSubgraphShaderFunction(NvBlastFractureBuffers commandBuffers, NvBlastSubgraphShaderActor actor, NvBlastProgramParams p);
-
- public NvBlastGraphShaderFunction graphShaderFunction;
- public NvBlastSubgraphShaderFunction subgraphShaderFunction;
-};
-
-
-public class NvBlastWrapper
-{
- //////// DLL ////////
-
- public const string DLL_POSTFIX = "DEBUG"; //DEBUG
- public const string DLL_PLATFORM = "x64";
- public const string DLL_NAME = "NvBlast" + DLL_POSTFIX + "_" + DLL_PLATFORM;
-
-
- //////// Internal Types ////////
-
- public delegate IntPtr NvBlastAlloc(Int64 size);
- public delegate void NvBlastFree(IntPtr ptr);
- public delegate void NvBlastLog(Int32 type, string msg, string file, Int32 line);
-
-
- //////// Public Types ////////
-
-
-
- //////// Helpers ////////
-
- public static IntPtr Alloc(Int64 size)
- {
- return Marshal.AllocHGlobal((Int32)size);
- }
-
- public static void Free(IntPtr ptr)
- {
- Marshal.FreeHGlobal(ptr);
- }
-
- public static void Log(Int32 type, string msg, string file, Int32 line)
- {
- Debug.Log(DLL_NAME + ": [" + type + "] " + msg + "(" + file + ":" + line + ")");
- }
-
- public static IntPtr GetScratch(int size)
- {
- return _greedyScratch.GetScratch(size);
- }
-
- private static GreedyScratch _greedyScratch = new GreedyScratch();
-}
-
-
-public class GreedyScratch : IDisposable
-{
- public IntPtr GetScratch(int size)
- {
- if (_size < size)
- {
- releaseScratch();
- _scratch = Marshal.AllocHGlobal(size);
- _size = size;
- }
-
- return _scratch;
- }
-
- private void releaseScratch()
- {
- if (_size > 0)
- {
- Marshal.FreeHGlobal(_scratch);
- _scratch = IntPtr.Zero;
- }
- }
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool bDisposing)
- {
- releaseScratch();
-
- if (bDisposing)
- {
- GC.SuppressFinalize(this);
- }
- }
-
- ~GreedyScratch()
- {
- Dispose(false);
- }
-
- private int _size = 0;
- private IntPtr _scratch = IntPtr.Zero;
-}
-
-
-public abstract class DisposablePtr : IDisposable
-{
- protected void Initialize(IntPtr ptr)
- {
- Assert.IsTrue(this._ptr == IntPtr.Zero);
- this._ptr = ptr;
- }
-
- protected void ResetPtr()
- {
- this._ptr = IntPtr.Zero;
- }
-
- protected abstract void Release();
-
- public IntPtr ptr
- {
- get { return _ptr; }
- }
-
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool bDisposing)
- {
- if (_ptr != IntPtr.Zero)
- {
- Release();
- _ptr = IntPtr.Zero;
- }
-
- if (bDisposing)
- {
- GC.SuppressFinalize(this);
- }
- }
-
- ~DisposablePtr()
- {
- Dispose(false);
- }
-
- private IntPtr _ptr = IntPtr.Zero;
-}
-
-
-public class NvBlastAsset : DisposablePtr
-{
- #region Dll
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern UInt64 NvBlastAssetCreateRequiredScratch(NvBlastAssetDesc desc);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern IntPtr NvBlastAssetCreate(NvBlastAssetDesc desc, NvBlastWrapper.NvBlastAlloc allocFn, IntPtr scratch, NvBlastWrapper.NvBlastLog logFn);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern void NvBlastAssetRelease(IntPtr asset, NvBlastWrapper.NvBlastFree freeFn, NvBlastWrapper.NvBlastLog logFn);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern UInt32 NvBlastAssetGetLeafChunkCount(IntPtr asset, NvBlastWrapper.NvBlastLog logFn);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern NvBlastChunkGraph NvBlastAssetGetSupportGraph(IntPtr asset, NvBlastWrapper.NvBlastLog logFn);
- #endregion
-
- public NvBlastAsset(NvBlastAssetDesc desc)
- {
- var scratchSize = NvBlastAssetCreateRequiredScratch(desc);
- var asset = NvBlastAssetCreate(desc, NvBlastWrapper.Alloc, NvBlastWrapper.GetScratch((int)scratchSize), NvBlastWrapper.Log);
- Initialize(asset);
- }
-
- protected override void Release()
- {
- NvBlastAssetRelease(ptr, NvBlastWrapper.Free, NvBlastWrapper.Log);
- }
-
- public UInt32 leafChunkCount
- {
- get
- {
- return NvBlastAssetGetLeafChunkCount(ptr, NvBlastWrapper.Log);
- }
- }
-
- public NvBlastChunkGraph chunkGraph
- {
- get
- {
- if (!_graph.HasValue)
- {
- _graph = NvBlastAssetGetSupportGraph(ptr, NvBlastWrapper.Log);
- }
- return _graph.Value;
- }
- }
-
- private NvBlastChunkGraph? _graph = null;
-}
-
-
-public class NvBlastFamily : DisposablePtr
-{
- #region Dll
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern IntPtr NvBlastFamilyCreate(IntPtr asset, NvBlastWrapper.NvBlastAlloc allocFn, NvBlastWrapper.NvBlastLog logFn);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern void NvBlastFamilyRelease(IntPtr family, NvBlastWrapper.NvBlastFree freeFn, NvBlastWrapper.NvBlastLog logFn);
- #endregion
-
- public NvBlastAsset asset
- {
- get;
- private set;
- }
-
- public NvBlastFamily(NvBlastAsset asset_)
- {
- asset = asset_;
- var family = NvBlastFamilyCreate(asset.ptr, NvBlastWrapper.Alloc, NvBlastWrapper.Log);
- Initialize(family);
- }
-
- protected override void Release()
- {
- NvBlastFamilyRelease(ptr, NvBlastWrapper.Free, NvBlastWrapper.Log);
- }
-}
-
-
-public class NvBlastActor : DisposablePtr
-{
- #region Dll
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern UInt64 NvBlastActorCreateRequiredScratch(IntPtr asset);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern IntPtr NvBlastActorCreate(IntPtr family, NvBlastActorDesc desc, IntPtr scratch, NvBlastWrapper.NvBlastLog logFn);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern void NvBlastActorRelease(IntPtr actor);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern UInt32 NvBlastActorGetVisibleChunkCount(IntPtr actor, NvBlastWrapper.NvBlastLog logFn);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern UInt32 NvBlastActorGetVisibleChunkIndices([In, Out] UInt32[] visibleChunkIndices, UInt32 visibleChunkIndicesSize, IntPtr actor, NvBlastWrapper.NvBlastLog logFn);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern UInt32 NvBlastActorGetGraphNodeCount(IntPtr actor, NvBlastWrapper.NvBlastLog logFn);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern UInt32 NvBlastActorGetGraphNodeIndices([In, Out] UInt32[] graphNodeIndices, UInt32 graphNodeIndicesSize, IntPtr actor, NvBlastWrapper.NvBlastLog logFn);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern void NvBlastActorGenerateFracture(NvBlastFractureBuffers commandBuffers, IntPtr actor, NvBlastDamageProgram program, NvBlastProgramParams programParams, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern void NvBlastActorApplyFracture(IntPtr eventBuffers, IntPtr actor, NvBlastFractureBuffers commands, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern UInt64 NvBlastActorSplitRequiredScratch(IntPtr actor);
-
- [DllImport(NvBlastWrapper.DLL_NAME)]
- static extern UInt32 NvBlastActorSplit([In, Out] NvBlastActorSplitEvent result, UInt32 newActorsMaxCount, IntPtr actor, IntPtr scratch, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers);
- #endregion
-
- public NvBlastFamily family
- {
- get;
- private set;
- }
-
- public object userData = null;
-
- public NvBlastActor(NvBlastFamily family_, NvBlastActorDesc desc)
- {
- family = family_;
-
- var scratchSize = NvBlastActorCreateRequiredScratch(family_.asset.ptr);
- var actor = NvBlastActorCreate(family.ptr, desc, NvBlastWrapper.GetScratch((int)scratchSize), NvBlastWrapper.Log);
- Initialize(actor);
- }
-
- public NvBlastActor(NvBlastFamily family_, IntPtr ptr)
- {
- family = family_;
-
- Initialize(ptr);
- }
-
- protected override void Release()
- {
- NvBlastActorRelease(ptr);
- }
-
- public UInt32 visibleChunkCount
- {
- get { return NvBlastActorGetVisibleChunkCount(ptr, NvBlastWrapper.Log); }
- }
-
- public UInt32[] visibleChunkIndices
- {
- get
- {
- if(_visibleChunkIndices == null)
- {
- _visibleChunkIndices = new UInt32[visibleChunkCount];
- NvBlastActorGetVisibleChunkIndices(_visibleChunkIndices, visibleChunkCount, ptr, NvBlastWrapper.Log);
- }
- return _visibleChunkIndices;
- }
- }
-
- public UInt32 graphNodeCount
- {
- get { return NvBlastActorGetGraphNodeCount(ptr, NvBlastWrapper.Log); }
- }
-
- public UInt32[] graphNodeIndices
- {
- get
- {
- if (_graphNodeIndices == null)
- {
- _graphNodeIndices = new UInt32[graphNodeCount];
- NvBlastActorGetGraphNodeIndices(_graphNodeIndices, graphNodeCount, ptr, NvBlastWrapper.Log);
- }
- return _graphNodeIndices;
- }
- }
-
- public void GenerateFracture(NvBlastFractureBuffers buffers, NvBlastDamageProgram program, NvBlastProgramParams programParams)
- {
- NvBlastActorGenerateFracture(buffers, ptr, program, programParams, NvBlastWrapper.Log, null);
- }
-
- public void ApplyFracture(NvBlastFractureBuffers commands)
- {
- NvBlastActorApplyFracture(IntPtr.Zero, ptr, commands, NvBlastWrapper.Log, null);
- }
-
- public UInt32 Split(NvBlastActorSplitEvent result, UInt32 newActorsMaxCount)
- {
- var scratchSize = NvBlastActorSplitRequiredScratch(ptr);
- UInt32 newActorsCount = NvBlastActorSplit(result, newActorsMaxCount, ptr, NvBlastWrapper.GetScratch((int)scratchSize), NvBlastWrapper.Log, null);
- if(result.deletedActor != IntPtr.Zero)
- {
- ResetPtr();
- }
- return newActorsCount;
- }
-
- private UInt32[] _visibleChunkIndices = null;
- private UInt32[] _graphNodeIndices = null;
-}
-
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using UnityEngine;
+using UnityEngine.Assertions;
+
+public struct NvBlastChunkDesc
+{
+ public enum Flags
+ {
+ NoFlags = 0,
+ SupportFlag = (1 << 0)
+ };
+
+ /** Central position in chunk. */
+ public Single c0;
+ public Single c1;
+ public Single c2;
+
+
+ /** Volume of chunk. */
+ public Single volume;
+
+ /** Index of this chunk's parent. If this is a root chunk, then this value must be UINT32_MAX. */
+ public UInt32 parentChunkIndex;
+
+ /** See Flags enum for possible flags. */
+ public UInt32 flags;
+
+ /** User-supplied data which will be accessible to the user in chunk fracture events. */
+ public UInt32 userData;
+}
+
+public struct NvBlastBond
+{
+ public Single n0;
+ public Single n1;
+ public Single n2;
+
+ public Single area;
+
+ public Single c0;
+ public Single c1;
+ public Single c2;
+
+ UInt32 userData;
+};
+
+public struct NvBlastBondDesc
+{
+ /** The indices of the chunks linked by this bond. They must be different support chunk indices. */
+ public UInt32 chunk0;
+ public UInt32 chunk1;
+
+ /** Bond data (see NvBlastBond). */
+ public NvBlastBond bond;
+}
+
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastAssetDesc
+{
+ public UInt32 chunkCount;
+ public NvBlastChunkDesc[] chunkDescs;
+ public UInt32 bondCount;
+ public NvBlastBondDesc[] bondDescs;
+}
+
+/**
+Actor descriptor, used to create an instance of an NvBlastAsset with NvBlastActorCreate
+ 6
+See NvBlastActorCreate.
+*/
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastActorDesc
+{
+ /**
+ Initial health of all bonds, if initialBondHealths is NULL (see initialBondHealths).
+ */
+ public Single uniformInitialBondHealth;
+
+ /**
+ Initial bond healths. If not NULL, this array must be of length NvBlastAssetGetChunkCount(asset, ... ).
+ If NULL, uniformInitialBondHealth must be set.
+ */
+ public Single[] initialBondHealths = null;
+
+ /**
+ Initial health of all lower-support chunks, if initialSupportChunkHealths is NULL (see initialSupportChunkHealths).
+ */
+ public Single uniformInitialLowerSupportChunkHealth;
+
+ /**
+ Initial health of all support chunks. If not NULL, this must be of length
+ NvBlastAssetGetSupportGraph(asset, ... ).nodeCount. The elements in the initialSupportChunkHealth
+ array will correspond to the chunk indices in the NvBlastAssetGetSupportGraph(asset, ... ).chunkIndices
+ array. Every descendent of a support chunk will have its health initialized to its ancestor support
+ chunk's health, so this initializes all lower-support chunk healths.
+ If NULL, uniformInitialLowerSupportChunkHealth must be set.
+ */
+ public Single[] initialSupportChunkHealths = null;
+};
+
+
+public struct NvBlastChunk
+{
+ /**
+ Central position for the chunk's volume
+ */
+ public Single c0;
+ public Single c1;
+ public Single c2;
+
+ /**
+ Volume of the chunk
+ */
+ public Single volume;
+
+ /**
+ Index of parent (UINT32_MAX denotes no parent)
+ */
+ public UInt32 parentChunkIndex;
+
+ /**
+ Index of first child
+ */
+ public UInt32 firstChildIndex;
+
+ /**
+ Stop for child indices
+ */
+ public UInt32 childIndexStop;
+
+ /**
+ Field for user to associate with external data
+ */
+ public UInt32 userData;
+};
+
+public struct NvBlastChunkGraph
+{
+ UInt32 nodeCount;
+ public IntPtr chunkIndices;
+ public IntPtr adjacencyPartition;
+ public IntPtr adjacentNodeIndices;
+ public IntPtr adjacentBondIndices;
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastTimers
+{
+ public Int64 material; //!< Time spent in material function
+ public Int64 fracture; //!< Time spent applying damage
+ public Int64 island; //!< Time spent discovering islands
+ public Int64 partition; //!< Time spent partitioning the graph
+ public Int64 visibility; //!< Time spent updating visibility
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Types used for damage and fracturing
+///////////////////////////////////////////////////////////////////////////////
+
+public struct NvBlastChunkFractureData
+{
+ public UInt32 userdata; //!< chunk's user data
+ public UInt32 chunkIndex; //!< asset chunk index
+ public Single health; //!< health value (damage or remains)
+};
+
+public struct NvBlastBondFractureData
+{
+ public UInt32 userdata; //!< bond's user data
+ public UInt32 nodeIndex0; //!< graph node index of bond
+ public UInt32 nodeIndex1; //!< pair graph node index of bond
+ public Single health; //!< health value (damage or remains)
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastFractureBuffers
+{
+ public UInt32 bondFractureCount;
+ public UInt32 chunkFractureCount;
+ public IntPtr bondFractures; // NvBlastBondFractureData[]
+ public IntPtr chunkFractures; // NvBlastChunkFractureData[]
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastActorSplitEvent
+{
+ public IntPtr deletedActor; //!< deleted actor or nullptr if actor has not changed
+ public IntPtr newActors; //!< list of created actors
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastGraphShaderActor
+{
+ UInt32 firstGraphNodeIndex; //<! Entry index for graphNodeIndexLinks
+ public UInt32[] graphNodeIndexLinks; //<! Linked index list of connected nodes. Traversable with nextIndex = graphNodeIndexLinks[currentIndex], terminates with 0xFFFFFFFF.
+ public UInt32[] chunkIndices; //<! Graph's map from node index to support chunk index.
+ public UInt32[] adjacencyPartition; //<! See NvBlastChunkGraph::adjacencyPartition.
+ public UInt32[] adjacentNodeIndices; //<! See NvBlastChunkGraph::adjacentNodeIndices.
+ public UInt32[] adjacentBondIndices; //<! See NvBlastChunkGraph::adjacentBondIndices.
+ public NvBlastBond[] assetBonds; //<! NvBlastBonds geometry in the NvBlastAsset.
+ public Single[] familyBondHealths; //<! Actual bond health values for broken bond detection.
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastProgramParams
+{
+ public IntPtr damageDescBuffer; //!< array of damage descriptions
+ public UInt32 damageDescCount; //!< number of damage descriptions in array
+ public IntPtr material; //!< pointer to material
+};
+
+[StructLayout(LayoutKind.Sequential)]
+public class NvBlastSubgraphShaderActor
+{
+ public UInt32 chunkIndex; //<! Index of chunk represented by this actor.
+ public NvBlastChunk[] assetChunks; //<! NvBlastChunks geometry in the NvBlastAsset.
+};
+
+public struct NvBlastDamageProgram
+{
+ public delegate void NvBlastGraphShaderFunction(System.IntPtr commandBuffers, System.IntPtr actor, System.IntPtr p);
+ public delegate void NvBlastSubgraphShaderFunction(NvBlastFractureBuffers commandBuffers, NvBlastSubgraphShaderActor actor, NvBlastProgramParams p);
+
+ public NvBlastGraphShaderFunction graphShaderFunction;
+ public NvBlastSubgraphShaderFunction subgraphShaderFunction;
+};
+
+
+public class NvBlastWrapper
+{
+ //////// DLL ////////
+
+ public const string DLL_POSTFIX = "DEBUG"; //DEBUG
+ public const string DLL_PLATFORM = "x64";
+ public const string DLL_NAME = "NvBlast" + DLL_POSTFIX + "_" + DLL_PLATFORM;
+
+
+ //////// Internal Types ////////
+
+ public delegate IntPtr NvBlastAlloc(Int64 size);
+ public delegate void NvBlastFree(IntPtr ptr);
+ public delegate void NvBlastLog(Int32 type, string msg, string file, Int32 line);
+
+
+ //////// Public Types ////////
+
+
+
+ //////// Helpers ////////
+
+ public static IntPtr Alloc(Int64 size)
+ {
+ return Marshal.AllocHGlobal((Int32)size);
+ }
+
+ public static void Free(IntPtr ptr)
+ {
+ Marshal.FreeHGlobal(ptr);
+ }
+
+ public static void Log(Int32 type, string msg, string file, Int32 line)
+ {
+ Debug.Log(DLL_NAME + ": [" + type + "] " + msg + "(" + file + ":" + line + ")");
+ }
+
+ public static IntPtr GetScratch(int size)
+ {
+ return _greedyScratch.GetScratch(size);
+ }
+
+ private static GreedyScratch _greedyScratch = new GreedyScratch();
+}
+
+
+public class GreedyScratch : IDisposable
+{
+ public IntPtr GetScratch(int size)
+ {
+ if (_size < size)
+ {
+ releaseScratch();
+ _scratch = Marshal.AllocHGlobal(size);
+ _size = size;
+ }
+
+ return _scratch;
+ }
+
+ private void releaseScratch()
+ {
+ if (_size > 0)
+ {
+ Marshal.FreeHGlobal(_scratch);
+ _scratch = IntPtr.Zero;
+ }
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ }
+
+ protected virtual void Dispose(bool bDisposing)
+ {
+ releaseScratch();
+
+ if (bDisposing)
+ {
+ GC.SuppressFinalize(this);
+ }
+ }
+
+ ~GreedyScratch()
+ {
+ Dispose(false);
+ }
+
+ private int _size = 0;
+ private IntPtr _scratch = IntPtr.Zero;
+}
+
+
+public abstract class DisposablePtr : IDisposable
+{
+ protected void Initialize(IntPtr ptr)
+ {
+ Assert.IsTrue(this._ptr == IntPtr.Zero);
+ this._ptr = ptr;
+ }
+
+ protected void ResetPtr()
+ {
+ this._ptr = IntPtr.Zero;
+ }
+
+ protected abstract void Release();
+
+ public IntPtr ptr
+ {
+ get { return _ptr; }
+ }
+
+
+ public void Dispose()
+ {
+ Dispose(true);
+ }
+
+ protected virtual void Dispose(bool bDisposing)
+ {
+ if (_ptr != IntPtr.Zero)
+ {
+ Release();
+ _ptr = IntPtr.Zero;
+ }
+
+ if (bDisposing)
+ {
+ GC.SuppressFinalize(this);
+ }
+ }
+
+ ~DisposablePtr()
+ {
+ Dispose(false);
+ }
+
+ private IntPtr _ptr = IntPtr.Zero;
+}
+
+
+public class NvBlastAsset : DisposablePtr
+{
+ #region Dll
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern UInt64 NvBlastAssetCreateRequiredScratch(NvBlastAssetDesc desc);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern IntPtr NvBlastAssetCreate(NvBlastAssetDesc desc, NvBlastWrapper.NvBlastAlloc allocFn, IntPtr scratch, NvBlastWrapper.NvBlastLog logFn);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern void NvBlastAssetRelease(IntPtr asset, NvBlastWrapper.NvBlastFree freeFn, NvBlastWrapper.NvBlastLog logFn);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern UInt32 NvBlastAssetGetLeafChunkCount(IntPtr asset, NvBlastWrapper.NvBlastLog logFn);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern NvBlastChunkGraph NvBlastAssetGetSupportGraph(IntPtr asset, NvBlastWrapper.NvBlastLog logFn);
+ #endregion
+
+ public NvBlastAsset(NvBlastAssetDesc desc)
+ {
+ var scratchSize = NvBlastAssetCreateRequiredScratch(desc);
+ var asset = NvBlastAssetCreate(desc, NvBlastWrapper.Alloc, NvBlastWrapper.GetScratch((int)scratchSize), NvBlastWrapper.Log);
+ Initialize(asset);
+ }
+
+ protected override void Release()
+ {
+ NvBlastAssetRelease(ptr, NvBlastWrapper.Free, NvBlastWrapper.Log);
+ }
+
+ public UInt32 leafChunkCount
+ {
+ get
+ {
+ return NvBlastAssetGetLeafChunkCount(ptr, NvBlastWrapper.Log);
+ }
+ }
+
+ public NvBlastChunkGraph chunkGraph
+ {
+ get
+ {
+ if (!_graph.HasValue)
+ {
+ _graph = NvBlastAssetGetSupportGraph(ptr, NvBlastWrapper.Log);
+ }
+ return _graph.Value;
+ }
+ }
+
+ private NvBlastChunkGraph? _graph = null;
+}
+
+
+public class NvBlastFamily : DisposablePtr
+{
+ #region Dll
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern IntPtr NvBlastFamilyCreate(IntPtr asset, NvBlastWrapper.NvBlastAlloc allocFn, NvBlastWrapper.NvBlastLog logFn);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern void NvBlastFamilyRelease(IntPtr family, NvBlastWrapper.NvBlastFree freeFn, NvBlastWrapper.NvBlastLog logFn);
+ #endregion
+
+ public NvBlastAsset asset
+ {
+ get;
+ private set;
+ }
+
+ public NvBlastFamily(NvBlastAsset asset_)
+ {
+ asset = asset_;
+ var family = NvBlastFamilyCreate(asset.ptr, NvBlastWrapper.Alloc, NvBlastWrapper.Log);
+ Initialize(family);
+ }
+
+ protected override void Release()
+ {
+ NvBlastFamilyRelease(ptr, NvBlastWrapper.Free, NvBlastWrapper.Log);
+ }
+}
+
+
+public class NvBlastActor : DisposablePtr
+{
+ #region Dll
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern UInt64 NvBlastActorCreateRequiredScratch(IntPtr asset);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern IntPtr NvBlastActorCreate(IntPtr family, NvBlastActorDesc desc, IntPtr scratch, NvBlastWrapper.NvBlastLog logFn);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern void NvBlastActorRelease(IntPtr actor);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern UInt32 NvBlastActorGetVisibleChunkCount(IntPtr actor, NvBlastWrapper.NvBlastLog logFn);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern UInt32 NvBlastActorGetVisibleChunkIndices([In, Out] UInt32[] visibleChunkIndices, UInt32 visibleChunkIndicesSize, IntPtr actor, NvBlastWrapper.NvBlastLog logFn);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern UInt32 NvBlastActorGetGraphNodeCount(IntPtr actor, NvBlastWrapper.NvBlastLog logFn);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern UInt32 NvBlastActorGetGraphNodeIndices([In, Out] UInt32[] graphNodeIndices, UInt32 graphNodeIndicesSize, IntPtr actor, NvBlastWrapper.NvBlastLog logFn);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern void NvBlastActorGenerateFracture(NvBlastFractureBuffers commandBuffers, IntPtr actor, NvBlastDamageProgram program, NvBlastProgramParams programParams, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern void NvBlastActorApplyFracture(IntPtr eventBuffers, IntPtr actor, NvBlastFractureBuffers commands, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern UInt64 NvBlastActorSplitRequiredScratch(IntPtr actor);
+
+ [DllImport(NvBlastWrapper.DLL_NAME)]
+ static extern UInt32 NvBlastActorSplit([In, Out] NvBlastActorSplitEvent result, UInt32 newActorsMaxCount, IntPtr actor, IntPtr scratch, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers);
+ #endregion
+
+ public NvBlastFamily family
+ {
+ get;
+ private set;
+ }
+
+ public object userData = null;
+
+ public NvBlastActor(NvBlastFamily family_, NvBlastActorDesc desc)
+ {
+ family = family_;
+
+ var scratchSize = NvBlastActorCreateRequiredScratch(family_.asset.ptr);
+ var actor = NvBlastActorCreate(family.ptr, desc, NvBlastWrapper.GetScratch((int)scratchSize), NvBlastWrapper.Log);
+ Initialize(actor);
+ }
+
+ public NvBlastActor(NvBlastFamily family_, IntPtr ptr)
+ {
+ family = family_;
+
+ Initialize(ptr);
+ }
+
+ protected override void Release()
+ {
+ NvBlastActorRelease(ptr);
+ }
+
+ public UInt32 visibleChunkCount
+ {
+ get { return NvBlastActorGetVisibleChunkCount(ptr, NvBlastWrapper.Log); }
+ }
+
+ public UInt32[] visibleChunkIndices
+ {
+ get
+ {
+ if(_visibleChunkIndices == null)
+ {
+ _visibleChunkIndices = new UInt32[visibleChunkCount];
+ NvBlastActorGetVisibleChunkIndices(_visibleChunkIndices, visibleChunkCount, ptr, NvBlastWrapper.Log);
+ }
+ return _visibleChunkIndices;
+ }
+ }
+
+ public UInt32 graphNodeCount
+ {
+ get { return NvBlastActorGetGraphNodeCount(ptr, NvBlastWrapper.Log); }
+ }
+
+ public UInt32[] graphNodeIndices
+ {
+ get
+ {
+ if (_graphNodeIndices == null)
+ {
+ _graphNodeIndices = new UInt32[graphNodeCount];
+ NvBlastActorGetGraphNodeIndices(_graphNodeIndices, graphNodeCount, ptr, NvBlastWrapper.Log);
+ }
+ return _graphNodeIndices;
+ }
+ }
+
+ public void GenerateFracture(NvBlastFractureBuffers buffers, NvBlastDamageProgram program, NvBlastProgramParams programParams)
+ {
+ NvBlastActorGenerateFracture(buffers, ptr, program, programParams, NvBlastWrapper.Log, null);
+ }
+
+ public void ApplyFracture(NvBlastFractureBuffers commands)
+ {
+ NvBlastActorApplyFracture(IntPtr.Zero, ptr, commands, NvBlastWrapper.Log, null);
+ }
+
+ public UInt32 Split(NvBlastActorSplitEvent result, UInt32 newActorsMaxCount)
+ {
+ var scratchSize = NvBlastActorSplitRequiredScratch(ptr);
+ UInt32 newActorsCount = NvBlastActorSplit(result, newActorsMaxCount, ptr, NvBlastWrapper.GetScratch((int)scratchSize), NvBlastWrapper.Log, null);
+ if(result.deletedActor != IntPtr.Zero)
+ {
+ ResetPtr();
+ }
+ return newActorsCount;
+ }
+
+ private UInt32[] _visibleChunkIndices = null;
+ private UInt32[] _graphNodeIndices = null;
+}
+
diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs.meta b/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs.meta
index 6cb40de..6a5ccd6 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs.meta
+++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs.meta
@@ -1,12 +1,12 @@
-fileFormatVersion: 2
-guid: 50e876cfa58ea5a46935955772ce78d6
-timeCreated: 1481552179
-licenseType: Free
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: 50e876cfa58ea5a46935955772ce78d6
+timeCreated: 1481552179
+licenseType: Free
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64.meta b/examples/UnityExample/Assets/Plugins/Blast/x64.meta
index 1d8c5b7..051c1a6 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/x64.meta
+++ b/examples/UnityExample/Assets/Plugins/Blast/x64.meta
@@ -1,9 +1,9 @@
-fileFormatVersion: 2
-guid: 7efc8ea30a371b14b9de21b07f5666b1
-folderAsset: yes
-timeCreated: 1481552179
-licenseType: Free
-DefaultImporter:
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: 7efc8ea30a371b14b9de21b07f5666b1
+folderAsset: yes
+timeCreated: 1481552179
+licenseType: Free
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll
index 323acb4..323acb4 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll
+++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll
Binary files differ
diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll.meta b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll.meta
index 3b289f8..8388fbf 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll.meta
+++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll.meta
@@ -1,68 +1,68 @@
-fileFormatVersion: 2
-guid: 5fc0a2604d2987b4680e41464be1c22e
-timeCreated: 1482762574
-licenseType: Free
-PluginImporter:
- serializedVersion: 1
- iconMap: {}
- executionOrder: {}
- isPreloaded: 0
- isOverridable: 0
- platformData:
- Any:
- enabled: 1
- settings:
- Exclude Editor: 0
- Exclude Linux: 0
- Exclude Linux64: 0
- Exclude LinuxUniversal: 0
- Exclude OSXIntel: 0
- Exclude OSXIntel64: 0
- Exclude OSXUniversal: 0
- Exclude WebGL: 0
- Exclude Win: 1
- Exclude Win64: 0
- Editor:
- enabled: 1
- settings:
- CPU: x86_64
- DefaultValueInitialized: true
- OS: AnyOS
- Linux:
- enabled: 1
- settings:
- CPU: None
- Linux64:
- enabled: 1
- settings:
- CPU: x86_64
- LinuxUniversal:
- enabled: 1
- settings:
- CPU: AnyCPU
- OSXIntel:
- enabled: 1
- settings:
- CPU: None
- OSXIntel64:
- enabled: 1
- settings:
- CPU: AnyCPU
- OSXUniversal:
- enabled: 1
- settings:
- CPU: AnyCPU
- WebGL:
- enabled: 1
- settings: {}
- Win:
- enabled: 0
- settings:
- CPU: None
- Win64:
- enabled: 1
- settings:
- CPU: AnyCPU
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: 5fc0a2604d2987b4680e41464be1c22e
+timeCreated: 1482762574
+licenseType: Free
+PluginImporter:
+ serializedVersion: 1
+ iconMap: {}
+ executionOrder: {}
+ isPreloaded: 0
+ isOverridable: 0
+ platformData:
+ Any:
+ enabled: 1
+ settings:
+ Exclude Editor: 0
+ Exclude Linux: 0
+ Exclude Linux64: 0
+ Exclude LinuxUniversal: 0
+ Exclude OSXIntel: 0
+ Exclude OSXIntel64: 0
+ Exclude OSXUniversal: 0
+ Exclude WebGL: 0
+ Exclude Win: 1
+ Exclude Win64: 0
+ Editor:
+ enabled: 1
+ settings:
+ CPU: x86_64
+ DefaultValueInitialized: true
+ OS: AnyOS
+ Linux:
+ enabled: 1
+ settings:
+ CPU: None
+ Linux64:
+ enabled: 1
+ settings:
+ CPU: x86_64
+ LinuxUniversal:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ OSXIntel:
+ enabled: 1
+ settings:
+ CPU: None
+ OSXIntel64:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ OSXUniversal:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ WebGL:
+ enabled: 1
+ settings: {}
+ Win:
+ enabled: 0
+ settings:
+ CPU: None
+ Win64:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll
index 9000d94..9000d94 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll
+++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll
Binary files differ
diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll.meta b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll.meta
index fd62927..cda3e53 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll.meta
+++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll.meta
@@ -1,54 +1,54 @@
-fileFormatVersion: 2
-guid: 819acd10daddc114cb79447732a44ff3
-timeCreated: 1482926953
-licenseType: Free
-PluginImporter:
- serializedVersion: 1
- iconMap: {}
- executionOrder: {}
- isPreloaded: 0
- isOverridable: 0
- platformData:
- Any:
- enabled: 1
- settings: {}
- Editor:
- enabled: 0
- settings:
- CPU: x86_64
- DefaultValueInitialized: true
- Linux:
- enabled: 0
- settings:
- CPU: None
- Linux64:
- enabled: 1
- settings:
- CPU: x86_64
- LinuxUniversal:
- enabled: 1
- settings:
- CPU: x86_64
- OSXIntel:
- enabled: 0
- settings:
- CPU: None
- OSXIntel64:
- enabled: 1
- settings:
- CPU: AnyCPU
- OSXUniversal:
- enabled: 0
- settings:
- CPU: x86_64
- Win:
- enabled: 0
- settings:
- CPU: None
- Win64:
- enabled: 1
- settings:
- CPU: AnyCPU
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: 819acd10daddc114cb79447732a44ff3
+timeCreated: 1482926953
+licenseType: Free
+PluginImporter:
+ serializedVersion: 1
+ iconMap: {}
+ executionOrder: {}
+ isPreloaded: 0
+ isOverridable: 0
+ platformData:
+ Any:
+ enabled: 1
+ settings: {}
+ Editor:
+ enabled: 0
+ settings:
+ CPU: x86_64
+ DefaultValueInitialized: true
+ Linux:
+ enabled: 0
+ settings:
+ CPU: None
+ Linux64:
+ enabled: 1
+ settings:
+ CPU: x86_64
+ LinuxUniversal:
+ enabled: 1
+ settings:
+ CPU: x86_64
+ OSXIntel:
+ enabled: 0
+ settings:
+ CPU: None
+ OSXIntel64:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ OSXUniversal:
+ enabled: 0
+ settings:
+ CPU: x86_64
+ Win:
+ enabled: 0
+ settings:
+ CPU: None
+ Win64:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll
index 401cd04..401cd04 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll
+++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll
Binary files differ
diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll.meta b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll.meta
index e35fbdc..560b07a 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll.meta
+++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll.meta
@@ -1,68 +1,68 @@
-fileFormatVersion: 2
-guid: 52823d20a4352e84d84af3b61814dc42
-timeCreated: 1482762574
-licenseType: Free
-PluginImporter:
- serializedVersion: 1
- iconMap: {}
- executionOrder: {}
- isPreloaded: 0
- isOverridable: 0
- platformData:
- Any:
- enabled: 1
- settings:
- Exclude Editor: 0
- Exclude Linux: 0
- Exclude Linux64: 0
- Exclude LinuxUniversal: 0
- Exclude OSXIntel: 0
- Exclude OSXIntel64: 0
- Exclude OSXUniversal: 0
- Exclude WebGL: 0
- Exclude Win: 1
- Exclude Win64: 0
- Editor:
- enabled: 1
- settings:
- CPU: x86_64
- DefaultValueInitialized: true
- OS: AnyOS
- Linux:
- enabled: 1
- settings:
- CPU: None
- Linux64:
- enabled: 1
- settings:
- CPU: x86_64
- LinuxUniversal:
- enabled: 1
- settings:
- CPU: AnyCPU
- OSXIntel:
- enabled: 1
- settings:
- CPU: None
- OSXIntel64:
- enabled: 1
- settings:
- CPU: AnyCPU
- OSXUniversal:
- enabled: 1
- settings:
- CPU: AnyCPU
- WebGL:
- enabled: 1
- settings: {}
- Win:
- enabled: 0
- settings:
- CPU: None
- Win64:
- enabled: 1
- settings:
- CPU: AnyCPU
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: 52823d20a4352e84d84af3b61814dc42
+timeCreated: 1482762574
+licenseType: Free
+PluginImporter:
+ serializedVersion: 1
+ iconMap: {}
+ executionOrder: {}
+ isPreloaded: 0
+ isOverridable: 0
+ platformData:
+ Any:
+ enabled: 1
+ settings:
+ Exclude Editor: 0
+ Exclude Linux: 0
+ Exclude Linux64: 0
+ Exclude LinuxUniversal: 0
+ Exclude OSXIntel: 0
+ Exclude OSXIntel64: 0
+ Exclude OSXUniversal: 0
+ Exclude WebGL: 0
+ Exclude Win: 1
+ Exclude Win64: 0
+ Editor:
+ enabled: 1
+ settings:
+ CPU: x86_64
+ DefaultValueInitialized: true
+ OS: AnyOS
+ Linux:
+ enabled: 1
+ settings:
+ CPU: None
+ Linux64:
+ enabled: 1
+ settings:
+ CPU: x86_64
+ LinuxUniversal:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ OSXIntel:
+ enabled: 1
+ settings:
+ CPU: None
+ OSXIntel64:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ OSXUniversal:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ WebGL:
+ enabled: 1
+ settings: {}
+ Win:
+ enabled: 0
+ settings:
+ CPU: None
+ Win64:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll
index b24c4fa..b24c4fa 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll
+++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll
Binary files differ
diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll.meta b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll.meta
index 4423045..ccb6a94 100644..100755
--- a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll.meta
+++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll.meta
@@ -1,54 +1,54 @@
-fileFormatVersion: 2
-guid: 26135af3d3f04804dbaebd13245d00ce
-timeCreated: 1482926953
-licenseType: Free
-PluginImporter:
- serializedVersion: 1
- iconMap: {}
- executionOrder: {}
- isPreloaded: 0
- isOverridable: 0
- platformData:
- Any:
- enabled: 1
- settings: {}
- Editor:
- enabled: 0
- settings:
- CPU: x86_64
- DefaultValueInitialized: true
- Linux:
- enabled: 0
- settings:
- CPU: None
- Linux64:
- enabled: 1
- settings:
- CPU: x86_64
- LinuxUniversal:
- enabled: 1
- settings:
- CPU: x86_64
- OSXIntel:
- enabled: 0
- settings:
- CPU: None
- OSXIntel64:
- enabled: 1
- settings:
- CPU: AnyCPU
- OSXUniversal:
- enabled: 0
- settings:
- CPU: x86_64
- Win:
- enabled: 0
- settings:
- CPU: None
- Win64:
- enabled: 1
- settings:
- CPU: AnyCPU
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: 26135af3d3f04804dbaebd13245d00ce
+timeCreated: 1482926953
+licenseType: Free
+PluginImporter:
+ serializedVersion: 1
+ iconMap: {}
+ executionOrder: {}
+ isPreloaded: 0
+ isOverridable: 0
+ platformData:
+ Any:
+ enabled: 1
+ settings: {}
+ Editor:
+ enabled: 0
+ settings:
+ CPU: x86_64
+ DefaultValueInitialized: true
+ Linux:
+ enabled: 0
+ settings:
+ CPU: None
+ Linux64:
+ enabled: 1
+ settings:
+ CPU: x86_64
+ LinuxUniversal:
+ enabled: 1
+ settings:
+ CPU: x86_64
+ OSXIntel:
+ enabled: 0
+ settings:
+ CPU: None
+ OSXIntel64:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ OSXUniversal:
+ enabled: 0
+ settings:
+ CPU: x86_64
+ Win:
+ enabled: 0
+ settings:
+ CPU: None
+ Win64:
+ enabled: 1
+ settings:
+ CPU: AnyCPU
+ userData:
+ assetBundleName:
+ assetBundleVariant: