aboutsummaryrefslogtreecommitdiff
path: root/sdk/lowlevel/source/NvBlastActor.cpp
diff options
context:
space:
mode:
authorAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
committerAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
commit236f03c0b9a4982328ed1201978f7f69d192d9b2 (patch)
treee486f2fa39dba203563895541e92c60ed3e25759 /sdk/lowlevel/source/NvBlastActor.cpp
parentAdded screens to welcome page (diff)
downloadblast-236f03c0b9a4982328ed1201978f7f69d192d9b2.tar.xz
blast-236f03c0b9a4982328ed1201978f7f69d192d9b2.zip
Blast 1.1 release (windows / linux)
see docs/release_notes.txt for details
Diffstat (limited to 'sdk/lowlevel/source/NvBlastActor.cpp')
-rw-r--r--sdk/lowlevel/source/NvBlastActor.cpp629
1 files changed, 146 insertions, 483 deletions
diff --git a/sdk/lowlevel/source/NvBlastActor.cpp b/sdk/lowlevel/source/NvBlastActor.cpp
index b93c47a..afed7bb 100644
--- a/sdk/lowlevel/source/NvBlastActor.cpp
+++ b/sdk/lowlevel/source/NvBlastActor.cpp
@@ -1,12 +1,30 @@
-/*
-* 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#include "NvBlastActor.h"
#include "NvBlastFamilyGraph.h"
@@ -24,29 +42,11 @@ namespace Nv
namespace Blast
{
-//////// Local helper functions ////////
-
-#if NVBLAST_CHECK_PARAMS
-/**
-Helper function to validate fracture buffer values being meaningful.
-*/
-static inline bool isValid(const NvBlastFractureBuffers* buffers)
-{
- if (buffers->chunkFractureCount != 0 && buffers->chunkFractures == nullptr)
- return false;
-
- if (buffers->bondFractureCount != 0 && buffers->bondFractures == nullptr)
- return false;
-
- return true;
-}
-#endif
-
//////// Actor static methods ////////
size_t Actor::createRequiredScratch(const NvBlastFamily* family)
{
-#if NVBLAST_CHECK_PARAMS
+#if NVBLASTLL_CHECK_PARAMS
if (family == nullptr || reinterpret_cast<const FamilyHeader*>(family)->m_asset == nullptr)
{
NVBLAST_ALWAYS_ASSERT();
@@ -61,22 +61,22 @@ size_t Actor::createRequiredScratch(const NvBlastFamily* family)
Actor* Actor::create(NvBlastFamily* family, const NvBlastActorDesc* desc, void* scratch, NvBlastLog logFn)
{
- NVBLAST_CHECK(family != nullptr, logFn, "Actor::create: NULL family pointer input.", return nullptr);
- NVBLAST_CHECK(reinterpret_cast<FamilyHeader*>(family)->m_asset != nullptr, logFn, "Actor::create: family has NULL asset.", return nullptr);
- NVBLAST_CHECK(reinterpret_cast<FamilyHeader*>(family)->m_asset->m_graph.m_nodeCount != 0, logFn, "Actor::create: family's asset has no support chunks.", return nullptr);
- NVBLAST_CHECK(desc != nullptr, logFn, "Actor::create: NULL desc pointer input.", return nullptr);
- NVBLAST_CHECK(scratch != nullptr, logFn, "Actor::create: NULL scratch input.", return nullptr);
+ NVBLASTLL_CHECK(family != nullptr, logFn, "Actor::create: NULL family pointer input.", return nullptr);
+ NVBLASTLL_CHECK(reinterpret_cast<FamilyHeader*>(family)->m_asset != nullptr, logFn, "Actor::create: family has NULL asset.", return nullptr);
+ NVBLASTLL_CHECK(reinterpret_cast<FamilyHeader*>(family)->m_asset->m_graph.m_nodeCount != 0, logFn, "Actor::create: family's asset has no support chunks.", return nullptr);
+ NVBLASTLL_CHECK(desc != nullptr, logFn, "Actor::create: NULL desc pointer input.", return nullptr);
+ NVBLASTLL_CHECK(scratch != nullptr, logFn, "Actor::create: NULL scratch input.", return nullptr);
FamilyHeader* header = reinterpret_cast<FamilyHeader*>(family);
if (header->m_actorCount > 0)
{
- NVBLAST_LOG_ERROR(logFn, "Actor::create: input family is not empty.");
+ NVBLASTLL_LOG_ERROR(logFn, "Actor::create: input family is not empty.");
return nullptr;
}
const Asset& solverAsset = *static_cast<const Asset*>(header->m_asset);
- const Nv::Blast::SupportGraph& graph = solverAsset.m_graph;
+ const SupportGraph& graph = solverAsset.m_graph;
// Lower support chunk healths - initialize
float* lowerSupportChunkHealths = header->getLowerSupportChunkHealths();
@@ -190,14 +190,14 @@ uint32_t Actor::damageBond(const NvBlastBondFractureData& cmd)
void Actor::generateFracture(NvBlastFractureBuffers* commandBuffers, const NvBlastDamageProgram& program, const NvBlastProgramParams* programParams,
NvBlastLog logFn, NvBlastTimers* timers) const
{
- NVBLAST_CHECK(commandBuffers != nullptr, logFn, "Actor::generateFracture: NULL commandBuffers pointer input.", return);
- NVBLAST_CHECK(isValid(commandBuffers), logFn, "NvBlastActorGenerateFracture: commandBuffers memory is NULL but size is > 0.",
+ NVBLASTLL_CHECK(commandBuffers != nullptr, logFn, "Actor::generateFracture: NULL commandBuffers pointer input.", return);
+ NVBLASTLL_CHECK(isValid(commandBuffers), logFn, "NvBlastActorGenerateFracture: commandBuffers memory is NULL but size is > 0.",
commandBuffers->bondFractureCount = 0; commandBuffers->chunkFractureCount = 0; return);
-#if NVBLAST_CHECK_PARAMS
+#if NVBLASTLL_CHECK_PARAMS
if (commandBuffers->bondFractureCount == 0 && commandBuffers->chunkFractureCount == 0)
{
- NVBLAST_LOG_WARNING(logFn, "NvBlastActorGenerateFracture: commandBuffers do not provide any space.");
+ NVBLASTLL_LOG_WARNING(logFn, "NvBlastActorGenerateFracture: commandBuffers do not provide any space.");
return;
}
#endif
@@ -221,7 +221,9 @@ void Actor::generateFracture(NvBlastFractureBuffers* commandBuffers, const NvBla
graph->getAdjacentNodeIndices(),
graph->getAdjacentBondIndices(),
getBonds(),
- getBondHealths()
+ getChunks(),
+ getBondHealths(),
+ getLowerSupportChunkHealths()
};
program.graphShaderFunction(commandBuffers, &shaderActor, programParams);
@@ -252,374 +254,6 @@ void Actor::generateFracture(NvBlastFractureBuffers* commandBuffers, const NvBla
}
-void Actor::fractureSubSupportNoEvents(uint32_t chunkIndex, uint32_t suboffset, float healthDamage, float* chunkHealths, const NvBlastChunk* chunks)
-{
- const NvBlastChunk& chunk = chunks[chunkIndex];
- uint32_t numChildren = chunk.childIndexStop - chunk.firstChildIndex;
-
- if (numChildren > 0)
- {
- healthDamage /= numChildren;
- for (uint32_t childIndex = chunk.firstChildIndex; childIndex < chunk.childIndexStop; childIndex++)
- {
- float& health = chunkHealths[childIndex - suboffset];
- if (health > 0.0f)
- {
- float remainingDamage = healthDamage - health;
- health -= healthDamage;
-
- NVBLAST_ASSERT(chunks[childIndex].parentChunkIndex == chunkIndex);
-
- if (health <= 0.0f && remainingDamage > 0.0f)
- {
- fractureSubSupportNoEvents(childIndex, suboffset, remainingDamage, chunkHealths, chunks);
- }
- }
- }
- }
-}
-
-
-void Actor::fractureSubSupport(uint32_t chunkIndex, uint32_t suboffset, float healthDamage, float* chunkHealths, const NvBlastChunk* chunks, NvBlastChunkFractureData* outBuffer, uint32_t* currentIndex, const uint32_t maxCount)
-{
- const NvBlastChunk& chunk = chunks[chunkIndex];
- uint32_t numChildren = chunk.childIndexStop - chunk.firstChildIndex;
-
- if (numChildren > 0)
- {
- healthDamage /= numChildren;
- for (uint32_t childIndex = chunk.firstChildIndex; childIndex < chunk.childIndexStop; childIndex++)
- {
- float& health = chunkHealths[childIndex - suboffset];
- if (health > 0.0f)
- {
- float remainingDamage = healthDamage - health;
- health -= healthDamage;
-
- NVBLAST_ASSERT(chunks[childIndex].parentChunkIndex == chunkIndex);
-
- if (*currentIndex < maxCount)
- {
- NvBlastChunkFractureData& event = outBuffer[*currentIndex];
- event.userdata = chunks[childIndex].userData;
- event.chunkIndex = childIndex;
- event.health = health;
- }
- (*currentIndex)++;
-
- if (health <= 0.0f && remainingDamage > 0.0f)
- {
- fractureSubSupport(childIndex, suboffset, remainingDamage, chunkHealths, chunks, outBuffer, currentIndex, maxCount);
- }
- }
- }
- }
-
-}
-
-
-void Actor::fractureNoEvents(uint32_t chunkFractureCount, const NvBlastChunkFractureData* chunkFractures)
-{
- const Asset& asset = *getAsset();
- const SupportGraph& graph = *getGraph();
- const uint32_t* graphAdjacencyPartition = graph.getAdjacencyPartition();
- const uint32_t* graphAdjacentNodeIndices = graph.getAdjacentNodeIndices();
- float* bondHealths = getBondHealths();
- float* chunkHealths = getLowerSupportChunkHealths();
- float* subChunkHealths = getSubsupportChunkHealths();
- const NvBlastChunk* chunks = getChunks();
-
- for (uint32_t i = 0; i < chunkFractureCount; ++i)
- {
- const NvBlastChunkFractureData& command = chunkFractures[i];
- const uint32_t chunkIndex = command.chunkIndex;
- const uint32_t chunkHealthIndex = asset.getContiguousLowerSupportIndex(chunkIndex);
- NVBLAST_ASSERT(!isInvalidIndex(chunkHealthIndex));
- if (isInvalidIndex(chunkHealthIndex))
- {
- continue;
- }
- float& health = chunkHealths[chunkHealthIndex];
- if (health > 0.0f && command.health > 0.0f)
- {
- const uint32_t nodeIndex = asset.getChunkToGraphNodeMap()[chunkIndex];
- if (getGraphNodeCount() > 1 && !isInvalidIndex(nodeIndex))
- {
- for (uint32_t adjacentIndex = graphAdjacencyPartition[nodeIndex]; adjacentIndex < graphAdjacencyPartition[nodeIndex + 1]; adjacentIndex++)
- {
-
- const uint32_t bondIndex = graph.findBond(nodeIndex, graphAdjacentNodeIndices[adjacentIndex]);
- NVBLAST_ASSERT(!isInvalidIndex(bondIndex));
- if (bondHealths[bondIndex] > 0.0f)
- {
- bondHealths[bondIndex] = 0.0f;
- }
- }
- getFamilyGraph()->notifyNodeRemoved(getIndex(), nodeIndex, &graph);
- }
-
- health -= command.health;
-
- const float remainingDamage = -health;
-
- if (remainingDamage > 0.0f) // node chunk has been damaged beyond its health
- {
- uint32_t firstSubOffset = getFirstSubsupportChunkIndex();
- fractureSubSupportNoEvents(chunkIndex, firstSubOffset, remainingDamage, subChunkHealths, chunks);
- }
- }
- }
-}
-
-
-void Actor::fractureWithEvents(uint32_t chunkFractureCount, const NvBlastChunkFractureData* commands, NvBlastChunkFractureData* events, uint32_t eventsSize, uint32_t* count)
-{
- const Asset& asset = *getAsset();
- const SupportGraph& graph = *getGraph();
- const uint32_t* graphAdjacencyPartition = graph.getAdjacencyPartition();
- const uint32_t* graphAdjacentNodeIndices = graph.getAdjacentNodeIndices();
- float* bondHealths = getBondHealths();
- float* chunkHealths = getLowerSupportChunkHealths();
- float* subChunkHealths = getSubsupportChunkHealths();
- const NvBlastChunk* chunks = getChunks();
-
- for (uint32_t i = 0; i < chunkFractureCount; ++i)
- {
- const NvBlastChunkFractureData& command = commands[i];
- const uint32_t chunkIndex = command.chunkIndex;
- const uint32_t chunkHealthIndex = asset.getContiguousLowerSupportIndex(chunkIndex);
- NVBLAST_ASSERT(!isInvalidIndex(chunkHealthIndex));
- if (isInvalidIndex(chunkHealthIndex))
- {
- continue;
- }
- float& health = chunkHealths[chunkHealthIndex];
- if (health > 0.0f && command.health > 0.0f)
- {
- const uint32_t nodeIndex = asset.getChunkToGraphNodeMap()[chunkIndex];
- if (getGraphNodeCount() > 1 && !isInvalidIndex(nodeIndex))
- {
- for (uint32_t adjacentIndex = graphAdjacencyPartition[nodeIndex]; adjacentIndex < graphAdjacencyPartition[nodeIndex + 1]; adjacentIndex++)
- {
- const uint32_t bondIndex = graph.findBond(nodeIndex, graphAdjacentNodeIndices[adjacentIndex]);
- NVBLAST_ASSERT(!isInvalidIndex(bondIndex));
- if (bondHealths[bondIndex] > 0.0f)
- {
- bondHealths[bondIndex] = 0.0f;
- }
- }
- getFamilyGraph()->notifyNodeRemoved(getIndex(), nodeIndex, &graph);
- }
-
- health -= command.health;
-
- if (*count < eventsSize)
- {
- NvBlastChunkFractureData& outEvent = events[*count];
- outEvent.userdata = chunks[chunkIndex].userData;
- outEvent.chunkIndex = chunkIndex;
- outEvent.health = health;
- }
- (*count)++;
-
- const float remainingDamage = -health;
-
- if (remainingDamage > 0.0f) // node chunk has been damaged beyond its health
- {
- uint32_t firstSubOffset = getFirstSubsupportChunkIndex();
- fractureSubSupport(chunkIndex, firstSubOffset, remainingDamage, subChunkHealths, chunks, events, count, eventsSize);
- }
- }
- }
-}
-
-
-void Actor::fractureInPlaceEvents(uint32_t chunkFractureCount, NvBlastChunkFractureData* inoutbuffer, uint32_t eventsSize, uint32_t* count)
-{
- const Asset& asset = *getAsset();
- const SupportGraph& graph = *getGraph();
- const uint32_t* graphAdjacencyPartition = graph.getAdjacencyPartition();
- const uint32_t* graphAdjacentNodeIndices = graph.getAdjacentNodeIndices();
- float* bondHealths = getBondHealths();
- float* chunkHealths = getLowerSupportChunkHealths();
- float* subChunkHealths = getSubsupportChunkHealths();
- const NvBlastChunk* chunks = getChunks();
-
- //
- // First level Chunk Fractures
- //
-
- for (uint32_t i = 0; i < chunkFractureCount; ++i)
- {
- const NvBlastChunkFractureData& command = inoutbuffer[i];
- const uint32_t chunkIndex = command.chunkIndex;
- const uint32_t chunkHealthIndex = asset.getContiguousLowerSupportIndex(chunkIndex);
- NVBLAST_ASSERT(!isInvalidIndex(chunkHealthIndex));
- if (isInvalidIndex(chunkHealthIndex))
- {
- continue;
- }
- float& health = chunkHealths[chunkHealthIndex];
- if (health > 0.0f && command.health > 0.0f)
- {
- const uint32_t nodeIndex = asset.getChunkToGraphNodeMap()[chunkIndex];
- if (getGraphNodeCount() > 1 && !isInvalidIndex(nodeIndex))
- {
- for (uint32_t adjacentIndex = graphAdjacencyPartition[nodeIndex]; adjacentIndex < graphAdjacencyPartition[nodeIndex + 1]; adjacentIndex++)
- {
- const uint32_t bondIndex = graph.findBond(nodeIndex, graphAdjacentNodeIndices[adjacentIndex]);
- NVBLAST_ASSERT(!isInvalidIndex(bondIndex));
- if (bondHealths[bondIndex] > 0.0f)
- {
- bondHealths[bondIndex] = 0.0f;
- }
- }
- getFamilyGraph()->notifyNodeRemoved(getIndex(), nodeIndex, &graph);
- }
-
- health -= command.health;
-
- NvBlastChunkFractureData& outEvent = inoutbuffer[(*count)++];
- outEvent.userdata = chunks[chunkIndex].userData;
- outEvent.chunkIndex = chunkIndex;
- outEvent.health = health;
- }
- }
-
- //
- // Hierarchical Chunk Fractures
- //
-
- uint32_t commandedChunkFractures = *count;
-
- for (uint32_t i = 0; i < commandedChunkFractures; ++i)
- {
- NvBlastChunkFractureData& event = inoutbuffer[i];
- const uint32_t chunkIndex = event.chunkIndex;
-
- const float remainingDamage = -event.health;
- if (remainingDamage > 0.0f) // node chunk has been damaged beyond its health
- {
- uint32_t firstSubOffset = getFirstSubsupportChunkIndex();
- fractureSubSupport(chunkIndex, firstSubOffset, remainingDamage, subChunkHealths, chunks, inoutbuffer, count, eventsSize);
- }
- }
-}
-
-
-void Actor::applyFracture(NvBlastFractureBuffers* eventBuffers, const NvBlastFractureBuffers* commands, NvBlastLog logFn, NvBlastTimers* timers)
-{
- NVBLAST_CHECK(commands != nullptr, logFn, "Actor::applyFracture: NULL commands pointer input.", return);
- NVBLAST_CHECK(isValid(commands), logFn, "Actor::applyFracture: commands memory is NULL but size is > 0.", return);
- NVBLAST_CHECK(eventBuffers == nullptr || isValid(eventBuffers), logFn, "NvBlastActorApplyFracture: eventBuffers memory is NULL but size is > 0.",
- eventBuffers->bondFractureCount = 0; eventBuffers->chunkFractureCount = 0; return);
-
-#if NVBLAST_CHECK_PARAMS
- if (eventBuffers != nullptr && eventBuffers->bondFractureCount == 0 && eventBuffers->chunkFractureCount == 0)
- {
- NVBLAST_LOG_WARNING(logFn, "NvBlastActorApplyFracture: eventBuffers do not provide any space.");
- return;
- }
-#endif
-
-#if NV_PROFILE
- Time time;
-#else
- NV_UNUSED(timers);
-#endif
-
- //
- // Chunk Fracture
- //
-
- if (eventBuffers == nullptr || eventBuffers->chunkFractures == nullptr)
- {
- // immediate hierarchical fracture
- fractureNoEvents(commands->chunkFractureCount, commands->chunkFractures);
- }
- else if (eventBuffers->chunkFractures != commands->chunkFractures)
- {
- // immediate hierarchical fracture
- uint32_t count = 0;
- fractureWithEvents(commands->chunkFractureCount, commands->chunkFractures, eventBuffers->chunkFractures, eventBuffers->chunkFractureCount, &count);
-
- if (count > eventBuffers->chunkFractureCount)
- {
- NVBLAST_LOG_WARNING(logFn, "NvBlastActorApplyFracture: eventBuffers too small. Chunk events were lost.");
- }
- else
- {
- eventBuffers->chunkFractureCount = count;
- }
- }
- else if (eventBuffers->chunkFractures == commands->chunkFractures)
- {
- // compacting first
- uint32_t count = 0;
- fractureInPlaceEvents(commands->chunkFractureCount, commands->chunkFractures, eventBuffers->chunkFractureCount, &count);
-
- if (count > eventBuffers->chunkFractureCount)
- {
- NVBLAST_LOG_WARNING(logFn, "NvBlastActorApplyFracture: eventBuffers too small. Chunk events were lost.");
- }
- else
- {
- eventBuffers->chunkFractureCount = count;
- }
- }
-
- //
- // Bond Fracture
- //
-
- uint32_t outCount = 0;
- const uint32_t eventBufferSize = eventBuffers ? eventBuffers->bondFractureCount : 0;
-
- NvBlastBond* bonds = getBonds();
- float* bondHealths = getBondHealths();
- for (uint32_t i = 0; i < commands->bondFractureCount; ++i)
- {
- const NvBlastBondFractureData& frac = commands->bondFractures[i];
-
- const uint32_t bondIndex = damageBond(frac.nodeIndex0, frac.nodeIndex1, frac.health);
-
- if (!isInvalidIndex(bondIndex))
- {
- if (eventBuffers && eventBuffers->bondFractures)
- {
- if (outCount < eventBufferSize)
- {
- NvBlastBondFractureData& outEvent = eventBuffers->bondFractures[outCount];
- outEvent.userdata = bonds[bondIndex].userData;
- outEvent.nodeIndex0 = frac.nodeIndex0;
- outEvent.nodeIndex1 = frac.nodeIndex1;
- outEvent.health = bondHealths[bondIndex];
- }
- }
- outCount++;
- }
- }
-
- if (eventBuffers && eventBuffers->bondFractures)
- {
- if (outCount > eventBufferSize)
- {
- NVBLAST_LOG_WARNING(logFn, "NvBlastActorApplyFracture: eventBuffers too small. Bond events were lost.");
- }
- else
- {
- eventBuffers->bondFractureCount = outCount;
- }
- }
-
-#if NV_PROFILE
- if (timers != nullptr)
- {
- timers->fracture += time.getElapsedTicks();
- }
-#endif
-
-}
size_t Actor::splitRequiredScratch() const
@@ -630,9 +264,9 @@ size_t Actor::splitRequiredScratch() const
uint32_t Actor::split(NvBlastActorSplitEvent* result, uint32_t newActorsMaxCount, void* scratch, NvBlastLog logFn, NvBlastTimers* timers)
{
- NVBLAST_CHECK(result != nullptr, logFn, "Actor::split: NULL result pointer input.", return 0);
- NVBLAST_CHECK(newActorsMaxCount > 0 && result->newActors != nullptr, logFn, "NvBlastActorSplit: no space for results provided.", return 0);
- NVBLAST_CHECK(scratch != nullptr, logFn, "Actor::split: NULL scratch pointer input.", return 0);
+ NVBLASTLL_CHECK(result != nullptr, logFn, "Actor::split: NULL result pointer input.", return 0);
+ NVBLASTLL_CHECK(newActorsMaxCount > 0 && result->newActors != nullptr, logFn, "NvBlastActorSplit: no space for results provided.", return 0);
+ NVBLASTLL_CHECK(scratch != nullptr, logFn, "Actor::split: NULL scratch pointer input.", return 0);
#if NV_PROFILE
Time time;
@@ -708,10 +342,21 @@ uint32_t Actor::split(NvBlastActorSplitEvent* result, uint32_t newActorsMaxCount
#endif
// Recalculate visible chunk lists if the graph nodes have been redistributed
+ uint32_t actualActorsCount = 0;
for (uint32_t i = 0; i < actorsCount; ++i)
{
- newActors[i]->updateVisibleChunksFromGraphNodes();
+ newActors[actualActorsCount] = newActors[i];
+ newActors[actualActorsCount]->updateVisibleChunksFromGraphNodes();
+ if (newActors[actualActorsCount]->getVisibleChunkCount() > 0) // If we've split such that the world node is by itself, it will have no visible chunks
+ {
+ ++actualActorsCount;
+ }
+ else
+ {
+ getFamilyHeader()->returnActor(*newActors[actualActorsCount]);
+ }
}
+ actorsCount = actualActorsCount;
#if NV_PROFILE
if (timers != nullptr)
@@ -780,7 +425,7 @@ uint32_t Actor::partitionMultipleGraphNodes(Actor** newActors, uint32_t newActor
// Check for single subsupport chunk, no partitioning
if (m_graphNodeCount <= 1)
{
- NVBLAST_LOG_WARNING(logFn, "Nv::Blast::Actor::partitionMultipleGraphNodes: actor is a single lower-support chunk, and cannot be partitioned by this function.");
+ NVBLASTLL_LOG_WARNING(logFn, "Nv::Blast::Actor::partitionMultipleGraphNodes: actor is a single lower-support chunk, and cannot be partitioned by this function.");
return 0;
}
@@ -810,7 +455,11 @@ uint32_t Actor::partitionMultipleGraphNodes(Actor** newActors, uint32_t newActor
if (islandID == thisActorIndex)
{
- m_leafChunkCount += subtreeLeafChunkCounts[graphChunkIndices[graphNodeIndex]];
+ const uint32_t graphChunkIndex = graphChunkIndices[graphNodeIndex];
+ if (!isInvalidIndex(graphChunkIndex)) // Invalid if this is the world chunk
+ {
+ m_leafChunkCount += subtreeLeafChunkCounts[graphChunkIndex];
+ }
lastGraphNodeIndex = graphNodeIndex;
continue; // Leave the chunk in this actor
}
@@ -855,7 +504,11 @@ uint32_t Actor::partitionMultipleGraphNodes(Actor** newActors, uint32_t newActor
newActor->m_firstGraphNodeIndex = graphNodeIndex;
++newActor->m_graphNodeCount;
// Add to the actor's leaf chunk count
- newActor->m_leafChunkCount += subtreeLeafChunkCounts[graphChunkIndices[graphNodeIndex]];
+ const uint32_t graphChunkIndex = graphChunkIndices[graphNodeIndex];
+ if (!isInvalidIndex(graphChunkIndex)) // Invalid if this is the world chunk
+ {
+ newActor->m_leafChunkCount += subtreeLeafChunkCounts[graphChunkIndex];
+ }
}
if (m_graphNodeCount > 0)
@@ -878,7 +531,7 @@ uint32_t Actor::partitionMultipleGraphNodes(Actor** newActors, uint32_t newActor
if (overflow)
{
- NVBLAST_LOG_WARNING(logFn, "Nv::Blast::Actor::partitionMultipleGraphNodes: input newActors array could not hold all actors generated.");
+ NVBLASTLL_LOG_WARNING(logFn, "Nv::Blast::Actor::partitionMultipleGraphNodes: input newActors array could not hold all actors generated.");
}
return newActorCount;
@@ -892,7 +545,7 @@ uint32_t Actor::partitionSingleLowerSupportChunk(Actor** newActors, uint32_t new
// Ensure this is a single subsupport chunk, no partitioning
if (m_graphNodeCount > 1)
{
- NVBLAST_LOG_WARNING(logFn, "Nv::Blast::Actor::partitionSingleLowerSupportChunk: actor is not a single lower-support chunk, and cannot be partitioned by this function.");
+ NVBLASTLL_LOG_WARNING(logFn, "Nv::Blast::Actor::partitionSingleLowerSupportChunk: actor is not a single lower-support chunk, and cannot be partitioned by this function.");
return 0;
}
@@ -901,6 +554,12 @@ uint32_t Actor::partitionSingleLowerSupportChunk(Actor** newActors, uint32_t new
// The conditional (visible vs. support chunk) is needed because we allow single-child chunk chains
// This makes it possible that an actor with a single support chunk will have a different visible chunk (ancestor of the support chunk)
const uint32_t chunkIndex = m_graphNodeCount == 0 ? m_firstVisibleChunkIndex : getGraph()->getChunkIndices()[m_firstGraphNodeIndex];
+
+ if (isInvalidIndex(chunkIndex))
+ {
+ return 0; // This actor has no chunks; only a graph node representing the world
+ }
+
NVBLAST_ASSERT(isInvalidIndex(header->getVisibleChunkIndexLinks()[chunkIndex].m_adj[1]));
const NvBlastChunk& chunk = header->m_asset->getChunks()[chunkIndex];
@@ -909,7 +568,7 @@ uint32_t Actor::partitionSingleLowerSupportChunk(Actor** newActors, uint32_t new
// Warn if we cannot fit all child chunks in the output list
if (childCount > newActorsSize)
{
- NVBLAST_LOG_WARNING(logFn, "Nv::Blast::Actor::partitionSingleLowerSupportChunk: input newActors array will not hold all actors generated.");
+ NVBLASTLL_LOG_WARNING(logFn, "Nv::Blast::Actor::partitionSingleLowerSupportChunk: input newActors array will not hold all actors generated.");
childCount = newActorsSize;
}
@@ -959,7 +618,7 @@ void Actor::updateVisibleChunksFromGraphNodes()
Actor* actors = header->getActors();
IndexDLink<uint32_t>* visibleChunkIndexLinks = header->getVisibleChunkIndexLinks();
uint32_t* chunkActorIndices = header->getChunkActorIndices();
- const Nv::Blast::SupportGraph& graph = asset->m_graph;
+ const SupportGraph& graph = asset->m_graph;
const uint32_t* graphChunkIndices = graph.getChunkIndices();
const NvBlastChunk* chunks = asset->getChunks();
const uint32_t upperSupportChunkCount = asset->getUpperSupportChunkCount();
@@ -968,7 +627,11 @@ void Actor::updateVisibleChunksFromGraphNodes()
const uint32_t* graphNodeIndexLinks = header->getGraphNodeIndexLinks();
for (uint32_t graphNodeIndex = m_firstGraphNodeIndex; !isInvalidIndex(graphNodeIndex); graphNodeIndex = graphNodeIndexLinks[graphNodeIndex])
{
- updateVisibleChunksFromSupportChunk<Actor>(actors, visibleChunkIndexLinks, chunkActorIndices, thisActorIndex, graphChunkIndices[graphNodeIndex], chunks, upperSupportChunkCount);
+ const uint32_t supportChunkIndex = graphChunkIndices[graphNodeIndex];
+ if (!isInvalidIndex(supportChunkIndex)) // Invalid if this is the world chunk
+ {
+ updateVisibleChunksFromSupportChunk<Actor>(actors, visibleChunkIndexLinks, chunkActorIndices, thisActorIndex, graphChunkIndices[graphNodeIndex], chunks, upperSupportChunkCount);
+ }
}
}
@@ -983,9 +646,9 @@ extern "C"
NvBlastActor* NvBlastFamilyCreateFirstActor(NvBlastFamily* family, const NvBlastActorDesc* desc, void* scratch, NvBlastLog logFn)
{
- NVBLAST_CHECK(family != nullptr, logFn, "NvBlastFamilyCreateFirstActor: NULL family input.", return nullptr);
- NVBLAST_CHECK(desc != nullptr, logFn, "NvBlastFamilyCreateFirstActor: NULL desc input.", return nullptr);
- NVBLAST_CHECK(scratch != nullptr, logFn, "NvBlastFamilyCreateFirstActor: NULL scratch input.", return nullptr);
+ NVBLASTLL_CHECK(family != nullptr, logFn, "NvBlastFamilyCreateFirstActor: NULL family input.", return nullptr);
+ NVBLASTLL_CHECK(desc != nullptr, logFn, "NvBlastFamilyCreateFirstActor: NULL desc input.", return nullptr);
+ NVBLASTLL_CHECK(scratch != nullptr, logFn, "NvBlastFamilyCreateFirstActor: NULL scratch input.", return nullptr);
return Nv::Blast::Actor::create(family, desc, scratch, logFn);
}
@@ -993,8 +656,8 @@ NvBlastActor* NvBlastFamilyCreateFirstActor(NvBlastFamily* family, const NvBlast
size_t NvBlastFamilyGetRequiredScratchForCreateFirstActor(const NvBlastFamily* family, NvBlastLog logFn)
{
- NVBLAST_CHECK(family != nullptr, logFn, "NvBlastFamilyGetRequiredScratchForCreateFirstActor: NULL family input.", return 0);
- NVBLAST_CHECK(reinterpret_cast<const Nv::Blast::FamilyHeader*>(family)->m_asset != nullptr,
+ NVBLASTLL_CHECK(family != nullptr, logFn, "NvBlastFamilyGetRequiredScratchForCreateFirstActor: NULL family input.", return 0);
+ NVBLASTLL_CHECK(reinterpret_cast<const Nv::Blast::FamilyHeader*>(family)->m_asset != nullptr,
logFn, "NvBlastFamilyGetRequiredScratchForCreateFirstActor: family has NULL asset.", return 0);
return Nv::Blast::Actor::createRequiredScratch(family);
@@ -1003,13 +666,13 @@ size_t NvBlastFamilyGetRequiredScratchForCreateFirstActor(const NvBlastFamily* f
bool NvBlastActorDeactivate(NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorDeactivate: NULL actor input.", return false);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorDeactivate: NULL actor input.", return false);
Nv::Blast::Actor& a = *static_cast<Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_WARNING(logFn, "NvBlastActorDeactivate: inactive actor input.");
+ NVBLASTLL_LOG_WARNING(logFn, "NvBlastActorDeactivate: inactive actor input.");
}
return a.release();
@@ -1018,13 +681,13 @@ bool NvBlastActorDeactivate(NvBlastActor* actor, NvBlastLog logFn)
uint32_t NvBlastActorGetVisibleChunkCount(const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGetVisibleChunkCount: NULL actor input.", return 0);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGetVisibleChunkCount: NULL actor input.", return 0);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetVisibleChunkCount: inactive actor input.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetVisibleChunkCount: inactive actor input.");
return 0;
}
@@ -1034,14 +697,14 @@ uint32_t NvBlastActorGetVisibleChunkCount(const NvBlastActor* actor, NvBlastLog
uint32_t NvBlastActorGetVisibleChunkIndices(uint32_t* visibleChunkIndices, uint32_t visibleChunkIndicesSize, const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(visibleChunkIndices != nullptr, logFn, "NvBlastActorGetVisibleChunkIndices: NULL visibleChunkIndices pointer input.", return 0);
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGetVisibleChunkIndices: NULL actor pointer input.", return 0);
+ NVBLASTLL_CHECK(visibleChunkIndices != nullptr, logFn, "NvBlastActorGetVisibleChunkIndices: NULL visibleChunkIndices pointer input.", return 0);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGetVisibleChunkIndices: NULL actor pointer input.", return 0);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetVisibleChunkIndices: inactive actor pointer input.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetVisibleChunkIndices: inactive actor pointer input.");
return 0;
}
@@ -1058,13 +721,13 @@ uint32_t NvBlastActorGetVisibleChunkIndices(uint32_t* visibleChunkIndices, uint3
uint32_t NvBlastActorGetGraphNodeCount(const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGetGraphNodeCount: NULL actor pointer input.", return 0);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGetGraphNodeCount: NULL actor pointer input.", return 0);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetGraphNodeCount: inactive actor pointer input.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetGraphNodeCount: inactive actor pointer input.");
return 0;
}
@@ -1074,22 +737,27 @@ uint32_t NvBlastActorGetGraphNodeCount(const NvBlastActor* actor, NvBlastLog log
uint32_t NvBlastActorGetGraphNodeIndices(uint32_t* graphNodeIndices, uint32_t graphNodeIndicesSize, const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(graphNodeIndices != nullptr, logFn, "NvBlastActorGetGraphNodeIndices: NULL graphNodeIndices pointer input.", return 0);
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGetGraphNodeIndices: NULL actor pointer input.", return 0);
+ NVBLASTLL_CHECK(graphNodeIndices != nullptr, logFn, "NvBlastActorGetGraphNodeIndices: NULL graphNodeIndices pointer input.", return 0);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGetGraphNodeIndices: NULL actor pointer input.", return 0);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetGraphNodeIndices: inactive actor pointer input.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetGraphNodeIndices: inactive actor pointer input.");
return 0;
}
// Iterate through graph node list and write to supplied array
+ const uint32_t* graphChunkIndices = a.getAsset()->m_graph.getChunkIndices();
uint32_t indexCount = 0;
for (Nv::Blast::Actor::GraphNodeIt i = a; indexCount < graphNodeIndicesSize && (bool)i; ++i)
{
- graphNodeIndices[indexCount++] = (uint32_t)i;
+ const uint32_t graphNodeIndex = (uint32_t)i;
+ if (!Nv::Blast::isInvalidIndex(graphChunkIndices[graphNodeIndex]))
+ {
+ graphNodeIndices[indexCount++] = graphNodeIndex;
+ }
}
return indexCount;
@@ -1098,13 +766,13 @@ uint32_t NvBlastActorGetGraphNodeIndices(uint32_t* graphNodeIndices, uint32_t gr
const float* NvBlastActorGetBondHealths(const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGetBondHealths: NULL actor pointer input.", return nullptr);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGetBondHealths: NULL actor pointer input.", return nullptr);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetBondHealths: inactive actor pointer input.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetBondHealths: inactive actor pointer input.");
return nullptr;
}
@@ -1114,13 +782,13 @@ const float* NvBlastActorGetBondHealths(const NvBlastActor* actor, NvBlastLog lo
NvBlastFamily* NvBlastActorGetFamily(const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGetFamily: NULL actor pointer input.", return nullptr);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGetFamily: NULL actor pointer input.", return nullptr);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetFamily: inactive actor pointer input.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetFamily: inactive actor pointer input.");
return nullptr;
}
@@ -1130,13 +798,13 @@ NvBlastFamily* NvBlastActorGetFamily(const NvBlastActor* actor, NvBlastLog logFn
uint32_t NvBlastActorGetIndex(const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGetIndex: NULL actor pointer input.", return Nv::Blast::invalidIndex<uint32_t>());
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGetIndex: NULL actor pointer input.", return Nv::Blast::invalidIndex<uint32_t>());
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetIndex: actor is not active.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetIndex: actor is not active.");
return Nv::Blast::invalidIndex<uint32_t>();
}
@@ -1154,14 +822,14 @@ void NvBlastActorGenerateFracture
NvBlastTimers* timers
)
{
- NVBLAST_CHECK(commandBuffers != nullptr, logFn, "NvBlastActorGenerateFracture: NULL commandBuffers pointer input.", return);
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGenerateFracture: NULL actor pointer input.", return);
+ NVBLASTLL_CHECK(commandBuffers != nullptr, logFn, "NvBlastActorGenerateFracture: NULL commandBuffers pointer input.", return);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGenerateFracture: NULL actor pointer input.", return);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGenerateFracture: actor is not active.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGenerateFracture: actor is not active.");
commandBuffers->bondFractureCount = 0;
commandBuffers->chunkFractureCount = 0;
return;
@@ -1180,15 +848,15 @@ void NvBlastActorApplyFracture
NvBlastTimers* timers
)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorApplyFracture: NULL actor pointer input.", return);
- NVBLAST_CHECK(commands != nullptr, logFn, "NvBlastActorApplyFracture: NULL commands pointer input.", return);
- NVBLAST_CHECK(Nv::Blast::isValid(commands), logFn, "NvBlastActorApplyFracture: commands memory is NULL but size is > 0.", return);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorApplyFracture: NULL actor pointer input.", return);
+ NVBLASTLL_CHECK(commands != nullptr, logFn, "NvBlastActorApplyFracture: NULL commands pointer input.", return);
+ NVBLASTLL_CHECK(Nv::Blast::isValid(commands), logFn, "NvBlastActorApplyFracture: commands memory is NULL but size is > 0.", return);
Nv::Blast::Actor& a = *static_cast<Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorApplyFracture: actor is not active.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorApplyFracture: actor is not active.");
if (eventBuffers != nullptr)
{
eventBuffers->bondFractureCount = 0;
@@ -1197,19 +865,19 @@ void NvBlastActorApplyFracture
return;
}
- a.applyFracture(eventBuffers, commands, logFn, timers);
+ a.getFamilyHeader()->applyFracture(eventBuffers, commands, &a, logFn, timers);
}
size_t NvBlastActorGetRequiredScratchForSplit(const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGetRequiredScratchForSplit: NULL actor input.", return 0);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGetRequiredScratchForSplit: NULL actor input.", return 0);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetRequiredScratchForSplit: actor is not active.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetRequiredScratchForSplit: actor is not active.");
return 0;
}
@@ -1219,13 +887,13 @@ size_t NvBlastActorGetRequiredScratchForSplit(const NvBlastActor* actor, NvBlast
uint32_t NvBlastActorGetMaxActorCountForSplit(const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorGetMaxActorCountForSplit: NULL actor input.", return 0);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorGetMaxActorCountForSplit: NULL actor input.", return 0);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetMaxActorCountForSplit: actor is not active.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetMaxActorCountForSplit: actor is not active.");
return 0;
}
@@ -1243,16 +911,16 @@ uint32_t NvBlastActorSplit
NvBlastTimers* timers
)
{
- NVBLAST_CHECK(result != nullptr, logFn, "NvBlastActorSplit: NULL result pointer input.", return 0);
- NVBLAST_CHECK(newActorsMaxCount > 0 && result->newActors != nullptr, logFn, "NvBlastActorSplit: no space for results provided.", return 0);
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorSplit: NULL actor pointer input.", return 0);
- NVBLAST_CHECK(scratch != nullptr, logFn, "NvBlastActorSplit: NULL scratch pointer input.", return 0);
+ NVBLASTLL_CHECK(result != nullptr, logFn, "NvBlastActorSplit: NULL result pointer input.", return 0);
+ NVBLASTLL_CHECK(newActorsMaxCount > 0 && result->newActors != nullptr, logFn, "NvBlastActorSplit: no space for results provided.", return 0);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorSplit: NULL actor pointer input.", return 0);
+ NVBLASTLL_CHECK(scratch != nullptr, logFn, "NvBlastActorSplit: NULL scratch pointer input.", return 0);
Nv::Blast::Actor& a = *static_cast<Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorGetIndex: actor is not active.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorGetIndex: actor is not active.");
return 0;
}
@@ -1262,13 +930,13 @@ uint32_t NvBlastActorSplit
bool NvBlastActorCanFracture(const NvBlastActor* actor, NvBlastLog logFn)
{
- NVBLAST_CHECK(actor != nullptr, logFn, "NvBlastActorCanFracture: NULL actor input.", return false);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorCanFracture: NULL actor input.", return false);
const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
if (!a.isActive())
{
- NVBLAST_LOG_ERROR(logFn, "NvBlastActorCanFracture: actor is not active.");
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorCanFracture: actor is not active.");
return false;
}
@@ -1287,30 +955,25 @@ bool NvBlastActorCanFracture(const NvBlastActor* actor, NvBlastLog logFn)
}
-} // extern "C"
+bool NvBlastActorIsBoundToWorld(const NvBlastActor* actor, NvBlastLog logFn)
+{
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorIsBoundToWorld: NULL actor input.", return false);
+ return static_cast<const Nv::Blast::Actor*>(actor)->isBoundToWorld();
+}
-// deprecated API, still used in tests
-uint32_t NvBlastActorClosestChunk(const float point[4], const NvBlastActor* actor, NvBlastLog logFn)
+
+bool NvBlastActorIsSplitRequired(const NvBlastActor* actor, NvBlastLog logFn)
{
- const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
+ NVBLASTLL_CHECK(actor != nullptr, logFn, "NvBlastActorIsSplitRequired: NULL actor input.", return false);
- if (a.isSubSupportChunk())
+ const Nv::Blast::Actor& a = *static_cast<const Nv::Blast::Actor*>(actor);
+ if (!a.isActive())
{
- NVBLAST_LOG_WARNING(logFn, "NvBlastActorClosestChunk: not a graph actor.");
- return Nv::Blast::invalidIndex<uint32_t>();
+ NVBLASTLL_LOG_ERROR(logFn, "NvBlastActorIsSplitRequired: actor is not active.");
+ return false;
}
-
- uint32_t closestNode = Nv::Blast::findNodeByPositionLinked(
- point,
- a.getFirstGraphNodeIndex(),
- a.getFamilyHeader()->getGraphNodeIndexLinks(),
- a.getAsset()->m_graph.getAdjacencyPartition(),
- a.getAsset()->m_graph.getAdjacentNodeIndices(),
- a.getAsset()->m_graph.getAdjacentBondIndices(),
- a.getAsset()->getBonds(),
- a.getFamilyHeader()->getBondHealths()
- );
-
- return a.getAsset()->m_graph.getChunkIndices()[closestNode];
+ return a.isSplitRequired();
}
+
+} // extern "C"