22#define REPORT_SYSTEM_JOB_ENABLE 1
23#if REPORT_SYSTEM_JOB_ENABLE
35#define REPORT_SYSTEM_JOB_EX( str )\
36 auto sjrtb = agxUtil::TimerBlock( []( agx::UInt64 start, agx::UInt64 stop )\
38 agx::Thread::getCurrentThread()->reportSystemJob( start, stop, str );\
41#define REPORT_SYSTEM_JOB\
42 const char* AGX_CONCAT(agx_functionName,__LINE__) = __FUNCTION__; \
43 auto sjrtb = agxUtil::TimerBlock( [AGX_CONCAT(agx_functionName,__LINE__)]( agx::UInt64 start, agx::UInt64 stop )\
45 agx::Thread::getCurrentThread()->reportSystemJob( start, stop, AGX_CONCAT(agx_functionName,__LINE__) );\
48#define REPORT_SYSTEM_JOB_EX( str )
49#define REPORT_SYSTEM_JOB
56 class WireDistanceCompositeConstraint;
61 namespace MergeSplitUtils
76 return ( linVel + ( angVel ^ ( point - cmPos ) ) );
115 return ( relVel + ( angVel1 ^ ( point - cmPos1 ) ) + ( ( point - cmPos2 ) ^ angVel2 ) );
199 agx::MergedBody::EdgeInteraction::InteractionTag edgeTag,
208 using BfsQueueContainer = std::queue<const agx::RigidBody*>;
210 VisitedContainer visited;
211 VisitedPairContainer visitedPairs;
212 BfsQueueContainer bfsQueue;
214 const auto visit = [&visited, &bfsQueue](
const agx::RigidBody* rb )
217 visited.insert( rb );
223 SymmetricRigidBodyPtrPair rb1Rb2Pair( rb1, rb2 );
224 if ( visitedPairs.contains( rb1Rb2Pair ) )
227 visitedPairs.insert( rb1Rb2Pair );
235 auto front = bfsQueue.front();
240 visit( referenceEdge.getRigidBody1() );
241 while ( !bfsQueue.empty() ) {
242 const auto rb = pop();
246 for (
const auto neighbor : *neighbors ) {
247 if ( visitedPair( neighbor, rb ) )
250 const auto edges = mergedBody.
getEdges( neighbor, rb );
252 auto oneHasEdgeTag =
false;
253 for (
const auto& edge : *edges ) {
254 const auto edgeHasTag = edge->isTagged( edgeTag );
255 oneHasEdgeTag = oneHasEdgeTag || edgeHasTag;
256 if ( edge != &referenceEdge && edgeHasTag ) {
258 result.
push_back( edge->template as<T>() );
265 const auto visitThisNeighbor = neighbor !=
nullptr &&
267 ( !bounceAtNonSplittableBodies || handler.
maySplit( neighbor ) ) &&
268 !visited.contains( neighbor );
269 if ( visitThisNeighbor )
275 class WireSegmentMergedState;
312 using State = agx::BitState<EState, agx::UInt32>;
364 const agxWire::WireDistanceCompositeConstraint* m_wire;
#define AGXPHYSICS_EXPORT
Base class for a merge split algorithm handling a set of merged bodies.
agx::Bool maySplit(const agx::RigidBody *rb) const
Wire merged state segment along a wire.
WireSegmentMergedState(const agxWire::WireDistanceCompositeConstraint *wire)
Construct given wire constraint.
agxWire::NodeConstIterator begin() const
agxWire::NodeConstIterator construct(agxWire::NodeConstIterator it)
Initialize using iterator to first node (end of previous segment).
agx::MergedBody * getMergedBody() const
static WireSegmentMergedStateContainer create(const agxWire::Wire *wire)
Creates vector of WireMergedState segments along the wire starting from first lumped node to (and inc...
agxWire::Node * back() const
agxWire::BodyFixedNode * front() const
agxWire::NodeConstIterator end() const
agx::BitState< EState, agx::UInt32 > State
The body fixed node is attached to a body at a given offset.
Class defining a node that is part of a wire.
Interface and placeholder of controllers/helpers for wires.
Inheritance with partial specialization due to bug with ref_ptr containers.
Structure holding several "normal" rigid bodies.
const EdgeInteractionRefContainer * getEdges(const agx::RigidBody *rb1, const agx::RigidBody *rb2) const
const agx::RigidBodyPtrVector * getNeighbors(const agx::RigidBody *rb) const
GeometryContactEdgeInteraction()
Default constructor used by serialization.
The rigid body class, combining a geometric model and a frame of reference.
A std::pair, with both elements of the same type, and symmetric so (a, b) == (b, a)
Vector containing 'raw' data.
void push_back(const T2 &value)
bool contains(const T2 &element) const
Test if the vector contains a certain element.
AGXPHYSICS_EXPORT ExternalForceSplitResult shouldSplitGivenExternalForce(agxSDK::MergedBodySolverData::ForceFrame edgeStrength, const agx::RigidBody *rb, const agx::RigidBody *otherRb, const agx::Vec3 &externalForces, const agx::Vec3 &externalTorques, const agx::Vec3 &gravity, const agxSDK::MergeSplitHandler &handler)
Checks if two bodies should split given edge strength force frame and external forces.
void collectConnectingEdges(const T &referenceEdge, agx::MergedBody::EdgeInteraction::InteractionTag edgeTag, agx::Bool bounceAtNonSplittableBodies, const agx::MergedBody &mergedBody, const MergeSplitHandler &handler, CollectConnectingEdgesPtrContainer< T > &result)
Collects edges of given type/tag that are connected within a merged body.
AGXPHYSICS_EXPORT agxSDK::MergedBodySolverData::ForceFrame calculateContactForceFrame(const agx::RigidBody *refRb, const agx::MergedBody::GeometryContactEdgeInteraction *contactEdge, const MergeSplitHandler *handler=nullptr)
Calculates force frame (edge strength) given reference rigid body, contact edge and optionally an mer...
agx::Vec3 calculateRelativePointVelocity(const agx::Vec3 &point, const agx::Vec3 &cmPos, const agx::Vec3 &linVel, const agx::Vec3 &angVel)
Calculates velocity at a given point given center of mass position, linear- and angular velocity.
agx::Real calculateImpactSpeed(const agx::Vec3 &point, const agx::Vec3f &normal, const agx::Vec3 &cmPos, const agx::Vec3 &linVel, const agx::Vec3 &angVel)
Calculates impact speed of one body given contact point and normal.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Implements a Wire model with adaptive resolution.
NodeContainer::const_iterator NodeConstIterator
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
ExternalForceSplitResult()
const agx::RigidBody * rbTop
const agx::RigidBody * rbBottom
Force frame where the resultant force is u + v + n.