AGX Dynamics 2.41.1.2
Loading...
Searching...
No Matches
agxSDK::MaterialManager Class Reference

Simulation unique manager that handles logics around and parameters in contact materials given two agx::Materials. More...

#include <MaterialManager.h>

+ Inheritance diagram for agxSDK::MaterialManager:

Classes

class  MaterialManagerSerializer
 Internal class for store/restore of MaterialManager. More...
 

Public Member Functions

 MaterialManager ()
 Default constructor.
 
bool add (agx::ContactMaterial *contactMaterial)
 Add explicit contact material to this manager.
 
bool add (agx::Material *material)
 Add material to this manager.
 
const agx::ContactMaterialgetContactMaterial (agx::Physics::MaterialPtr material1, agx::Physics::MaterialPtr material2) const
 Returns an implicit or explicit contact material if it exists.
 
const agx::ContactMaterialgetContactMaterial (const agx::Material *material1, const agx::Material *material2) const
 Returns an implicit or explicit contact material if it exists.
 
const MaterialSPairContactMaterialRefTablegetContactMaterials () const
 
agxData::EntityStoragegetContactMaterialStorage ()
 
agx::ContactMaterialPtrVector getContactMaterialVector () const
 This method will create and return new vector with all ContactMaterials.
 
const agx::MaterialgetDefaultMaterial () const
 
agx::MaterialgetMaterial (const agx::String &name)
 
const agx::MaterialgetMaterial (const agx::String &name) const
 
agx::MaterialgetMaterial (const agx::Uuid &uuid)
 
const StringMaterialRefTablegetMaterials () const
 
agx::MaterialPtrVector getMaterialVector () const
 This method will create and return new vector with all materials.
 
agx::ContactMaterialgetOrCreateContactMaterial (const agx::Material *material1, const agx::Material *material2)
 Returns or creates an explicit contact material.
 
agx::ContactMaterialgetOrCreateContactMaterial (const agxCollide::GeometryContact *geometryContact)
 Not part of the public API.
 
bool hasMaterialsWithContactReduction () const
 
bool remove (agx::ContactMaterial *contactMaterial)
 Remove explicit contact material from this manager.
 
bool remove (agx::Material *material)
 Remove material from this manager.
 
void restore (const MaterialManagerSerializer &mgr)
 Restores necessary internal structures.
 
bool setContactMaterial (agxCollide::LocalGeometryContact *localGeometryContact)
 Assigns contact material to a local geometry contact.
 
void store (agxStream::OutputArchive &out) const
 Saves necessary internal structures.
 
- Public Member Functions inherited from agx::Component
 Component (const agx::Name &name=agx::Name(), agx::Model *model=agx::Component::ClassModel(), agx::Device *device=nullptr)
 
virtual void addObject (agx::Object *object, bool assignContext=true)
 Add an object to the component.
 
virtual String autoComplete (const String &partialName, StringVector &matchingNames) const
 
virtual void buildNavigationTree (agxJson::Value &eNode) const override
 
void configure (Model *model)
 
virtual void configure (TiXmlElement *eComponent) override
 
agx::DevicegetDevice ()
 
template<typename T >
T * getDevice ()
 
const agx::DevicegetDevice () const
 
template<typename T >
const T * getDevice () const
 
size_t getNumObjects (const agx::Name &name) const
 
agx::ObjectgetObject (const agx::Name &name, agx::Model *model, size_t index=0)
 
const agx::ObjectgetObject (const agx::Name &name, agx::Model *model, size_t index=0) const
 
agx::ObjectgetObject (const agx::Name &name, size_t index=0)
 
template<typename T >
T * getObject (const agx::Name &name, size_t index=0)
 
const agx::ObjectgetObject (const agx::Name &name, size_t index=0) const
 
template<typename T >
const T * getObject (const agx::Name &name, size_t index=0) const
 
const agx::ObjectRefVectorgetObjects () const
 
template<typename T >
void getObjects (agx::ObjectPtrVector &result, bool recursive=false) const
 
void getObjects (agx::ObjectPtrVector &result, const agx::Model *model, bool recursive=false) const
 
virtual ObjectgetResourceImpl (const Path &path, agx::Model *model) override
 
virtual void printSubtree () const override
 
void printSubtree (std::ostream &stream, int depth=0) const
 
virtual void rebind () override
 
void removeAllObjects ()
 Remove all components.
 
virtual void removeObject (agx::Object *object)
 Remove an object from the component.
 
void removeObject (const agx::Name &name, size_t index=0)
 Remove an object with a specified name (and optional index) from the component.
 
virtual void snapshot (TiXmlNode *eParent, const String &directory) const override
 
void traverse (ComponentVisitor *)
 
void traverse (const TraverseCallback &callback)
 
- Public Member Functions inherited from agx::Object
 Object (const Name &name=Name(), Model *model=Object::ClassModel())
 
void addListener (EventListener *listener)
 
virtual void buildNavigationTree (agxJson::Value &eNode) const
 
virtual void configure (TiXmlElement *)
 
agx::String fullName () const
 
agx::String fullPath () const
 
agx::String fullPath (const agx::Object *root) const
 
template<typename T >
T * getAutoScopedResource (const agx::Path &path)
 
template<typename T >
const T * getAutoScopedResource (const agx::Path &path) const
 
agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr) const
 
agx::ObjectgetContext ()
 
template<typename T >
T * getContext ()
 
const agx::ObjectgetContext () const
 
template<typename T >
const T * getContext () const
 
agx::UInt32 getId () const
 
const agx::NamegetImplementationName () const
 
agx::ModelgetModel ()
 
const agx::ModelgetModel () const
 
const agx::NamegetName () const
 
agx::ObjectgetNextSibling ()
 
const agx::ObjectgetNextSibling () const
 
agx::Path getPath () const
 
agx::Path getPath (const agx::Object *root) const
 
template<typename T >
T * getResource (const agx::Path &path)
 
template<typename T >
const T * getResource (const agx::Path &path) const
 
agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr) const
 
virtual agx::ObjectgetResourceImpl (const agx::Path &path, agx::Model *model)
 
agx::ObjectgetRootContext ()
 
const agx::ObjectgetRootContext () const
 
bool hasListener (EventListener *listener)
 
bool hasParent (const agx::Object *node) const
 
bool isUnique () const
 
virtual void printSubtree () const
 
virtual void rebind ()
 
void removeListener (EventListener *listener)
 
virtual void save (TiXmlElement *) const
 
virtual void setContext (agx::Object *context)
 
void setId (UInt32 id)
 
void setModel (agx::Model *model)
 Set the object model (handled automatically).
 
void setName (const agx::Name &name)
 Set the name of the object.
 
virtual void snapshot (TiXmlNode *, const String &) const
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Static Public Member Functions

static void calculateContactMaterial (agx::ContactMaterial *contactMaterial)
 Static method to calculate the parameters in a contact material given the two materials assigned to it.
 
static agx::ModelClassModel ()
 
- Static Public Member Functions inherited from agx::Component
static Component_load (TiXmlElement *eComponent, Device *device)
 
static agx::ModelClassModel ()
 
static Componentload (const Path &path, const Name &implementation, Device *device, const Path &_namespace=Path())
 
static Componentload (const String &path, const Path &_namespace=Path())
 
static Componentload (const String &path, Device *device, const Path &_namespace=Path())
 
static Componentload (TiXmlElement *eComponent, Device *device)
 
- Static Public Member Functions inherited from agx::Object
static agx::ModelClassModel ()
 
static agx::String generateName (const agx::String &bindPath)
 
static const HashSet< Object * > & getActiveObjects ()
 
static bool getEnableRebind ()
 Should rebinding be allowed? Right now a global setting.
 
static Objectload (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
static Objectload (const String &path, Device *device, const String &type="", size_t instance=0)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type="", size_t instance=0)
 
static void load (const String &path, Device *device, ObjectPtrVector &loadedObjects)
 
static Objectload (TiXmlElement *eObject, Device *device)
 
template<typename T >
static T * load (TiXmlElement *eObject, Device *device)
 
static TiXmlDocument openDocument (const String &path)
 
static void setEnableRebind (bool flag)
 Sets if rebinding of objects should be allowed (Right now a global setting).
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~MaterialManager ()
 Destructor.
 
void clear ()
 Clears all internal structures.
 
SymmetricMaterialPair getSymmetricPair (const agx::ContactMaterial *contactMaterial) const
 
SymmetricMaterialPair getSymmetricPair (const agx::Material *material1, const agx::Material *material2) const
 
void initializeNewGeometryContacts (const agxCollide::GeometryContactPtrVector &geometryContacts)
 For any geometry contact where the contact material is zero, this method performs getOrCreateContactMaterial and assigns it.
 
bool loadLibraryContactMaterial (const agx::Material *material1, const agx::Material *material2, agx::ContactMaterial *contactMaterial)
 Try to load the Library ContactMaterial for the pair (material1, material2) and fill in the settings in the provided contactMaterial.
 
void resetDirtyMaterials () const
 Updates implicit contact materials containing at least one dirty material.
 
void updateContactMaterials (const agxCollide::GeometryContactPtrVector &geometryContacts)
 Updates implicit, dirty, materials that are currently used.
 
- Protected Member Functions inherited from agx::Component
virtual ~Component ()
 
String expandAutoCompletionMatch (const String &query, const StringVector &matchingNames) const
 
void setDevice (Device *device)
 
- Protected Member Functions inherited from agx::Object
virtual ~Object ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Additional Inherited Members

- Public Types inherited from agx::Component
typedef Event2< Component *, Object * > ObjectEvent
 Event when adding removing child objects.
 
typedef Callback1< Object * > TraverseCallback
 
- Public Types inherited from agx::Object
typedef agx::observer_ptr< const EventEventConstObserver
 
typedef agx::ref_ptr< const EventEventConstRef
 
typedef agx::observer_ptr< EventEventObserver
 
typedef agx::Vector< EventObserverEventObserverVector
 
typedef agx::VectorPOD< Event * > EventPtrVector
 
typedef agx::ref_ptr< EventEventRef
 
typedef agx::Vector< EventRefEventRefVector
 
- Public Attributes inherited from agx::Component
ObjectEvent addObjectEvent
 
ObjectEvent removeObjectEvent
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Simulation unique manager that handles logics around and parameters in contact materials given two agx::Materials.

Definition at line 49 of file MaterialManager.h.

Constructor & Destructor Documentation

◆ MaterialManager()

agxSDK::MaterialManager::MaterialManager ( )

Default constructor.

◆ ~MaterialManager()

virtual agxSDK::MaterialManager::~MaterialManager ( )
protectedvirtual

Destructor.

Reference counted so protected.

Member Function Documentation

◆ add() [1/2]

bool agxSDK::MaterialManager::add ( agx::ContactMaterial contactMaterial)

Add explicit contact material to this manager.

This method adds all geometry materials in the contact material that aren't present in this manager.

If an explicit contact material with the same two materials already exists, the old explicit contact material will be overwritten.

The two materials defining this contact material can never trigger a recalculation of the values stored in this contact material. The ones specified will always be used.

Parameters
contactMaterial- the contact material to add
Returns
true if successful - otherwise false

◆ add() [2/2]

bool agxSDK::MaterialManager::add ( agx::Material material)

Add material to this manager.

If a material with the same name already exists, it will return false.

Parameters
material- the material to add
Returns
true if successful - otherwise false

◆ calculateContactMaterial()

static void agxSDK::MaterialManager::calculateContactMaterial ( agx::ContactMaterial contactMaterial)
static

Static method to calculate the parameters in a contact material given the two materials assigned to it.

Parameters
contactMaterial- contact material to fill with values (getMaterial1() and getMaterial2() will be used)

◆ ClassModel()

static agx::Model * agxSDK::MaterialManager::ClassModel ( )
static
Returns
the class model

◆ clear()

void agxSDK::MaterialManager::clear ( )
protected

Clears all internal structures.

◆ getContactMaterial() [1/2]

const agx::ContactMaterial * agxSDK::MaterialManager::getContactMaterial ( agx::Physics::MaterialPtr  material1,
agx::Physics::MaterialPtr  material2 
) const
inline

Returns an implicit or explicit contact material if it exists.

When the contact material can be implicit, it's not defined to change any parameters in the contact material. I.e., this is the current version of the contact material.

Parameters
material1- first material, if nullptr the default material will be used
material2- second material, if nullptr the default material will be used
Returns
contact material between material1 and material2 if present - otherwise nullptr

Definition at line 317 of file MaterialManager.h.

References getContactMaterial(), getDefaultMaterial(), and agx::Physics::MaterialPtr::model().

◆ getContactMaterial() [2/2]

const agx::ContactMaterial * agxSDK::MaterialManager::getContactMaterial ( const agx::Material material1,
const agx::Material material2 
) const

Returns an implicit or explicit contact material if it exists.

When the contact material can be implicit, it's not defined to change any parameters in the contact material. I.e., this is the current version of the contact material.

Parameters
material1- first material, if nullptr the default material will be used
material2- second material, if nullptr the default material will be used
Returns
contact material between material1 and material2 if present - otherwise nullptr

Referenced by getContactMaterial().

◆ getContactMaterials()

const MaterialSPairContactMaterialRefTable & agxSDK::MaterialManager::getContactMaterials ( ) const
Returns
all contact materials created or added to this manager

◆ getContactMaterialStorage()

agxData::EntityStorage * agxSDK::MaterialManager::getContactMaterialStorage ( )
inline
Returns
data storage for contact materials

Definition at line 312 of file MaterialManager.h.

◆ getContactMaterialVector()

agx::ContactMaterialPtrVector agxSDK::MaterialManager::getContactMaterialVector ( ) const

This method will create and return new vector with all ContactMaterials.

This is raw pointers to ContactMaterial objects, so if they are unreferenced (for example if someone removes it from the simulation), the pointer might be invalidated

Returns
all ContactMaterials

◆ getDefaultMaterial()

const agx::Material * agxSDK::MaterialManager::getDefaultMaterial ( ) const
inline
Returns
the default material

Definition at line 307 of file MaterialManager.h.

References agx::Material::getDefaultMaterial().

Referenced by getContactMaterial(), and getSymmetricPair().

◆ getMaterial() [1/3]

agx::Material * agxSDK::MaterialManager::getMaterial ( const agx::String name)
Returns
material given name, if a material with that name is present, otherwise nullptr

◆ getMaterial() [2/3]

const agx::Material * agxSDK::MaterialManager::getMaterial ( const agx::String name) const
Returns
material given name, if a material with that name is present, otherwise nullptr

◆ getMaterial() [3/3]

agx::Material * agxSDK::MaterialManager::getMaterial ( const agx::Uuid uuid)
Returns
material given uuid, if a material with that uuid is present, otherwise 0

◆ getMaterials()

const StringMaterialRefTable & agxSDK::MaterialManager::getMaterials ( ) const
Returns
all materials with unique name that have been handled by this manager

◆ getMaterialVector()

agx::MaterialPtrVector agxSDK::MaterialManager::getMaterialVector ( ) const

This method will create and return new vector with all materials.

This is raw pointers to materials, so if they are unreferenced (for example if someone removes it from the simulation), the pointer might be invalidated

Returns
all materials with unique name that have been handled by this manager

◆ getOrCreateContactMaterial() [1/2]

agx::ContactMaterial * agxSDK::MaterialManager::getOrCreateContactMaterial ( const agx::Material material1,
const agx::Material material2 
)

Returns or creates an explicit contact material.

If material1 or material2 are changed after this contact material has been created, no recalculations of the contact material will be made.

Parameters
material1- first material, if nullptr the default material will be used
material2- second material, if nullptr the default material will be used
Returns
contact material between the two materials

◆ getOrCreateContactMaterial() [2/2]

agx::ContactMaterial * agxSDK::MaterialManager::getOrCreateContactMaterial ( const agxCollide::GeometryContact geometryContact)

Not part of the public API.

This method can create implicit contact materials if no explicit is present.

◆ getSymmetricPair() [1/2]

SymmetricMaterialPair agxSDK::MaterialManager::getSymmetricPair ( const agx::ContactMaterial contactMaterial) const
protected
Returns
symmetric pair given contact material

Definition at line 322 of file MaterialManager.h.

References agxAssert, getDefaultMaterial(), agx::ContactMaterial::getMaterial1(), and agx::ContactMaterial::getMaterial2().

◆ getSymmetricPair() [2/2]

SymmetricMaterialPair agxSDK::MaterialManager::getSymmetricPair ( const agx::Material material1,
const agx::Material material2 
) const
protected
Returns
symmetric pair given two materials

Definition at line 330 of file MaterialManager.h.

References getDefaultMaterial().

◆ hasMaterialsWithContactReduction()

bool agxSDK::MaterialManager::hasMaterialsWithContactReduction ( ) const
Returns
true if this manager has seen at least one material with contact reduction enabled

◆ initializeNewGeometryContacts()

void agxSDK::MaterialManager::initializeNewGeometryContacts ( const agxCollide::GeometryContactPtrVector geometryContacts)
protected

For any geometry contact where the contact material is zero, this method performs getOrCreateContactMaterial and assigns it.

Note that this method doesn't updates dirty implicit materials, it only makes sure GeometryContact::m_material != nullptr. This method should be called after narrow phase update.

◆ loadLibraryContactMaterial()

bool agxSDK::MaterialManager::loadLibraryContactMaterial ( const agx::Material material1,
const agx::Material material2,
agx::ContactMaterial contactMaterial 
)
protected

Try to load the Library ContactMaterial for the pair (material1, material2) and fill in the settings in the provided contactMaterial.

Return true if successful.

◆ remove() [1/2]

bool agxSDK::MaterialManager::remove ( agx::ContactMaterial contactMaterial)

Remove explicit contact material from this manager.

Parameters
contactMaterial- contact material to remove
Returns
true if successful - otherwise false

◆ remove() [2/2]

bool agxSDK::MaterialManager::remove ( agx::Material material)

Remove material from this manager.

Parameters
material- material to remove
Returns
true if successful - otherwise false

◆ resetDirtyMaterials()

void agxSDK::MaterialManager::resetDirtyMaterials ( ) const
protected

Updates implicit contact materials containing at least one dirty material.

◆ restore()

void agxSDK::MaterialManager::restore ( const MaterialManagerSerializer mgr)

Restores necessary internal structures.

◆ setContactMaterial()

bool agxSDK::MaterialManager::setContactMaterial ( agxCollide::LocalGeometryContact localGeometryContact)

Assigns contact material to a local geometry contact.

This contact material can be either implicit or explicit.

Note
It's undefined to change properties of an implicit contact material.
Parameters
localGeometryContact- local geometry contact to assign contact material to
Returns
true if a contact material was assigned, otherwise false

◆ store()

void agxSDK::MaterialManager::store ( agxStream::OutputArchive out) const

Saves necessary internal structures.

◆ updateContactMaterials()

void agxSDK::MaterialManager::updateContactMaterials ( const agxCollide::GeometryContactPtrVector geometryContacts)
protected

Updates implicit, dirty, materials that are currently used.


The documentation for this class was generated from the following file: