AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxOSG::RigidBodyRenderCache Class Reference

RigidBodyRenderCache is used to cache generated visuals and lookup mappings of RigidBodies cloned from Templates in agx::RigidBodyEmitter and other related granular applications. More...

#include <RigidBodyRenderCache.h>

+ Inheritance diagram for agxOSG::RigidBodyRenderCache:

Classes

class  RigidBodyVisualGroup
 A help class to store all information we need to copy a rigid body visualization to duplicate the rigid body from a rigid body template. More...
 

Public Types

typedef agx::observer_ptr< const RigidBodyVisualGroup > RigidBodyVisualGroupConstObserver
 
typedef agx::ref_ptr< const RigidBodyVisualGroup > RigidBodyVisualGroupConstRef
 
typedef agx::observer_ptr< RigidBodyVisualGroup > RigidBodyVisualGroupObserver
 
typedef agx::ref_ptr< RigidBodyVisualGroup > RigidBodyVisualGroupRef
 

Public Member Functions

 RigidBodyRenderCache (bool onlyAddEmittedBodies=true)
 Default constructor.
 
const RigidBodyRenderCache::RigidBodyVisualGroup & addTemplateBodyToVisualCache (agx::RigidBody *body)
 Add template body to visual cache that is used during playback in qtViewer.
 
void addToCache (osg::Group *rootNode)
 Add the osg::Group created from a RigidBody to the cache.
 
bool bodyIsTemplateEmitted (agx::RigidBody *body)
 Checks wherever the specifed body is generated/cloned from the temlpate body via RigidBodyEmitter och creation via the Momentum API.
 
void clear ()
 Clear the internal cache.
 
const RigidBodyRenderCache::RigidBodyVisualGroup & getCachedTemplateBodyVisual (agx::RigidBody *body)
 Get cached template body visual from the node cache if it exists.
 
osg::Group * getNode (agx::RigidBody *body)
 Get the current mapping in the cache between a RigidBody to a osg::Group.
 
bool getOnlyAddEmittedBodies () const
 
const RigidBodyRenderCache::RigidBodyVisualGroup & getOrCreateCachedTemplateBodyNode (agx::RigidBody *body)
 Gets cached template body visual from the node cache if it exists, otherwise a new visual node will be created in the cache and returned.
 
void setOnlyAddEmittedBodies (bool enable)
 
- 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.
 
Referenced & operator= (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.
 

Protected Member Functions

virtual ~RigidBodyRenderCache ()
 
bool shouldAddBody (agx::RigidBody *body) const
 
void traverseAndInsert (osg::Group *rootNode)
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
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

RigidBodyRenderCache is used to cache generated visuals and lookup mappings of RigidBodies cloned from Templates in agx::RigidBodyEmitter and other related granular applications.

It is used to optimize rendering by basic instantiation of similar template bodies and also for fast lookup to circumvent the complexity of agxOSG::findGeometryNode.

Definition at line 36 of file RigidBodyRenderCache.h.

Member Typedef Documentation

◆ RigidBodyVisualGroupConstObserver

◆ RigidBodyVisualGroupConstRef

◆ RigidBodyVisualGroupObserver

◆ RigidBodyVisualGroupRef

Constructor & Destructor Documentation

◆ RigidBodyRenderCache()

agxOSG::RigidBodyRenderCache::RigidBodyRenderCache ( bool  onlyAddEmittedBodies = true)

Default constructor.

Parameters
onlyAddEmittedBodies- True if only emitted RigidBodies should be added, false otherwise.

◆ ~RigidBodyRenderCache()

virtual agxOSG::RigidBodyRenderCache::~RigidBodyRenderCache ( )
protectedvirtual

Member Function Documentation

◆ addTemplateBodyToVisualCache()

const RigidBodyRenderCache::RigidBodyVisualGroup & agxOSG::RigidBodyRenderCache::addTemplateBodyToVisualCache ( agx::RigidBody *  body)

Add template body to visual cache that is used during playback in qtViewer.

Parameters
body- The specified template body to add to node cache.
Returns
the cached visual node, with all properties we need to recreated it, for the template body. An empty group if the body isn't a template.

◆ addToCache()

void agxOSG::RigidBodyRenderCache::addToCache ( osg::Group *  rootNode)

Add the osg::Group created from a RigidBody to the cache.

Parameters
rootNode- the rootNode that is used to build the cache.

◆ bodyIsTemplateEmitted()

bool agxOSG::RigidBodyRenderCache::bodyIsTemplateEmitted ( agx::RigidBody *  body)

Checks wherever the specifed body is generated/cloned from the temlpate body via RigidBodyEmitter och creation via the Momentum API.

Note
- the function checks if a string property called "TemplateUUID" eixsts in the body's property container.

◆ clear()

void agxOSG::RigidBodyRenderCache::clear ( )

Clear the internal cache.

◆ getCachedTemplateBodyVisual()

const RigidBodyRenderCache::RigidBodyVisualGroup & agxOSG::RigidBodyRenderCache::getCachedTemplateBodyVisual ( agx::RigidBody *  body)

Get cached template body visual from the node cache if it exists.

Returns
the cached visual node, with all properties we need to recreated it, for the template body if it exists, otherwise an empty group.

◆ getNode()

osg::Group * agxOSG::RigidBodyRenderCache::getNode ( agx::RigidBody *  body)

Get the current mapping in the cache between a RigidBody to a osg::Group.

Returns
the current osg::Group mapped from the RigidBody.

◆ getOnlyAddEmittedBodies()

bool agxOSG::RigidBodyRenderCache::getOnlyAddEmittedBodies ( ) const
Returns
true if only emitted bodies should be added, false otherwise.

◆ getOrCreateCachedTemplateBodyNode()

const RigidBodyRenderCache::RigidBodyVisualGroup & agxOSG::RigidBodyRenderCache::getOrCreateCachedTemplateBodyNode ( agx::RigidBody *  body)

Gets cached template body visual from the node cache if it exists, otherwise a new visual node will be created in the cache and returned.

If the specified body is not a generated from a Template, the function returns nullptr.

Parameters
body- the specified body that should be used to get or create the visual representation from the node cache.
Returns
the cached visual node for the template body. This is a an empty group if the RB isn't template.

◆ setOnlyAddEmittedBodies()

void agxOSG::RigidBodyRenderCache::setOnlyAddEmittedBodies ( bool  enable)
Parameters
enable- true if only emitted bodies should be added, false otherwise.

◆ shouldAddBody()

bool agxOSG::RigidBodyRenderCache::shouldAddBody ( agx::RigidBody *  body) const
protected

◆ traverseAndInsert()

void agxOSG::RigidBodyRenderCache::traverseAndInsert ( osg::Group *  rootNode)
protected

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