#include <NvBlastExtStressSolver.h>
Classes | |
| struct | DebugBuffer |
| struct | DebugLine |
Public Types | |
| enum | DebugRenderMode { STRESS_GRAPH = 0, STRESS_GRAPH_NODES_IMPULSES = 1, STRESS_GRAPH_BONDS_IMPULSES = 2 } |
Public Member Functions | |
| virtual bool | addAngularVelocity (const NvBlastActor &actor, NvcVec3 localCenterMass, NvcVec3 localAngularVelocity)=0 |
| virtual void | addForce (uint32_t graphNodeIndex, NvcVec3 localForce, ExtForceMode::Enum mode=ExtForceMode::IMPULSE)=0 |
| virtual bool | addForce (const NvBlastActor &actor, NvcVec3 localPosition, NvcVec3 localForce, ExtForceMode::Enum mode=ExtForceMode::IMPULSE)=0 |
| virtual bool | addGravityForce (const NvBlastActor &actor, NvcVec3 localGravity)=0 |
| virtual const DebugBuffer | fillDebugRender (const uint32_t *nodes, uint32_t nodeCount, DebugRenderMode mode, float scale=1.0f)=0 |
| virtual void | generateFractureCommands (NvBlastFractureBuffers &commands)=0 |
| virtual void | generateFractureCommands (const NvBlastActor &actor, NvBlastFractureBuffers &commands)=0 |
| virtual uint32_t | generateFractureCommandsPerActor (const NvBlastActor **actorBuffer, NvBlastFractureBuffers *commandsBuffer, uint32_t bufferSize)=0 |
| virtual uint32_t | getBondCount () const =0 |
| virtual uint32_t | getFrameCount () const =0 |
| uint32_t | getIterationsPerFrame () const |
| virtual uint32_t | getOverstressedBondCount () const =0 |
| virtual const ExtStressSolverSettings & | getSettings () const =0 |
| virtual float | getStressErrorAngular () const =0 |
| virtual float | getStressErrorLinear () const =0 |
| virtual bool | notifyActorCreated (const NvBlastActor &actor)=0 |
| virtual void | notifyActorDestroyed (const NvBlastActor &actor)=0 |
| virtual void | release ()=0 |
| virtual void | reset ()=0 |
| virtual void | setAllNodesInfoFromLL (float density=1.0f)=0 |
| virtual void | setNodeInfo (uint32_t graphNodeIndex, float mass, float volume, NvcVec3 localPosition, bool isStatic)=0 |
| virtual void | setSettings (const ExtStressSolverSettings &settings)=0 |
| virtual void | update ()=0 |
Static Public Member Functions | |
| static ExtStressSolver * | create (NvBlastFamily &family, ExtStressSolverSettings settings=ExtStressSolverSettings()) |
| static uint32_t | getIterationsPerFrame (const ExtStressSolverSettings &settings, uint32_t bondCount) |
Uses NvBlastFamily, allocates and prepares its graph once when it's created. Then it's being quickly updated on every actor split. It uses NvBlastAsset support graph, you can apply forces on nodes and stress on bonds will be calculated as the result. When stress on bond exceeds it's health bond is considered broken (overstressed). Basic usage: 1. Create it with create function once for family 2. Fill node info for every node in support graph or use setAllNodesInfoFromLL() function. 3. Use notifyActorCreated / notifyActorDestroyed whenever actors are created and destroyed in family. 4. Every frame: Apply forces (there are different functions for it see ) 5. Every frame: Call update() for actual solver to process. 6. If getOverstressedBondCount() > 0 use generateFractureCommands() functions to get FractureCommands with bonds fractured
| virtual bool Nv::Blast::ExtStressSolver::addAngularVelocity | ( | const NvBlastActor & | actor, | |
| NvcVec3 | localCenterMass, | |||
| NvcVec3 | localAngularVelocity | |||
| ) | [pure virtual] |
Apply centrifugal force produced by actor's angular movement.
| [in] | actor | The actor to apply impulse on. |
| [in] | localCenterMass | Actor's local center of mass. |
| [in] | localAngularVelocity | Local angular velocity of an actor. |
| virtual void Nv::Blast::ExtStressSolver::addForce | ( | uint32_t | graphNodeIndex, | |
| NvcVec3 | localForce, | |||
| ExtForceMode::Enum | mode = ExtForceMode::IMPULSE | |||
| ) | [pure virtual] |
Apply external impulse on particular node.
| [in] | graphNodeIndex | The graph node index to apply impulse on. See NvBlastSupportGraph. |
| [in] | localForce | Force to apply in local actor's coordinates. |
| [in] | mode | The mode to use when applying the force/impulse(see ExtForceMode) |
| virtual bool Nv::Blast::ExtStressSolver::addForce | ( | const NvBlastActor & | actor, | |
| NvcVec3 | localPosition, | |||
| NvcVec3 | localForce, | |||
| ExtForceMode::Enum | mode = ExtForceMode::IMPULSE | |||
| ) | [pure virtual] |
Apply external impulse on particular actor of family. This function will find nearest actor's graph node to apply impulse on.
| [in] | actor | The actor to apply impulse on. |
| [in] | localPosition | Local position in actor's coordinates to apply impulse on. |
| [in] | localForce | Force to apply in local actor's coordinates. |
| [in] | mode | The mode to use when applying the force/impulse(see ExtForceMode) |
| virtual bool Nv::Blast::ExtStressSolver::addGravityForce | ( | const NvBlastActor & | actor, | |
| NvcVec3 | localGravity | |||
| ) | [pure virtual] |
Apply external gravity on particular actor of family. This function applies gravity on every node withing actor, so it makes sense only for static actors.
| [in] | actor | The actor to apply impulse on. |
| [in] | localGravity | Gravity to apply in local actor's coordinates. ExtForceMode::VELOCITY is used. |
| static ExtStressSolver* Nv::Blast::ExtStressSolver::create | ( | NvBlastFamily & | family, | |
| ExtStressSolverSettings | settings = ExtStressSolverSettings() | |||
| ) | [static] |
Create a new ExtStressSolver.
| [in] | family | The ExtPxFamily instance to calculate stress on. |
| [in] | settings | The settings to be set on ExtStressSolver. |
| virtual const DebugBuffer Nv::Blast::ExtStressSolver::fillDebugRender | ( | const uint32_t * | nodes, | |
| uint32_t | nodeCount, | |||
| DebugRenderMode | mode, | |||
| float | scale = 1.0f | |||
| ) | [pure virtual] |
Fill debug render for passed array of support graph nodes.
NOTE: Returned DebugBuffer points into internal memory which is valid till next fillDebugRender() call.
| [in] | nodes | Node indices of support graph to debug render for. |
| [in] | nodeCount | Node indices count. |
| [in] | mode | Debug render mode. |
| [in] | scale | Scale to be applied on impulses. |
| virtual void Nv::Blast::ExtStressSolver::generateFractureCommands | ( | NvBlastFractureBuffers & | commands | ) | [pure virtual] |
Generate fracture commands for whole family. A bit faster way to get all fractured bonds than calling generateFractureCommands() for every actor.
Calling this function if getOverstressedBondCount() == 0 or actor has no bond doesn't make sense, bondFractureCount will be '0'.
IMPORTANT: NvBlastFractureBuffers::bondFractures will point to internal stress solver memory which will be valid till next call of any of generateFractureCommands() functions or stress solver release() call.
| [in] | commands | Pointer to command buffer to fill. |
| virtual void Nv::Blast::ExtStressSolver::generateFractureCommands | ( | const NvBlastActor & | actor, | |
| NvBlastFractureBuffers & | commands | |||
| ) | [pure virtual] |
Generate fracture commands for particular actor.
Calling this function if getOverstressedBondCount() == 0 or actor has no bond doesn't make sense, bondFractureCount will be '0'. Filled fracture commands buffer can be passed directly to NvBlastActorApplyFracture.
IMPORTANT: NvBlastFractureBuffers::bondFractures will point to internal stress solver memory which will be valid till next call of any of generateFractureCommands() functions or stress solver release() call.
| [in] | actor | The actor to fill fracture commands for. |
| [in] | commands | Pointer to command buffer to fill. |
| virtual uint32_t Nv::Blast::ExtStressSolver::generateFractureCommandsPerActor | ( | const NvBlastActor ** | actorBuffer, | |
| NvBlastFractureBuffers * | commandsBuffer, | |||
| uint32_t | bufferSize | |||
| ) | [pure virtual] |
Generate fracture commands for every actor in family.
Actors and commands buffer must be passed in order to be filled. It's recommended for bufferSize to be the count of actor with more then one bond in family.
Calling this function if getOverstressedBondCount() == 0 or actor has no bond doesn't make sense, '0' will be returned.
IMPORTANT: NvBlastFractureBuffers::bondFractures will point to internal stress solver memory which will be valid till next call of any of generateFractureCommands() functions or stress solver release() call.
| [out] | buffer | A user-supplied array of NvBlastActor pointers to fill. |
| [out] | commandsBuffer | A user-supplied array of NvBlastFractureBuffers to fill. |
| [in] | bufferSize | The number of elements available to write into buffer. |
| virtual uint32_t Nv::Blast::ExtStressSolver::getBondCount | ( | ) | const [pure virtual] |
Get stress solver bonds count, after graph reduction was applied.
| virtual uint32_t Nv::Blast::ExtStressSolver::getFrameCount | ( | ) | const [pure virtual] |
Get stress solver total frames count (update() calls) since it was created (or reset).
| uint32_t Nv::Blast::ExtStressSolver::getIterationsPerFrame | ( | ) | const [inline] |
Get iteration per frame (update() call).
Helper method to know how many solver iterations are made per frame.
| static uint32_t Nv::Blast::ExtStressSolver::getIterationsPerFrame | ( | const ExtStressSolverSettings & | settings, | |
| uint32_t | bondCount | |||
| ) | [inline, static] |
Get solver iteration per frame (update() call) for particular settings and bondCount.
Helper method to know how many solver iterations are made per frame. This function made so transparent to make it clear how ExtStressSolverSettings::bondIterationsPerFrame is used.
| [in] | settings | Debug render mode. |
| [in] | bondCount | Scale to be applied on impulses. |
| virtual uint32_t Nv::Blast::ExtStressSolver::getOverstressedBondCount | ( | ) | const [pure virtual] |
Get overstressed/broken bonds count.
This count is updated after every update() call. Number of overstressed bond directly hints if any bond fracture is recommended by stress solver.
| virtual const ExtStressSolverSettings& Nv::Blast::ExtStressSolver::getSettings | ( | ) | const [pure virtual] |
Get stress solver settings.
| virtual float Nv::Blast::ExtStressSolver::getStressErrorAngular | ( | ) | const [pure virtual] |
Get stress solver angular error.
| virtual float Nv::Blast::ExtStressSolver::getStressErrorLinear | ( | ) | const [pure virtual] |
Get stress solver linear error.
| virtual bool Nv::Blast::ExtStressSolver::notifyActorCreated | ( | const NvBlastActor & | actor | ) | [pure virtual] |
Notify stress solver on newly created actor.
Call this function for all initial actors present in family and later upon every actor split.
| [in] | actor | The actor created. |
| virtual void Nv::Blast::ExtStressSolver::notifyActorDestroyed | ( | const NvBlastActor & | actor | ) | [pure virtual] |
Notify stress solver on destroyed actor.
Call this function when actor is destroyed (split futher) or deactivated.
| [in] | actor | The actor destroyed. |
| virtual void Nv::Blast::ExtStressSolver::release | ( | ) | [pure virtual] |
Release this stress solver.
| virtual void Nv::Blast::ExtStressSolver::reset | ( | ) | [pure virtual] |
Reset stress solver.
Stress solver uses warm start internally, calling this function will flush all previous data calculated and also zeros frame count. This function is to be used for debug purposes.
| virtual void Nv::Blast::ExtStressSolver::setAllNodesInfoFromLL | ( | float | density = 1.0f |
) | [pure virtual] |
Set all nodes info using low level NvBlastAsset data. Uses NvBlastChunk's centroid and volume. Uses 'world' node to mark nodes as static.
| [in] | density | Density. Used to convert volume to mass. |
| virtual void Nv::Blast::ExtStressSolver::setNodeInfo | ( | uint32_t | graphNodeIndex, | |
| float | mass, | |||
| float | volume, | |||
| NvcVec3 | localPosition, | |||
| bool | isStatic | |||
| ) | [pure virtual] |
Set node info.
All the required info per node for stress solver is set with this function. Call it for every node in graph or use setAllNodesInfoFromLL().
| [in] | graphNodeIndex | Index of the node in support graph. see NvBlastSupportGraph. |
| [in] | mass | Node mass. For static node it is irrelevant. |
| [in] | volume | Node volume. For static node it is irrelevant. |
| [in] | localPosition | Node local position. |
| [in] | isStatic | Is node static. |
| virtual void Nv::Blast::ExtStressSolver::setSettings | ( | const ExtStressSolverSettings & | settings | ) | [pure virtual] |
Set stress solver settings. Changing graph reduction level will lead to graph being rebuilt (which is fast, but still not recommended). All other settings are applied instantly and can be changed every frame.
| [in] | settings | The settings to be set on ExtStressSolver. |
| virtual void Nv::Blast::ExtStressSolver::update | ( | ) | [pure virtual] |
Update stress solver.
Actual performance heavy stress calculation happens there. Call it after all relevant forces were applied, usually every frame.