AGX Dynamics  2.35.0.1
RigidBodyRenderCache.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agxQt/export.h>
20 #include <agx/Math.h>
21 #include <agx/Referenced.h>
22 #include <agx/RigidBody.h>
23 #include <agxOSG/GeometryNode.h>
24 
25 namespace agxQt
26 {
28 
37  {
38  public:
44  RigidBodyRenderCache(bool onlyAddEmittedBodies=true);
45 
51  void addToCache(osg::Group* rootNode);
52 
58 
63 
67  void setOnlyAddEmittedBodies( bool enable );
68 
72  void clear();
73 
74  protected:
76  void traverseAndInsert(osg::Group* group);
77  bool shouldAddBody(agx::RigidBody* body) const;
78 
79  private:
80  // Internal cache to map RigidBody to GeometryNode
81  BodyToGeometryNodeTable m_bodiesToGeometryNodes;
82  bool m_onlyAddEmittedBodies;
83  };
84 }
85 
86 
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXQT_EXPORT
A node that can be associated with a collision geometry so that the transformation of this node is up...
Definition: GeometryNode.h:42
RigidBodyRenderCache is used to cache mappings between RigidBodies and GeometryNodes for fast lookup ...
bool getOnlyAddEmittedBodies() const
RigidBodyRenderCache(bool onlyAddEmittedBodies=true)
Default constructor.
void addToCache(osg::Group *rootNode)
Add all GeometryNodes with connected RigidBodies in the osg::Group.
void traverseAndInsert(osg::Group *group)
agxOSG::GeometryNode * getNode(agx::RigidBody *body)
Get the current mapping in the cache between a RigidBody to a GeometryNode.
void clear()
Clear the internal cache.
void setOnlyAddEmittedBodies(bool enable)
bool shouldAddBody(agx::RigidBody *body) const
Inheritance with partial specialization due to bug with ref_ptr containers.
Base class providing referencing counted objects.
Definition: Referenced.h:114
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
Contains classes/utility functions for connecting AGX to QT with OSG.
agx::HashTable< agx::RigidBody *, agxOSG::GeometryNode * > BodyToGeometryNodeTable