diff options
| author | Bryan Galdrikian <[email protected]> | 2017-02-24 09:32:20 -0800 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-02-24 09:32:20 -0800 |
| commit | e1bf674c16e3c8472b29574159c789cd3f0c64e0 (patch) | |
| tree | 9f0cfce09c71a2c27ff19589fcad6cd83504477c /sdk/toolkit/include | |
| parent | first commit (diff) | |
| download | blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.tar.xz blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.zip | |
Updating to [email protected] and [email protected] with a new directory structure.
NvBlast folder is gone, files have been moved to top level directory. README is changed to reflect this.
Diffstat (limited to 'sdk/toolkit/include')
| -rw-r--r-- | sdk/toolkit/include/NvBlastTk.h | 31 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkActor.h | 239 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkAsset.h | 136 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkEvent.h | 166 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkFamily.h | 124 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkFramework.h | 365 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkGroup.h | 133 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkIdentifiable.h | 61 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkJoint.h | 60 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkObject.h | 57 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkSerializable.h | 60 | ||||
| -rw-r--r-- | sdk/toolkit/include/NvBlastTkType.h | 65 |
12 files changed, 1497 insertions, 0 deletions
diff --git a/sdk/toolkit/include/NvBlastTk.h b/sdk/toolkit/include/NvBlastTk.h new file mode 100644 index 0000000..6471165 --- /dev/null +++ b/sdk/toolkit/include/NvBlastTk.h @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTK_H +#define NVBLASTTK_H + + +/** +This is the main include header for the BlastTk SDK, for users who +want to use a single #include file. + +Alternatively, one can instead directly #include a subset of the below files. +*/ + + +#include "NvBlastTkFramework.h" +#include "NvBlastTkAsset.h" +#include "NvBlastTkActor.h" +#include "NvBlastTkJoint.h" +#include "NvBlastTkFamily.h" +#include "NvBlastTkGroup.h" + + +#endif // ifndef NVBLASTTK_H diff --git a/sdk/toolkit/include/NvBlastTkActor.h b/sdk/toolkit/include/NvBlastTkActor.h new file mode 100644 index 0000000..a810ee1 --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkActor.h @@ -0,0 +1,239 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKACTOR_H +#define NVBLASTTKACTOR_H + +#include "NvBlastTkObject.h" +#include "NvBlastTypes.h" + +// Forward declarations +struct NvBlastActor; +struct NvBlastFamily; + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class TkAsset; +class TkFamily; +class TkGroup; +class TkJoint; + + +/** +The BlastTk entity which encapsulates an NvBlastActor. Every TkActor represents a group +of chunks which may correspond to a single physical rigid body. TkActors are created +using TkFramework::createActor. +*/ +class TkActor : public TkObject +{ +public: + /** + Access to underlying low-level actor. + + \return a pointer to the (const) low-level NvBlastActor object. + */ + virtual const NvBlastActor* getActorLL() const = 0; + + /** + Every actor is part of an actor family, even if that family contains a single actor. + This function returns a reference to the actor's TkFamily. + + \return a pointer to the actor's TkFamily. + */ + virtual TkFamily& getFamily() const = 0; + + /** + Every actor has a unique index within a family. This function returns that index. + */ + virtual uint32_t getIndex() const = 0; + + /** + Actors may be part of (no more than) one group. See TkGroup for the functions to add and remove actors. + This function returns a pointer to the actor's group, or NULL if it is not in a group. + */ + virtual TkGroup* getGroup() const = 0; + + /** + Remove this actor from its group, if it is in one. + + \return the actor's former group if successful, NULL otherwise. + */ + virtual TkGroup* removeFromGroup() = 0; + + /** + Every actor has an associated asset. + + \return a pointer to the (const) TkAsset object. + */ + virtual const TkAsset* getAsset() const = 0; + + /** + Get the number of visible chunks for this actor. May be used in conjunction with getVisibleChunkIndices. + + NOTE: Wrapper function over low-level function call, see NvBlastActorGetVisibleChunkCount for details. + + \return the number of visible chunk indices for the actor. + */ + virtual uint32_t getVisibleChunkCount() const = 0; + + /** + Retrieve a list of visible chunk indices for the actor into the given array. + + NOTE: Wrapper function over low-level function call, see NvBlastActorGetVisibleChunkIndices for details. + + \param[in] visibleChunkIndices User-supplied array to be filled in with indices of visible chunks for this actor. + \param[in] visibleChunkIndicesSize The size of the visibleChunkIndices array. To receive all visible chunk indices, the size must be at least that given by getVisibleChunkCount(). + + \return the number of indices written to visibleChunkIndices. This will not exceed visibleChunkIndicesSize. + */ + virtual uint32_t getVisibleChunkIndices(uint32_t* visibleChunkIndices, uint32_t visibleChunkIndicesSize) const = 0; + + /** + Get the number of graph nodes for this actor. May be used in conjunction with getGraphNodeIndices. + + NOTE: Wrapper function over low-level function call, see NvBlastActorGetGraphNodeCount for details. + + \return the number of graph node indices for the actor. + */ + virtual uint32_t getGraphNodeCount() const = 0; + + /** + Retrieve a list of graph node indices for the actor into the given array. + + NOTE: Wrapper function over low-level function call, see NvBlastActorGetGraphNodeIndices for details. + + \param[in] graphNodeIndices User-supplied array to be filled in with indices of graph nodes for this actor. + \param[in] graphNodeIndicesSize The size of the graphNodeIndices array. To receive all graph node indices, the size must be at least that given by getGraphNodeCount(). + + \return the number of indices written to graphNodeIndices. This will not exceed graphNodeIndicesSize. + */ + virtual uint32_t getGraphNodeIndices(uint32_t* graphNodeIndices, uint32_t graphNodeIndicesSize) const = 0; + + /** + Access the bond health data for an actor. + + NOTE: Wrapper function over low-level function call, see NvBlastActorGetBondHealths for details. + + \return the array of bond healths for the actor's family, or NULL if the actor is invalid. + */ + virtual const float* getBondHealths() const = 0; + + /** + Returns the upper-bound number of actors which can be created by splitting this actor. + + NOTE: Wrapper function over low-level function call, see NvBlastActorGetMaxActorCountForSplit for details. + + \return the upper-bound number of actors which can be created by splitting this actor. + */ + virtual uint32_t getSplitMaxActorCount() const = 0; + + /** + Report whether this actor is in 'pending' state. Being in 'pending' state leads to actor being processed by group. + + \return true iff actor is in 'pending' state. + */ + virtual bool isPending() const = 0; + + /** + Apply damage to this actor. + + Actual damage processing is deferred till the group process() call. Sets actor in 'pending' state. + + It's the user's responsibility to keep programParams pointer alive until the group sync() call. + + \param[in] program A NvBlastDamageProgram containing damage shaders. + \param[in] programParams Parameters for the NvBlastDamageProgram. + */ + virtual void damage(const NvBlastDamageProgram& program, const NvBlastProgramParams* programParams) = 0; + + /** + Apply damage to this actor. + + Actual damage processing is deferred till the group process() call. Sets actor in 'pending' state. + + Damage Desc will be stacked into NvBlastProgramParams. NvBlastProgramParams will be passed into shader. + + Material set on actor's family will be passed into NvBlastProgramParams. + + \param[in] program A NvBlastDamageProgram containing damage shaders. + \param[in] damageDesc Parameters to be put in NvBlastProgramParams, have to be POD type (will be copied). + \param[in] descSize Size of damageDesc in bytes. Required to copy and store Damage Desc. + */ + virtual void damage(const NvBlastDamageProgram& program, const void* damageDesc, uint32_t descSize) = 0; + + /** + Apply damage to this actor. + + Actual damage processing is deferred till the group process() call. Sets actor in 'pending' state. + + Damage Desc will be stacked into NvBlastDamageProgram. NvBlastDamageProgram will be passed into shader. + + This function overload explicitly sets a material to be passed into NvBlastProgramParams, it must be valid until the group sync() call. + + \param[in] program A NvBlastDamageProgram containing damage shaders. + \param[in] damageDesc Parameters to be put in NvBlastDamageProgram, have to be POD type (will be copied). + \param[in] descSize Size of damageDesc in bytes. Required to copy and store Damage Desc. + \param[in] material Material to be passed into NvBlastProgramParams. Must be valid until the group sync() call. + */ + virtual void damage(const NvBlastDamageProgram& program, const void* damageDesc, uint32_t descSize, const void* material) = 0; + + /** + Creates fracture commands for the actor using an NvBlastMaterialFunction. + + Cannot be called during group processing, in that case a warning will be raised and function will do nothing. + + NOTE: Wrapper function over low-level function call, see NvBlastActorGenerateFracture for details. + + \param[in,out] commands Target buffers to hold generated commands. + To avoid data loss, provide an entry for every support chunk and every bond in the original actor. + \param[in] program A NvBlastDamageProgram containing damage shaders. + \param[in] programParams Parameters for the NvBlastDamageProgram. + */ + virtual void generateFracture(NvBlastFractureBuffers* commands, const NvBlastDamageProgram& program, const NvBlastProgramParams* programParams) const = 0; + + /** + Function applies the direct fracture and breaks graph bonds/edges as necessary. Sets actor in 'pending' state if any bonds or chunks were damaged. Dispatches FractureCommand events. + + NOTE: Calls NvBlastActorApplyFracture internally. see NvBlastActorApplyFracture for details. + + \param[in,out] eventBuffers Target buffers to hold applied fracture events. May be NULL, in which case events are not reported. + To avoid data loss, provide an entry for every lower-support chunk and every bond in the original actor. + \param[in] commands The fracture commands to process. + */ + virtual void applyFracture(NvBlastFractureBuffers* eventBuffers, const NvBlastFractureBuffers* commands) = 0; + + /** + The number of joints currently attached to this actor. + + \return the number of TkJoints that are currently attached to this actor. + */ + virtual uint32_t getJointCount() const = 0; + + /** + Retrieve an array of pointers (into the user-supplied buffer) to joints. + + \param[out] joints A user-supplied array of TkJoint pointers. + \param[in] jointsSize The number of elements available to write into the joints array. + + \return the number of TkJoint pointers written to the joints array. + */ + virtual uint32_t getJoints(TkJoint** joints, uint32_t jointsSize) const = 0; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKACTOR_H diff --git a/sdk/toolkit/include/NvBlastTkAsset.h b/sdk/toolkit/include/NvBlastTkAsset.h new file mode 100644 index 0000000..987da7d --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkAsset.h @@ -0,0 +1,136 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKASSET_H +#define NVBLASTTKASSET_H + +#include "NvBlastTkSerializable.h" +#include "NvBlastTypes.h" +#include "PxVec3.h" + +// Forward declarations +struct NvBlastAsset; + + +namespace Nv +{ +namespace Blast +{ + +/** +A descriptor stored by a TkAsset for an internal joint. Internal joints are created when a TkAsset is instanced into a TkActor. +*/ +struct TkAssetJointDesc +{ + uint32_t nodeIndices[2]; //!< The graph node indices corresponding to the support chunks joined by a joint + physx::PxVec3 attachPositions[2]; //!< The joint's attachment positions in asset-local space +}; + + +/** +The static data associated with a destructible actor. TkAsset encapsulates an NvBlastAsset. In addition to the NvBlastAsset, +the TkAsset stores joint descriptors (see TkAssetJointDesc). +*/ +class TkAsset : public TkSerializable +{ +public: + /** + Access to underlying low-level asset. + + \return a pointer to the (const) low-level NvBlastAsset object. + */ + virtual const NvBlastAsset* getAssetLL() const = 0; + + /** + Get the number of chunks in this asset. + + NOTE: Wrapper function over low-level function call, see NvBlastAssetGetChunkCount for details. + + \return the number of chunks in the asset. + */ + virtual uint32_t getChunkCount() const = 0; + + /** + Get the number of leaf chunks in the given asset. + + NOTE: Wrapper function over low-level function call, see NvBlastAssetGetLeafChunkCount for details. + + \return the number of leaf chunks in the asset. + */ + virtual uint32_t getLeafChunkCount() const = 0; + + /** + Get the number of bonds in the given asset. + + NOTE: Wrapper function over low-level function call, see NvBlastAssetGetBondCount for details. + + \return the number of bonds in the asset. + */ + virtual uint32_t getBondCount() const = 0; + + /** + Access an array of chunks of the given asset. + + NOTE: Wrapper function over low-level function call, see NvBlastAssetGetChunks for details. + + \return a pointer to an array of chunks of the asset. + */ + virtual const NvBlastChunk* getChunks() const = 0; + + /** + Access an array of bonds of the given asset. + + NOTE: Wrapper function over low-level function call, see NvBlastAssetGetBonds for details. + + \return a pointer to an array of bonds of the asset. + */ + virtual const NvBlastBond* getBonds() const = 0; + + /** + Access an support graph for the given asset. + + NOTE: Wrapper function over low-level function call, see NvBlastAssetGetSupportGraph for details. + + \return a struct of support graph for the given asset. + */ + virtual const NvBlastSupportGraph getGraph() const = 0; + + /** + Retrieve the size (in bytes) of the LL asset. + + NOTE: Wrapper function over low-level function call, see NvBlastAssetGetSize for details. + + \return the size of the data block (in bytes). + */ + virtual uint32_t getDataSize() const = 0; + + /** + The number of internal TkJoint objects that will be created when this asset is instanced into a TkActor + (see TkFramework::createActor). These joints will not trigger TkJointUpdateEvent events + until this actor is split into actors such that a joint connects two actors. At this time the actor's family + will dispatch a TkJointUpdateEvent::External event during a call to TkGroup::sync() (see TkGroup). + + \return the number of descriptors for internal joints. + */ + virtual uint32_t getJointDescCount() const = 0; + + /** + The descriptors for the internal joints created when this asset is instanced. (See getJointDescCount.) + + \return a pointer to the array of descriptors for internal joints. + */ + virtual const TkAssetJointDesc* getJointDescs() const = 0; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKASSET_H diff --git a/sdk/toolkit/include/NvBlastTkEvent.h b/sdk/toolkit/include/NvBlastTkEvent.h new file mode 100644 index 0000000..1e640f1 --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkEvent.h @@ -0,0 +1,166 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKEVENT_H +#define NVBLASTTKEVENT_H + +#include <vector> + +#include "NvBlastTypes.h" + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class TkObject; +class TkActor; +class TkFamily; +class TkJoint; + + +/** +By the time events are dispatched, a specific TkActor may have been split and became invalid. +This structure caches the state before invalidation happened. +*/ +struct TkActorData +{ + TkFamily* family; //!< TkFamily of the originating TkActor + void* userData; //!< TkActor.userData of the originating TkActor + uint32_t index; //!< TkActor::getIndex() of the originating TkActor +}; + + +/** +Event data dispatched to TkEventListener objects. The user may implement the abstract TkEventListener interface +and pass the listener object to a BlastTk object which dispatches events. (See for example TkFamily.) +*/ +struct TkEvent +{ + // Enums + enum Type + { + Split, //!< Sent when a TkActor is split. See TkSplitEvent. + FractureCommand, //!< Sent when a TkActor generated fracture commands using TkActor::generateFracture. + FractureEvent, //!< Sent when a TkActor is fractured using TkActor::applyFracture. + JointUpdate, //!< Sent when TkJoints change their attachment state. See TkJointUpdateEvent. + + TypeCount + }; + + // Data + const void* payload; //!< Type-dependent payload data + Type type; //!< See the Type enum, above + + /** + Casts the payload data into its type-dependent format. + + \return the payload for an event of type T + */ + template<typename T> + const T* getPayload() const { return reinterpret_cast<const T*>(payload); } +}; + + +/** +Payload for TkEvent::Split events + +When this event is sent, the parent TkActor that was split is no longer valid. Therefore it is not referenced +directly in the event data. Instead, its TkFamily, index within the TkFamily, and userData are stored. In addition, +this event gives the child TkActors generated by the split. +*/ +struct TkSplitEvent +{ + enum { EVENT_TYPE = TkEvent::Split }; + + TkActorData parentData; //!< The data of parent TkActor that was split + uint32_t numChildren; //!< The number of children into which the parent TkActor was split + TkActor** children; //!< An array of pointers to the children into which the TkActor was split +}; + + +/** +Payload for the TkEvent::FractureCommand events + +Fracture Commands used to apply fracture to a TkActor. +*/ +struct TkFractureCommands +{ + enum { EVENT_TYPE = TkEvent::FractureCommand }; + + TkActorData tkActorData; //!< The data of TkActor that received the fracture command + NvBlastFractureBuffers buffers; //!< The fracture commands used to modify the TkActor +}; + + +/** +Payload for the TkEvent::FractureEvent events + +Fracture Events resulting from applying fracture to a TkActor. +*/ +struct TkFractureEvents +{ + enum { EVENT_TYPE = TkEvent::FractureEvent }; + + TkActorData tkActorData; //!< The data of TkActor that received the fracture command + NvBlastFractureBuffers buffers; //!< The fracture result of the modified TkActor + uint32_t bondsDamaged; //!< number of damaged bonds (health remains) + uint32_t bondsBroken; //!< number of broken bonds (health exhausted) + uint32_t chunksDamaged; //!< number of damaged chunks (health remains) including child chunks + uint32_t chunksBroken; //!< number of broken chunks (health exhausted) including child chunks +}; + + +/** +Payload for the TkEvent::JointUpdate events + +Event type sent when a TkJoint's TkActor references change. This may indicate a joint becoming external, +simply changing actors when split events occur on one or both of the actors, or when one or both of the actors +are destroyed. +*/ +struct TkJointUpdateEvent +{ + enum { EVENT_TYPE = TkEvent::JointUpdate }; + + enum Subtype + { + External, //!< A joint that used to be internal to a single TkActor now joins two different TkActors + Changed, //!< One or both of the joint's attached TkActors has changed. The previous TkActors were distinct, however, differentiating this from the JointExternal case + Unreferenced //!< The joint's actors have been set to NULL. The joint will not be used again, and the user may release the TkJoint at this time + }; + + TkJoint* joint; //!< The joint being updated + Subtype subtype; //!< The type of update event this is (see Subtype) +}; + + +/** +Interface for a listener of TkEvent data. The user must implement this interface and pass it +to the object which will dispatch the events. +*/ +class TkEventListener +{ +public: + /** + Interface to be implemented by the user. Events will be sent by BlastTk through a call to this function. + + \param[in] events The array of events being dispatched. + \param[in] eventCount The number of events in the array. + */ + virtual void receive(const TkEvent* events, uint32_t eventCount) = 0; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKEVENT_H diff --git a/sdk/toolkit/include/NvBlastTkFamily.h b/sdk/toolkit/include/NvBlastTkFamily.h new file mode 100644 index 0000000..be6edd6 --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkFamily.h @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKFAMILY_H +#define NVBLASTTKFAMILY_H + +#include "NvBlastTkSerializable.h" + + +// Forward declarations +struct NvBlastFamily; + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class TkActor; +class TkAsset; +class TkEventListener; + + +/** +The TkFamily is associated with the TkActor that is instanced from a TkAsset, as well as all descendent TkActors generated +by spliting TkActors within the family. It encapsulates an NvBlastFamily, and also holds a material which will be used +by default on all TkActors during damage functions. +*/ +class TkFamily : public TkSerializable +{ +public: + /** + Access to underlying low-level family. + + \return a pointer to the (const) low-level NvBlastFamily object. + */ + virtual const NvBlastFamily* getFamilyLL() const = 0; + + /** + Every family has an associated asset (the TkAsset which was instanced to create the first member of the family). + + \return a pointer to the (const) TkAsset object. + */ + virtual const TkAsset* getAsset() const = 0; + + /** + The number of actors currently in this family. + + \return the number of TkActors that currently exist in this family. + */ + virtual uint32_t getActorCount() const = 0; + + /** + Retrieve an array of pointers (into the user-supplied buffer) to actors. + + \param[out] buffer A user-supplied array of TkActor pointers. + \param[in] bufferSize The number of elements available to write into buffer. + \param[in] indexStart The starting index of the actor. + + \return the number of TkActor pointers written to the buffer. + */ + virtual uint32_t getActors(TkActor** buffer, uint32_t bufferSize, uint32_t indexStart = 0) const = 0; + + /** + Add a user implementation of TkEventListener to this family's list of listeners. These listeners will receive + all split and fracture events generated by TkActor objects in this family. They will also receive joint update events + when TkJoint objects are updated that are (or were) associated with a TkActor in this family. + + \param[in] l The event listener to add. + */ + virtual void addListener(TkEventListener& l) = 0; + + /** + Remove a TkEventReciever from this family's list of listeners. + + \param[in] l The event listener to remove. + */ + virtual void removeListener(TkEventListener& l) = 0; + + /** + This function applies fracture buffers on relevant actors (actor which contains corresponding bond/chunk) in family. + + \param[in] commands The fracture commands to process. + */ + virtual void applyFracture(const NvBlastFractureBuffers* commands) = 0; + + /** + A function to reinitialize this family with new family. The Family must be created from the same low-level asset, but can be + in any other state. As a result split events (TkEvent::Split) will be dispatched reflecting the resulting changes (created and removed actors) + Afterwards the family will contain a copy of the new family and all actors' low-level actor pointers will be updated. + + \param[in] newFamily The NvBlastFamily to use to reinitialize this family. + \param[in] group The group for new actors to be placed in. + */ + virtual void reinitialize(const NvBlastFamily* newFamily, TkGroup* group = nullptr) = 0; + + /** + The default material to be passed into NvBlastDamageProgram when a TkActor in this family is damaged. + + \return a pointer to the default material. + */ + virtual const void* getMaterial() const = 0; + + /** + Set the default material to be passed into NvBlastDamageProgram when a TkActor in this family is damaged. Must be valid till group sync() call. + + \param[in] material The material to be the new default. + */ + virtual void setMaterial(const void* material) = 0; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKFAMILY_H diff --git a/sdk/toolkit/include/NvBlastTkFramework.h b/sdk/toolkit/include/NvBlastTkFramework.h new file mode 100644 index 0000000..353eebd --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkFramework.h @@ -0,0 +1,365 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKFRAMEWORK_H +#define NVBLASTTKFRAMEWORK_H + + +#include "NvBlastTkType.h" +#include "NvBlastTkEvent.h" + +#include "NvBlastPreprocessor.h" +#include "NvBlastTypes.h" + +#include "PxVec3.h" + + +// Forward declarations +namespace physx +{ +class PxErrorCallback; +class PxAllocatorCallback; +class PxTransform; +namespace general_PxIOStream2 +{ +class PxFileBuf; +} +} + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class TkObject; +class TkEventDispatcher; +class TkAsset; +struct TkGroupDesc; +class TkGroup; +class TkActor; +class TkJoint; +class TkSerializable; +class TkIdentifiable; +struct TkAssetJointDesc; + + + +/** +Descriptor for framework creation. + +The TkFramework uses PxShared callbacks for messages and allocation. +*/ +struct TkFrameworkDesc +{ + physx::PxErrorCallback* errorCallback; //!< User-defined message callback (see PxErrorCallback) + physx::PxAllocatorCallback* allocatorCallback; //!< User-defined allocation callback (see PxAllocatorCallback) +}; + + +/** +Descriptor for asset creation + +Used to create a TkAsset. This may be used by an authoring tool to describe the asset to be created. + +The TkAssetDesc is a simple extension of the low-level NvBlastAsset descriptor, NvBlastAssetDesc. +*/ +struct TkAssetDesc : public NvBlastAssetDesc +{ + /** + Flags which may be associated with each bond described in the base NvBlastAssetDesc. + */ + enum BondFlags + { + NoFlags = 0, + + /** + If this flag is set then a TkJoint will be created joining the support chunks jointed by the bond. + + These joints will remain "quiet" until the actor is split in such a way that the joint joins two + different actors. In that case, a TkJointUpdateEvent will be dispatched with subtype External. + (See TkJointUpdateEvent.) + */ + BondJointed = (1 << 0) + }; + + /** + An array of size bondCount, see BondFlags. + If NULL, all flags are assumed to be NoFlags. + */ + const uint8_t* bondFlags; + + /** Constructor sets sane default values. The zero chunkCount will cause TkFramework::createAsset(...) to fail, though gracefully. */ + TkAssetDesc() : bondFlags(nullptr) + { + chunkCount = bondCount = 0; + chunkDescs = nullptr; + bondDescs = nullptr; + } +}; + + +/** +Descriptor for actor creation. + +The TkActorDesc is a simple extension of the low-level NvBlastActor descriptor, NvBlastActorDesc. +*/ +struct TkActorDesc : public NvBlastActorDesc +{ + const TkAsset* asset; //!< The TkAsset to instance + + /** Constructor sets sane default values */ + TkActorDesc(const TkAsset* inAsset = nullptr) : asset(inAsset) + { + uniformInitialBondHealth = uniformInitialLowerSupportChunkHealth = 1.0f; + initialBondHealths = initialSupportChunkHealths = nullptr; + } +}; + + +/** +Descriptor for joint creation. +*/ +struct TkJointDesc +{ + TkFamily* families[2]; //!< The TkFamily objects containint the chunks joined by the joint + uint32_t chunkIndices[2]; //!< The chunk indices within the corresponding TkFamily objects joined by the joint. The indexed chunks will be support chunks. + physx::PxVec3 attachPositions[2]; //!< The position of the joint relative to each TkActor which ownes the chunks jointed by this joint +}; + + +/** +Struct-enum to index object types handled by the framework +*/ +struct TkTypeIndex +{ + enum Enum + { + Asset = 0, //!< TkAsset object type + Family, //!< TkFamily object type + Group, //!< TkGroup object type + + TypeCount + }; +}; + + +/** +BlastTk Framework. + +The framework exists as a singleton and is used to create objects, deserialize object streams, and hold references +to identified objects (TkAsset, TkFamily, and TkGroup) which may be recalled by their GUIDs. +*/ +class TkFramework +{ +public: + /** + Release this framework and all contained objects. + Global singleton is set to NULL. + */ + virtual void release() = 0; + + /** + Access to the error callback set by the user. + */ + virtual physx::PxErrorCallback& getErrorCallback() const = 0; + + /** + Access to the allocator callback set by the user. + */ + virtual physx::PxAllocatorCallback& getAllocatorCallback() const = 0; + + /** + Access to a log function which can be used in Blast low-level calls. + This function uses the user-supplied PxErrorCallback (see TkFrameworkDesc). + */ + virtual NvBlastLog getLogFn() const = 0; + + /** + Deserialize an object from the given stream. Only objects derived from TkSerializable may be serialized and + deserialized. Use the parent class method TkIdentifiable::getType() to know the type to which to cast the object. + + Notes for different classes: + + TkAsset: deserializing a serialized TkAsset will recreate the asset in memory with the same NvBlastID (see + TkIdentifiable::getID()) as the original asset. + + TkFamily: deserializing a serialized TkFamily will generate all TkActor and TkJoint objects that were originally + contained in the family. The TkAsset which generated the family must exist at the time the family is deserialized. + + \param[in] stream User-defined stream object. + + \return pointer the deserialized object if successful, or NULL if unsuccessful. + */ + virtual TkSerializable* deserialize(physx::general_PxIOStream2::PxFileBuf& stream) = 0; + + /** + To find the type information for a given TkIdentifiable-derived class, use this funtion with the TkTypeIndex::Enum + corresponding to the desired class name. + + \param[in] typeIndex Enumerated object type (see TkTypeIndex). + + \return type object associated with the object's class. + */ + virtual const TkType* getType(TkTypeIndex::Enum typeIndex) const = 0; + + /** + Look up an object derived from TkIdentifiable by its ID. + + \param[in] id The ID of the object to look up (see NvBlastID). + + \return pointer the object if it exists, NULL otherwise. + */ + virtual TkIdentifiable* findObjectByID(const NvBlastID& id) const = 0; + + /** + The number of TkIdentifiable-derived objects in the framework of the given type. + + \param[in] type The type object for the given type. + + \return the number of objects that currently exist of the given type. + */ + virtual uint32_t getObjectCount(const TkType& type) const = 0; + + /** + Retrieve an array of pointers (into the user-supplied buffer) to TkIdentifiable-derived objects of the given type. + + \param[out] buffer A user-supplied array of TkIdentifiable pointers. + \param[in] bufferSize The number of elements available to write into buffer. + \param[in] type The type object for the given type. + \param[in] indexStart The starting index of the object. + + \return the number of TkIdentifiable pointers written to the buffer. + */ + virtual uint32_t getObjects(TkIdentifiable** buffer, uint32_t bufferSize, const TkType& type, uint32_t indexStart = 0) const = 0; + + //////// Asset creation //////// + /** + Helper function to build and apply chunk reorder map, so that chunk descriptors are properly ordered for the createAsset function. + + This is a convenience wrapper for the low-level NvBlastReorderAssetDescChunks function. + + This function may modify both the chunkDescs and bondDescs array, since rearranging chunk descriptors requires re-indexing within the bond descriptors. + + \param[in] chunkDescs Array of chunk descriptors of size chunkCount. It will be updated accordingly. + \param[in] chunkCount The number of chunk descriptors. + \param[in] bondDescs Array of bond descriptors of size chunkCount. It will be updated accordingly. + \param[in] bondCount The number of bond descriptors. + \param[in] chunkReorderMap If not NULL, must be a pointer to a uint32_t array of size desc.chunkCount. Maps old chunk indices to the reordered chunk indices. + + \return true iff the chunks did not require reordering (chunkReorderMap is the identity map). + */ + virtual bool reorderAssetDescChunks(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount, NvBlastBondDesc* bondDescs, uint32_t bondCount, uint32_t* chunkReorderMap = nullptr) const = 0; + + /** + Helper function to ensure (check and update) support coverage of chunks, required for asset creation via the createAsset function. + + This is a convenience wrapper for the low-level NvBlastEnsureAssetExactSupportCoverage function. + + The chunk descriptors may have their support flags be modified to ensure exact coverage. + + \param[in] chunkDescs An array of chunk descriptors. + \param[in] chunkCount The size of the chunkDescs array. + + \return true iff coverage was already exact. + */ + virtual bool ensureAssetExactSupportCoverage(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount) const = 0; + + /** + Create an asset from the given descriptor. + + \param[in] desc The asset descriptor (see TkAssetDesc). + + \return the created asset, if the descriptor was valid and memory was available for the operation. Otherwise, returns NULL. + */ + virtual TkAsset* createAsset(const TkAssetDesc& desc) = 0; + + /** + Create an asset from a low-level NvBlastAsset. + + \param[in] assetLL The low-level NvBlastAsset to encapsulate. + \param[in] jointDescs Optional joint descriptors to add to the new asset. + \param[in] jointDescCount The number of joint descriptors in the jointDescs array. If non-zero, jointDescs cannot be NULL. + \param[in] ownsAsset Does this TkAsset own the NvBlastAsset and thus is responsible for freeing it. + + \return the created asset, if memory was available for the operation. Otherwise, returns NULL. + */ + virtual TkAsset* createAsset(const NvBlastAsset* assetLL, Nv::Blast::TkAssetJointDesc* jointDescs = nullptr, uint32_t jointDescCount = 0, bool ownsAsset = false) = 0; + + //////// Group creation //////// + /** + Create a group from the given descriptor. A group is a processing unit, to which the user may add TkActors. New actors generated + from splitting a TkActor are automatically put into the same group. However, any actor may be removed from its group and optionally + placed into another group, or left groupless. + + \param[in] desc The group descriptor (see TkGroupDesc). + + \return the created group, if the descriptor was valid and memory was available for the operation. Otherwise, returns NULL. + */ + virtual TkGroup* createGroup(const TkGroupDesc& desc) = 0; + + //////// Actor creation //////// + /** + Create an actor from the given descriptor. The actor will be the first member of a new TkFamily. + + \param[in] desc The actor descriptor (see TkActorDesc). + + \return the created actor, if the descriptor was valid and memory was available for the operation. Otherwise, returns NULL. + */ + virtual TkActor* createActor(const TkActorDesc& desc) = 0; + + //////// Joint creation //////// + /** + Create a joint from the given descriptor. The following restrictions apply: + + * Only one joint may be created between any two support chunks. + + * A joint cannot be created between chunks within the same actor using this method. See TkAssetDesc for a description of + bond joint flags, which will create internal joints within an actor. + + \param[in] desc The joint descriptor (see TkJointDesc). + + \return the created joint, if the descriptor was valid and memory was available for the operation. Otherwise, returns NULL. + */ + virtual TkJoint* createJoint(const TkJointDesc& desc) = 0; + +protected: + /** + Destructor is virtual and not public - use the release() method instead of explicitly deleting the TkFramework + */ + virtual ~TkFramework() {} +}; + +} // namespace Blast +} // namespace Nv + + +//////// Global API to Create and Access Framework //////// + +/** +Create a new TkFramework. This creates a global singleton, and will fail if a TkFramework object already exists. + +\param[in] desc The descriptor used to create the new framework (see TkFrameworkDesc). + +\return the new TkFramework if successful, NULL otherwise. +*/ +NVBLAST_API Nv::Blast::TkFramework* NvBlastTkFrameworkCreate(const Nv::Blast::TkFrameworkDesc& desc); + + +/** +Retrieve a pointer to the global TkFramework singleton (if it exists). + +\return the pointer to the global TkFramework (NULL if none exists). +*/ +NVBLAST_API Nv::Blast::TkFramework* NvBlastTkFrameworkGet(); + + +#endif // ifndef NVBLASTTKFRAMEWORK_H diff --git a/sdk/toolkit/include/NvBlastTkGroup.h b/sdk/toolkit/include/NvBlastTkGroup.h new file mode 100644 index 0000000..585cccb --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkGroup.h @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKGROUP_H +#define NVBLASTTKGROUP_H + +#include "NvBlastTkIdentifiable.h" + + +// Forward declarations +namespace physx +{ +class PxTaskManager; +} + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class TkActor; + + +/** +Descriptor for a TkGroup. It uses the PxShared PxTaskManager interface to dispatch PxLightCpuTask. +@see TkWorker +*/ +struct TkGroupDesc +{ + physx::PxTaskManager* pxTaskManager; //!< User-defined task manager +}; + + +/** +Used to collect internal counters using TkGroup::getStats (for profile builds only) +@see TkGroup::getStats() +*/ +struct TkGroupStats +{ + NvBlastTimers timers; //!< Accumulated time spent in blast low-level functions, see NvBlastTimers + uint32_t processedActorsCount; //!< Accumulated number of processed actors in all TkWorker + int64_t workerTime; //!< Accumulated time spent executing TkWorker::run. Unit is ticks, see NvBlastTimers. +}; + + +/** +A group is a processing unit, to which the user may add TkActors. New actors generated from splitting a TkActor +are automatically put into the same group. However, any actor may be removed from its group and placed into +another group (or no group) by the user's choice. + +When the group's process function is called, all actors' damage buffers will be processed and turned into fracture events +and the actor is split if applicable. +This work is done in separate (possibly multiple) threads. The sync function waits for the processing threads to finish +and dispatches events for processing that actually occurred. +*/ +class TkGroup : public TkIdentifiable +{ +public: + /** + Add the actor to this group, if the actor does not currently belong to a group. + + \param[in] actor The actor to add. + + \return true if successful, false otherwise. + */ + virtual bool addActor(TkActor& actor) = 0; + + /** + The number of actors currently in this group. + + \return the number of TkActors that currently exist in this group. + */ + virtual uint32_t getActorCount() const = 0; + + /** + Retrieve an array of pointers (into the user-supplied buffer) to actors. + + \param[out] buffer A user-supplied array of TkActor pointers. + \param[in] bufferSize The number of elements available to write into buffer. + \param[in] indexStart The starting index of the actor. + + \return the number of TkActor pointers written to the buffer. + */ + virtual uint32_t getActors(TkActor** buffer, uint32_t bufferSize, uint32_t indexStart = 0) const = 0; + + /** + TkActors that have been damaged with applyFracture() such that they may be split into separate + actors are split by this function. TkActors that have damage queued through the actor's damage() function + will be fractured and split by this function. + Fracture and splitting work will be run on different threads provided through TkGroupDesc::pxTaskManager. + All work is done asynchronously, and the results are gathered by the sync() function. + + Note: The number of threads provided by pxTaskManager must not change over the group's lifetime. + + \return true if processing may be launched (this group is not currently processing), false otherwise. + */ + virtual bool process() = 0; + + /** + If all threads spawned by process() have finished, and sync() has not yet been called since, then this + function gathers the results of the split operations on the actors in this group. Events will be dispatched + to notify listeners of new and deleted actors. + + \param[in] block If true, this function waits until all threads have completed execution, then performs the gather and dispatch work. + If false, this function will perform the gather and dispatch work only if threads have completed execution, otherwise it returns immediately. + + \return true if gather and dispatch work have been performed, false otherwise. + */ + virtual bool sync(bool block = true) = 0; + + /** + For profile builds only, request stats of the last successful processing. Inactive in other builds. + The times and counters reported account for all the TkWorker (accumulated) taking part in the processing. + + \param[in] stats The struct to be filled in. + */ + virtual void getStats(TkGroupStats& stats) const = 0; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKGROUP_H diff --git a/sdk/toolkit/include/NvBlastTkIdentifiable.h b/sdk/toolkit/include/NvBlastTkIdentifiable.h new file mode 100644 index 0000000..6efe954 --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkIdentifiable.h @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKIDENTIFIABLE_H +#define NVBLASTTKIDENTIFIABLE_H + + +#include "NvBlastTkObject.h" + +#include "NvBlastTypes.h" + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class TkType; + + +/** +TkIdentifiable objects have getID and setID methods for individual objects. They also have a type (class) identification. +*/ +class TkIdentifiable : public TkObject +{ +public: + // Identifiable API + + /** + Return the ID associated with this object. + + \return the ID for this object. + */ + virtual const NvBlastID& getID() const = 0; + + /** + Set the ID for this object. + */ + virtual void setID(const NvBlastID& id) = 0; + + /** + Access to the static (class) type data for this object. + + \return the static type data for this object type. + */ + virtual const TkType& getType() const = 0; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKIDENTIFIABLE_H diff --git a/sdk/toolkit/include/NvBlastTkJoint.h b/sdk/toolkit/include/NvBlastTkJoint.h new file mode 100644 index 0000000..1fc41c0 --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkJoint.h @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKJOINT_H +#define NVBLASTTKJOINT_H + +#include "NvBlastTkObject.h" + +#include "PxVec3.h" + + +namespace Nv +{ +namespace Blast +{ + +/** +The data contained in a TkJoint. +*/ +struct TkJointData +{ + TkActor* actors[2]; //!< The TkActor objects joined by the joint + uint32_t chunkIndices[2]; //!< The chunk indices within the corresponding TkActor objects joined by the joint. The indexed chunks will be support chunks. + physx::PxVec3 attachPositions[2]; //!< The position of the joint relative to each TkActor +}; + + +/** +The TkJoint is may join two different TkActors, or be created internally within a single TkActor. + +When a TkActor is created from a TkAsset with jointed bonds (the asset is created using a TkAssetDesc with joint flags on bonds, see TkActorDesc) then +internal TkJoint objects are created and associated with every TkActor created from that TkAsset. The user only gets notification of the internal TkJoint +objects when the TkActor is split into separate TkActor objects that hold the support chunks joined by an internal TkJoint. + +The user will be notified when the TkActor objects that are attached to TkJoint objects change, or are released. In that case, a TkEvent with +a TkJointUpdateEvent payload is dispatched to TkEventListener objects registered with the TkFamily objects to which the actors belong. +*/ +class TkJoint : public TkObject +{ +public: + /** + Retrieve data in this joint. + + \return a TkJointData containing this joint's data. + */ + virtual const TkJointData getData() const = 0; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKJOINT_H diff --git a/sdk/toolkit/include/NvBlastTkObject.h b/sdk/toolkit/include/NvBlastTkObject.h new file mode 100644 index 0000000..085e859 --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkObject.h @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKOBJECT_H +#define NVBLASTTKOBJECT_H + + +namespace Nv +{ +namespace Blast +{ + +/** +Base class for all objects in Tk. All TkObjects are releasable. +*/ +class TkObject +{ +public: + /** + Constructor clears userData. + */ + TkObject() : userData(nullptr) {} + + // Object API + + /** + Release this object and free associated memory. + */ + virtual void release() = 0; + +protected: + /** + Destructor is virtual and not public - use the release() method instead of explicitly deleting a TkObject + */ + virtual ~TkObject() {} + +public: + // Data + + /** + Pointer field available to the user. + */ + void* userData; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKOBJECT_H diff --git a/sdk/toolkit/include/NvBlastTkSerializable.h b/sdk/toolkit/include/NvBlastTkSerializable.h new file mode 100644 index 0000000..93b9b47 --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkSerializable.h @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKSERIALIZABLE_H +#define NVBLASTTKSERIALIZABLE_H + + +#include "NvBlastTkIdentifiable.h" + + +// Forward declarations +namespace physx +{ +namespace general_PxIOStream2 +{ +class PxFileBuf; +} +} + + +namespace Nv +{ +namespace Blast +{ + +/** +TkSerializable objects support the serialize interface, and are returned by TkFramework::deserialize. +*/ +class TkSerializable : public TkIdentifiable +{ +public: + /** + Write the object data to the user-defined PxFileBuf stream. + + \param[in] stream User-defined stream object. + + \return true if serialization was successful, false otherwise. + */ + virtual bool serialize(physx::general_PxIOStream2::PxFileBuf& stream) const = 0; + + // Data + + /** + Integer field available to the user. This data is serialized. + */ + uint64_t userIntData; +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKSERIALIZABLE_H diff --git a/sdk/toolkit/include/NvBlastTkType.h b/sdk/toolkit/include/NvBlastTkType.h new file mode 100644 index 0000000..6f3afbf --- /dev/null +++ b/sdk/toolkit/include/NvBlastTkType.h @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#ifndef NVBLASTTKTYPE_H +#define NVBLASTTKTYPE_H + +#include "NvBlastTypes.h" + + + +namespace Nv +{ +namespace Blast +{ + +/** +Interface for static (class) type data. This data is used for identification in streams, +class-specific object queries in TkFramework, etc. Only classes derived from TkIdentifiable +use TkType data. +*/ +class TkType +{ +public: + /** + The class name. + + \return the class name. + */ + virtual const char* getName() const = 0; + + /** + The data format version for this class. When deserializing, this version must match the + current version. If not, the user may convert the data format using the format conversion + extension. + + \return the version number. + */ + virtual uint32_t getVersion() const = 0; + + /** + Test for equality. This type is used in static (per-class) data, so types are equal exactly + when their addresses are equal. + + \param[in] type The TkType to compare with this TkType. + + \return true if this type equals the input type, false otherwise. + */ + bool operator == (const TkType& type) const + { + return &type == this; + } +}; + +} // namespace Blast +} // namespace Nv + + +#endif // ifndef NVBLASTTKTYPE_H |