|
AGXDynamics
2.31.1.0
|
Class which will go through contacting/separating bodies and determine if the bodies can be merged (geometries from bodyA can go into bodyB and bodyB will now move as one rigid body) or split (the original geometries of bodyA can be transferred back so BodyA can move as a separate body). More...
#include <MergeSplit.h>
Inheritance diagram for agx::MergeSplit:Classes | |
| class | Listener |
| Class for intercepting merge/split events. More... | |
Public Types | |
| typedef agx::ref_ptr< Listener > | ListenerRef |
Public Member Functions | |
| MergeSplit (agxCollide::Space *space=nullptr) | |
| Default constructor. More... | |
| template<typename T > | |
| T * | as () |
| Subclass casting. More... | |
| template<typename T > | |
| const T * | as () const |
| template<typename T > | |
| T * | asSafe () |
| Safe subclass casting, return nullptr if template type does not match. More... | |
| template<typename T > | |
| const T * | asSafe () const |
| void | clear () |
| Split all merged bodies, clear all data structures. More... | |
| const char * | getClassName () const override |
| bool | getEnable () const |
| bool | getEnableSerialization () const |
| bool | getEnableUuidGeneration () |
| agx::UInt32 | getIndex () const |
| This index is given at creation of this object. More... | |
| Listener * | getListener () |
| const Listener * | getListener () const |
| int | getReferenceCount () const |
| bool | getSplitInPost () const |
| agxStream::StorageAgent * | getStorageAgent () const override |
| MergeSplitThreshold * | getThreshold () |
| const MergeSplitThreshold * | getThreshold () const |
| agx::Uuid | getUuid () const |
| template<typename T > | |
| bool | is () const |
| Subclass test. More... | |
| bool | isEnabled () const |
| bool | isFinished () const |
| void | merge () |
| Explicit call to merge, will go and ask space for contacts and separations and see if something can be merged based on those contacts. More... | |
| bool | merge (agx::RigidBody *child, agx::RigidBody *parent) |
| Explicitly merge two bodies. More... | |
| void | post (const agx::TimeStamp &t) |
| void | pre (const agx::TimeStamp &t) |
| void | reference (void *ptr=nullptr) const |
| Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More... | |
| virtual void | restore (agxStream::InputArchive &in) override |
| void | setEnable (bool flag) |
| Enable/disable MergeSplit. More... | |
| void | setEnableSerialization (bool flag) |
| Set to false to disable serialization of this object. More... | |
| void | setFinished () |
| Tells this class that it is restored correctly and should not be deleted during destruction of an Archive. More... | |
| void | setListener (Listener *listener) |
| Specify a point to a listener that will be called upon merge/split events. More... | |
| void | setSpace (agxCollide::Space *space) |
| Tell MergeSplit which space to use for accessing contacts. More... | |
| void | setSplitInPost (bool flag) |
| Specifies whether the split should occur in the pre solver step, or in the post step. More... | |
| void | setUuid (const agx::Uuid &uuid) |
| Explicitly set a Uuid on a serializable object. More... | |
| void | split () |
| Explicit call to split, will go and ask space for contacts and separations and see if something can be split based on those contacts. More... | |
| bool | split (agxCollide::Geometry *geometry, bool shouldUpdateContacts=true, bool forceSplit=false, bool splitImmediately=true) |
Take a specified geometry geometry and locate its ORIGINAL body (which was the original body that this geometry belonged to) and split that. More... | |
| bool | split (agx::RigidBody *bodyToBeSplit, bool forceSplit=false, bool splitImmediately=true) |
Take the specified body bodyToBeSplit and if it is merged, then split it from any parents, make it a free non-merged body. More... | |
| virtual void | store (agxStream::OutputArchive &out) const override |
| void | unreference (void *ptr=nullptr) const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
| void | unreference_nodelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is referencing it. More... | |
| bool | validate () |
Static Public Member Functions | |
| static void | calculateSeparatingVelocityAcceleration (agx::RigidBody *body1, agx::RigidBody *body2, agx::Real &dVel, agx::Real &dOmega, agx::Real &dAcc, agx::Real &dAngularAcc) |
| Calculate the relative velocity/acceleration of two rigidbodies center of mass velocities. More... | |
| static agxStream::Serializable * | create (agxStream::InputArchive &) |
| static agxStream::Serializable * | create () |
| static const char * | getConstructClassId () |
| static void | setEnableUuidGeneration (bool flag) |
| Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled. More... | |
| template<typename T > | |
| static bool | ValidateCast (const Referenced *object) |
Protected Types | |
| typedef agx::HashVector < agxCollide::Geometry *, agx::ref_ptr < MergeSplitBodyStorage > > | GeometryBodyHashVector |
| typedef agx::Vector < MergeSplitBodyStorage * > | MergeSplitBodyStoragePtrVector |
| typedef agx::Vector < agx::ref_ptr < MergeSplitBodyStorage > > | MergeSplitBodyStorageRefVector |
Static Protected Member Functions | |
| static DeleteHandler * | getDeleteHandler () |
| static void | setDeleteHandler (DeleteHandler *handler) |
| Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More... | |
Protected Attributes | |
| agx::RigidBodyObserverVector | m_bodiesToBeSplit |
| MergeSplitBodyStorageRefVector | m_bodyStoragePool |
| bool | m_enabled |
| MergeSplitBodyStoragePtrVector | m_freeBodyStorage |
| GeometryBodyHashVector | m_geometryBodyHash |
| ListenerRef | m_listener |
| Mutex | m_mutex |
| size_t | m_numMerge |
| size_t | m_numSplit |
| ObserverContainer | m_observers |
| AtomicValue | m_refCount |
| agx::observer_ptr < agxCollide::Space > | m_space |
| bool | m_splitInPost |
| agx::ref_ptr< SleepThreshold > | m_threshold |
Class which will go through contacting/separating bodies and determine if the bodies can be merged (geometries from bodyA can go into bodyB and bodyB will now move as one rigid body) or split (the original geometries of bodyA can be transferred back so BodyA can move as a separate body).
Default is splitting bodies due to contacts in a PRE step, that is after contacts are generated and before solver.
Definition at line 37 of file MergeSplit.h.
|
protected |
Definition at line 264 of file MergeSplit.h.
Definition at line 195 of file MergeSplit.h.
|
protected |
Definition at line 273 of file MergeSplit.h.
|
protected |
Definition at line 272 of file MergeSplit.h.
| agx::MergeSplit::MergeSplit | ( | agxCollide::Space * | space = nullptr | ) |
Default constructor.
|
protectedvirtual |
|
protected |
Take the specified body bodyToBeSplit and if it is merged, then split it from any parents, make it a free non-merged body.
| bodyToBeSplit | - The body that should be split from any merged bodies |
| contact | - set to the GeometryContact if it was a contact/impacting resulting in the split, otherwise nullptr. |
| forceSplit | - if true, body will be split, even if it has properties stating it should not. |
| splitImmediately | - Split now not later in a batch with other bodies that are going to be split |
|
protected |
|
protectedinherited |
|
inherited |
Subclass casting.
Template type must match actual type, dynamic_cast assertion will fail otherwise.
Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().
|
inherited |
|
inherited |
Safe subclass casting, return nullptr if template type does not match.
Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().
|
inherited |
|
static |
Calculate the relative velocity/acceleration of two rigidbodies center of mass velocities.
| void agx::MergeSplit::clear | ( | ) |
Split all merged bodies, clear all data structures.
|
protected |
|
inlinestatic |
Definition at line 120 of file MergeSplit.h.
|
inlinestatic |
Definition at line 120 of file MergeSplit.h.
|
protectedinherited |
|
protectedinherited |
|
protected |
|
inlineoverridevirtual |
Reimplemented from agxStream::Serializable.
Definition at line 120 of file MergeSplit.h.
|
inlinestatic |
Definition at line 120 of file MergeSplit.h.
|
staticprotectedinherited |
| bool agx::MergeSplit::getEnable | ( | ) | const |
|
inherited |
Definition at line 273 of file Serializable.h.
|
inherited |
|
inherited |
This index is given at creation of this object.
It is guaranteed to be unique for the lifetime of this library instance. As long as the application is running. This value is not serialized or restored. A new object will always get a new index no matter how it is created.
Definition at line 247 of file Serializable.h.
| Listener* agx::MergeSplit::getListener | ( | ) |
| const Listener* agx::MergeSplit::getListener | ( | ) | const |
|
inherited |
| bool agx::MergeSplit::getSplitInPost | ( | ) | const |
|
inlineoverridevirtual |
Implements agxStream::Serializable.
Definition at line 120 of file MergeSplit.h.
| MergeSplitThreshold* agx::MergeSplit::getThreshold | ( | ) |
| const MergeSplitThreshold* agx::MergeSplit::getThreshold | ( | ) | const |
|
inherited |
Definition at line 268 of file Serializable.h.
|
inherited |
Subclass test.
Referenced by agx::Object::getAutoScopedResource(), agxData::Buffer::getElement(), and agx::Object::getResource().
| bool agx::MergeSplit::isEnabled | ( | ) | const |
|
inherited |
Definition at line 252 of file Serializable.h.
| void agx::MergeSplit::merge | ( | ) |
Explicit call to merge, will go and ask space for contacts and separations and see if something can be merged based on those contacts.
Requires that Space::update() has been called prior to this.
| bool agx::MergeSplit::merge | ( | agx::RigidBody * | child, |
| agx::RigidBody * | parent | ||
| ) |
Explicitly merge two bodies.
parent will be parent if the following is true:
parent is static, child is not parent has a constraint attached to itself, child has not
If the above rules fails, the two bodies will be swapped and child will be parent. If merge cannot proceed (if both bodies are static or both have constraints, the method will return false).
There is currently no test if any of the two bodies are already merged. If so, the result will be unpredicted.
| child | - The body that will be the child unless above rule fails |
| parent | - The body that will be the parent unless above rule fails |
|
protected |
|
protected |
| void agx::MergeSplit::post | ( | const agx::TimeStamp & | t | ) |
| void agx::MergeSplit::pre | ( | const agx::TimeStamp & | t | ) |
|
protected |
Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
This method should be used with care, always balanced with the same number of calls to unreference.
Referenced by agxData::Val< UInt >::Val().
|
protected |
|
protected |
|
protected |
|
overridevirtual |
|
protected |
|
staticprotectedinherited |
Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
| void agx::MergeSplit::setEnable | ( | bool | flag | ) |
Enable/disable MergeSplit.
| flag | - If true, MergeSplit will be enabled, if false, all merged bodies will be split, |
|
inherited |
Set to false to disable serialization of this object.
It will just be ignored during serialization (writing). It is still possible to restore TO this object.
|
staticinherited |
Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.
|
inherited |
Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
Specify a point to a listener that will be called upon merge/split events.
| void agx::MergeSplit::setSpace | ( | agxCollide::Space * | space | ) |
Tell MergeSplit which space to use for accessing contacts.
| void agx::MergeSplit::setSplitInPost | ( | bool | flag | ) |
Specifies whether the split should occur in the pre solver step, or in the post step.
A system where split occurs in pre will appear more dynamic and realistic, however, it will probably result in a more overall dynamic system with somewhat lower performance. Splitting in pre might also cause jitter in large piles, due to that when splitting in pre, no contacts are created until next time step. Meaning that gravity will pull the split body, let it fall during one time step, and at the next contacts will be created and it will be stabilized. So for single objects on merged ground split in pre will work just fine, for larger piles, some jitter might be noticed.
| flag | if true, the split will occur in post, otherwise in pre (default) |
Explicitly set a Uuid on a serializable object.
Use this method with great care, as it can result in non-unique identifiers in the system!
|
protected |
|
protected |
| void agx::MergeSplit::split | ( | ) |
Explicit call to split, will go and ask space for contacts and separations and see if something can be split based on those contacts.
Requires that Space::update() has been called prior to this.
| bool agx::MergeSplit::split | ( | agxCollide::Geometry * | geometry, |
| bool | shouldUpdateContacts = true, |
||
| bool | forceSplit = false, |
||
| bool | splitImmediately = true |
||
| ) |
Take a specified geometry geometry and locate its ORIGINAL body (which was the original body that this geometry belonged to) and split that.
This will also mean that additional geometry (belonging to this Body) will be taken out of a merged body.
| geometry | - The geometry which has an original owner body that will be split |
| shouldUpdateContacts | - If true, and IF the split succeeded, all contacts will be investigated and updated to get correct body/geometry pointers. |
| forceSplit | - if true, body will be split, even if it has properties stating it should not. Geometry will be split even if it has property stating it should not. |
| splitImmediately | - If true the geometry will be split now and not later in a batch with other splitted geometries |
| bool agx::MergeSplit::split | ( | agx::RigidBody * | bodyToBeSplit, |
| bool | forceSplit = false, |
||
| bool | splitImmediately = true |
||
| ) |
Take the specified body bodyToBeSplit and if it is merged, then split it from any parents, make it a free non-merged body.
| bodyToBeSplit | - The body that should be split from any merged bodies |
| forceSplit | - if true, body will be split, even if it has properties stating it should not. |
| splitImmediately | - Split now not later in a batch with other bodies that are going to be split |
|
protected |
|
protected |
|
protected |
|
overridevirtual |
|
protected |
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.
This method should be used with care, always balanced with the same number of calls to reference.
|
inherited |
Decrement the reference count by one, indicating that a pointer to this object is referencing it.
However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.
|
protected |
| bool agx::MergeSplit::validate | ( | ) |
|
staticinherited |
|
protected |
|
protected |
Definition at line 282 of file MergeSplit.h.
|
protected |
Definition at line 276 of file MergeSplit.h.
|
protected |
Definition at line 279 of file MergeSplit.h.
|
protected |
Definition at line 275 of file MergeSplit.h.
|
protected |
Definition at line 265 of file MergeSplit.h.
|
protected |
Definition at line 280 of file MergeSplit.h.
|
mutableprotectedinherited |
Definition at line 240 of file Referenced.h.
|
protected |
Definition at line 267 of file MergeSplit.h.
|
protected |
Definition at line 268 of file MergeSplit.h.
|
mutableprotectedinherited |
Definition at line 239 of file Referenced.h.
|
mutableprotectedinherited |
Definition at line 241 of file Referenced.h.
|
protected |
Definition at line 277 of file MergeSplit.h.
|
protected |
Definition at line 283 of file MergeSplit.h.
|
protected |
Definition at line 270 of file MergeSplit.h.