It is also can be used as an another way to apply impact damage, which can give visually pleasant result of breaking actor in a weak place instead of the place of contact.
Debug render could help a lot with that, consider using stressSolver->fillDebugRender(...) for that.
ExtStressSolver* stressSolver = ExtStressSolver::create(family, settings);
ExtStressSolverSettings are passed in create function, but also can be changed at any time with stressSolver->setSettings(...).
It fully utilizes the fact that it knows initial support graph structure and does maximum of processing in create(...) method calls. After that all actors split calls are synced internally quite fast and only the actual stress propagation takes most of computational time.
Then you need to provide physics specific information (mass, volume, position, static) for every node in support graph since Blast itself is physics agnostic. There are two ways to do it, you can call stressSolver->setNodeInfo(...) for every graph node. Another was is to call stressSolver->setAllNodesInfoFromLL() once all the data will be populated using NvBlastAsset chunk's data, in particular volume and centroid are used. All nodes connected to 'world' chunk are marked as static.
stressSolver->setAllNodesInfoFromLL();
Stress solver needs to keep track for actor create/destroy events in order to update it's internal stress graph accordingly. So you need to call stressSolver->notifyActorCreated(actor) and stressSolver->notifyActorDestroyed(actor) every time actor is created or destroyed including the initial actor family had when stress solver were created. There is no need to track actors which contain only one or lesser graph nodes in that case notifyActorCreated(actor) returns 'false' as a hint, it means that stress solver will ignore them. For those actors applying forces is also doesn't make any sense.
Typical update loop would can look like this:
Example code from ExtPxStressSolverImpl:
void ExtPxStressSolverImpl::onActorCreated(ExtPxFamily& /*family*/, ExtPxActor& actor) { if (m_solver->notifyActorCreated(*actor.getTkActor().getActorLL())) { m_actors.insert(&actor); } } void ExtPxStressSolverImpl::onActorDestroyed(ExtPxFamily& /*family*/, ExtPxActor& actor) { m_solver->notifyActorDestroyed(*actor.getTkActor().getActorLL()); m_actors.erase(&actor); } void ExtPxStressSolverImpl::update(bool doDamage) { for (auto it = m_actors.getIterator(); !it.done(); ++it) { const ExtPxActor* actor = *it; PxRigidDynamic& rigidDynamic = actor->getPhysXActor(); const bool isStatic = rigidDynamic.getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC; if (isStatic) { PxVec3 gravity = rigidDynamic.getScene()->getGravity(); PxVec3 localGravity = rigidDynamic.getGlobalPose().rotateInv(gravity); m_solver->addGravityForce(*actor->getTkActor().getActorLL(), localGravity); } else { PxVec3 localCenterMass = rigidDynamic.getCMassLocalPose().p; PxVec3 localAngularVelocity = rigidDynamic.getGlobalPose().rotateInv(rigidDynamic.getAngularVelocity()); m_solver->addAngularVelocity(*actor->getTkActor().getActorLL(), localCenterMass, localAngularVelocity); } } m_solver->update(); if (doDamage && m_solver->getOverstressedBondCount() > 0) { NvBlastFractureBuffers commands; m_solver->generateFractureCommands(commands); if (commands.bondFractureCount > 0) { m_family.getTkFamily().applyFracture(&commands); } } }
Have a look at ExtPxStressSolver implementation code, which is basically high level wrapper on NvBlastExtStress to couple it with PhysX™ and NvBlatExtPx extension (see ExtPxStressSolver).