lowlevel/NvBlast.h
File members: lowlevel/NvBlast.h
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2016-2024 NVIDIA Corporation. All rights reserved.
#ifndef NVBLAST_H
#define NVBLAST_H
#include "NvBlastTypes.h"
// NvBlastAsset functions
NV_C_API size_t NvBlastGetAssetMemorySize(const NvBlastAssetDesc* desc, NvBlastLog logFn);
NV_C_API size_t NvBlastGetAssetMemorySizeFromSizeData(const NvBlastAssetMemSizeData& sizeData, NvBlastLog logFn);
NV_C_API size_t NvBlastGetRequiredScratchForCreateAsset(const NvBlastAssetDesc* desc, NvBlastLog logFn);
NV_C_API NvBlastAsset* NvBlastCreateAsset(void* mem, const NvBlastAssetDesc* desc, void* scratch, NvBlastLog logFn);
NV_C_API size_t NvBlastAssetGetFamilyMemorySize(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API size_t NvBlastAssetGetFamilyMemorySizeFromSizeData(const NvBlastAssetMemSizeData& sizeData, NvBlastLog logFn);
NV_C_API NvBlastAssetMemSizeData NvBlastAssetMemSizeDataFromAsset(const NvBlastAsset* asset);
NV_C_API NvBlastFamily* NvBlastAssetCreateFamily(void* mem, const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API NvBlastFamily* NvBlastAssetCreateFamilyFromSizeData(void* mem, const NvBlastAssetMemSizeData& sizeData, NvBlastLog logFn);
NV_C_API NvBlastID NvBlastAssetGetID(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API bool NvBlastAssetSetID(NvBlastAsset* asset, const NvBlastID* id, NvBlastLog logFn);
NV_C_API uint32_t NvBlastAssetGetFormatVersion(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API uint32_t NvBlastAssetGetSize(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API uint32_t NvBlastAssetGetChunkCount(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API uint32_t NvBlastAssetGetSupportChunkCount(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API uint32_t NvBlastAssetGetLeafChunkCount(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API uint32_t NvBlastAssetGetFirstSubsupportChunkIndex(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API uint32_t NvBlastAssetGetBondCount(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API const NvBlastSupportGraph NvBlastAssetGetSupportGraph(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API const uint32_t* NvBlastAssetGetChunkToGraphNodeMap(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API const NvBlastChunk* NvBlastAssetGetChunks(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API const NvBlastBond* NvBlastAssetGetBonds(const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API uint32_t NvBlastAssetGetActorSerializationSizeUpperBound(const NvBlastAsset* asset, NvBlastLog logFn);
// NvBlastAsset helper functions
NV_C_API bool NvBlastEnsureAssetExactSupportCoverage(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount, void* scratch, NvBlastLog logFn);
NV_C_API bool NvBlastBuildAssetDescChunkReorderMap(uint32_t* chunkReorderMap, const NvBlastChunkDesc* chunkDescs, uint32_t chunkCount, void* scratch, NvBlastLog logFn);
NV_C_API void NvBlastApplyAssetDescChunkReorderMap
(
NvBlastChunkDesc* reorderedChunkDescs,
const NvBlastChunkDesc* chunkDescs,
uint32_t chunkCount,
NvBlastBondDesc* bondDescs,
uint32_t bondCount,
const uint32_t* chunkReorderMap,
bool keepBondNormalChunkOrder,
NvBlastLog logFn
);
NV_C_API void NvBlastApplyAssetDescChunkReorderMapInPlace
(
NvBlastChunkDesc* chunkDescs,
uint32_t chunkCount,
NvBlastBondDesc* bondDescs,
uint32_t bondCount,
const uint32_t* chunkReorderMap,
bool keepBondNormalChunkOrder,
void* scratch,
NvBlastLog logFn
);
NV_C_API bool NvBlastReorderAssetDescChunks
(
NvBlastChunkDesc* chunkDescs,
uint32_t chunkCount,
NvBlastBondDesc* bondDescs,
uint32_t bondCount,
uint32_t* chunkReorderMap,
bool keepBondNormalChunkOrder,
void* scratch,
NvBlastLog logFn
);
// NvBlastFamily functions
NV_C_API uint32_t NvBlastFamilyGetFormatVersion(const NvBlastFamily* family, NvBlastLog logFn);
NV_C_API const NvBlastAsset* NvBlastFamilyGetAsset(const NvBlastFamily* family, NvBlastLog logFn);
NV_C_API void NvBlastFamilySetAsset(NvBlastFamily* family, const NvBlastAsset* asset, NvBlastLog logFn);
NV_C_API uint32_t NvBlastFamilyGetSize(const NvBlastFamily* family, NvBlastLog logFn);
NV_C_API NvBlastID NvBlastFamilyGetAssetID(const NvBlastFamily* family, NvBlastLog logFn);
NV_C_API size_t NvBlastFamilyGetRequiredScratchForCreateFirstActor(const NvBlastFamily* family, NvBlastLog logFn);
NV_C_API NvBlastActor* NvBlastFamilyCreateFirstActor(NvBlastFamily* family, const NvBlastActorDesc* desc, void* scratch, NvBlastLog logFn);
NV_C_API uint32_t NvBlastFamilyGetActorCount(const NvBlastFamily* family, NvBlastLog logFn);
NV_C_API NvBlastActor* NvBlastFamilyDeserializeActor(NvBlastFamily* family, const void* buffer, NvBlastLog logFn);
NV_C_API uint32_t NvBlastFamilyGetActors(NvBlastActor** actors, uint32_t actorsSize, const NvBlastFamily* family, NvBlastLog logFn);
NV_C_API NvBlastActor* NvBlastFamilyGetActorByIndex(const NvBlastFamily* family, uint32_t actorIndex, NvBlastLog logFn);
NV_C_API NvBlastActor* NvBlastFamilyGetChunkActor(const NvBlastFamily* family, uint32_t chunkIndex, NvBlastLog logFn);
NV_C_API uint32_t* NvBlastFamilyGetChunkActorIndices(const NvBlastFamily* family, NvBlastLog logFn);
NV_C_API uint32_t NvBlastFamilyGetMaxActorCount(const NvBlastFamily* family, NvBlastLog logFn);
// NvBlastActor accessor, serialization, and deactivation functions
NV_C_API uint32_t NvBlastActorGetVisibleChunkCount(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API uint32_t NvBlastActorGetVisibleChunkIndices(uint32_t* visibleChunkIndices, uint32_t visibleChunkIndicesSize, const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API uint32_t NvBlastActorGetGraphNodeCount(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API uint32_t NvBlastActorGetGraphNodeIndices(uint32_t* graphNodeIndices, uint32_t graphNodeIndicesSize, const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API const float* NvBlastActorGetBondHealths(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API const float* NvBlastActorGetCachedBondHeaths(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API bool NvBlastActorCacheBondHeath(const NvBlastActor* actor, uint32_t bondIndex, NvBlastLog logFn);
NV_C_API uint32_t NvBlastActorGetSerializationSize(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API uint32_t NvBlastActorSerialize(void* buffer, uint32_t bufferSize, const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API NvBlastFamily* NvBlastActorGetFamily(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API uint32_t NvBlastActorGetIndex(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API bool NvBlastActorDeactivate(NvBlastActor* actor, NvBlastLog logFn);
// NvBlastActor damage and fracturing functions
NV_C_API void NvBlastActorGenerateFracture
(
NvBlastFractureBuffers* commandBuffers,
const NvBlastActor* actor,
const NvBlastDamageProgram program,
const void* programParams,
NvBlastLog logFn,
NvBlastTimers* timers
);
NV_C_API void NvBlastActorApplyFracture
(
NvBlastFractureBuffers* eventBuffers,
NvBlastActor* actor,
const NvBlastFractureBuffers* commands,
NvBlastLog logFn,
NvBlastTimers* timers
);
NV_C_API uint32_t NvBlastActorSplit
(
NvBlastActorSplitEvent* result,
NvBlastActor* actor,
uint32_t newActorsMaxCount,
void* scratch,
NvBlastLog logFn,
NvBlastTimers* timers
);
NV_C_API size_t NvBlastActorGetRequiredScratchForSplit(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API uint32_t NvBlastActorGetMaxActorCountForSplit(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API bool NvBlastActorCanFracture(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API bool NvBlastActorIsSplitRequired(const NvBlastActor* actor, NvBlastLog logFn);
NV_C_API bool NvBlastActorHasExternalBonds(const NvBlastActor* actor, NvBlastLog logFn);
// DEPRICATED: remove on next major version bump
#define NvBlastActorIsBoundToWorld NvBlastActorHasExternalBonds
// NvBlastTimers functions and helpers
NV_C_API void NvBlastTimersReset(NvBlastTimers* timers);
NV_C_API double NvBlastTicksToSeconds(int64_t ticks);
#endif // ifndef NVBLAST_H