AGXDynamics  2.35.0.3
HeightFieldDeformer.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 #ifndef AGXMODEL_HEIGHT_FIELD_DEFORMER_H
18 #define AGXMODEL_HEIGHT_FIELD_DEFORMER_H
19 
20 #include <agxModel/export.h>
21 
23 #include <agxSDK/Simulation.h>
24 #include <agxCollide/HeightField.h>
25 #include <agx/Journal.h>
26 
27 namespace agxModel
28 {
30 
37  {
39  public:
40 
45 
49  agxCollide::HeightField* getHeightField() const;
50 
52  bool isValid() const;
53 
57  const agx::Vec2iVector& getModifiedIndices() const;
58 
63  const agx::RealVector& getHeightDifferences() const;
64 
71  static bool extractHeightFieldDeformers(agxModel::HeightFieldDeformerPtrVector& deformers, agxSDK::Simulation* simulation);
72 
74 
75  protected:
76  virtual ~HeightFieldDeformer();
78 
79  protected:
81  bool m_valid;
84 
85 
86  };
87 
89 
90  // Implementations
91 
93  {
94  return m_heightField;
95  }
96 
97 
99  {
100  return m_valid;
101  }
102 
103 
105  {
106  return m_modifiedIndices;
107  }
108 
109 
111  {
112  return m_heightDifferences;
113  }
114 
115 
117  {
118  }
119 
124  {
125  public:
131 
136  virtual void preCollide(const agx::TimeStamp& time) override;
137 
142  virtual void pre(const agx::TimeStamp& time) override;
143 
148  virtual void post(const agx::TimeStamp& time) override;
149 
151  virtual void addNotification() override;
152 
154 
155  protected:
156 
157  bool heigthBufferIsValid();
158 
159  void storeHeights();
160 
161  void storeChangedVertices();
162 
163  void restoreHeights();
164 
165  void initHeightFieldStorage();
166 
167  void createJournalBindings(agx::Journal* journal);
168 
169  void journalAttachedCallback(agxSDK::Simulation* simulation, agx::Journal* journal);
170 
171  agxData::Buffer* getHeightBuffer();
172 
174 
175  private:
177 
179  // Variables
181  protected:
189  };
190 }
191 
192 #endif
agxModel::HeightFieldDeformerJournalRecorder::m_dataRootUUID
agx::Uuid m_dataRootUUID
Definition: HeightFieldDeformer.h:187
agxModel::HeightFieldDeformerPtrVector
agx::VectorPOD< HeightFieldDeformer * > HeightFieldDeformerPtrVector
Definition: HeightFieldDeformer.h:32
HeightField.h
agxModel::HeightFieldDeformer::m_heightField
agxCollide::HeightFieldRef m_heightField
Definition: HeightFieldDeformer.h:80
agx::Journal
Definition: Journal.h:46
agxModel
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
agxSDK::StepEventListener
Derive from this class to implement a listener for simulation step events.
Definition: StepEventListener.h:37
agxModel::HeightFieldDeformerRef
agx::ref_ptr< HeightFieldDeformer > HeightFieldDeformerRef
Definition: HeightFieldDeformer.h:29
agxSDK::StepEventListener::ActivationMask
ActivationMask
Defines the event states for which a listener will be activated, a mask can be bitwise OR:ed from the...
Definition: StepEventListener.h:42
Simulation.h
agxModel::HeightFieldDeformerJournalRecorder::m_heightIndices
agx::RealVector m_heightIndices
Definition: HeightFieldDeformer.h:184
export.h
agxCollide::HeightField
A HeightField is a collision shape that can be created from a grid structure, like an image.
Definition: agxCollide/HeightField.h:51
agxModel::HeightFieldDeformer::getHeightField
agxCollide::HeightField * getHeightField() const
Return the HeightFieldDeformer geometry (which is created in HeightFieldDeformer constructor)
Definition: HeightFieldDeformer.h:92
agxModel::HeightFieldDeformer::getHeightDifferences
const agx::RealVector & getHeightDifferences() const
Definition: HeightFieldDeformer.h:110
agxModel::HeightFieldDeformer::m_modifiedIndices
agx::Vec2iVector m_modifiedIndices
Definition: HeightFieldDeformer.h:82
StepEventListener.h
AGXSTREAM_DECLARE_SERIALIZABLE
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
agx::VectorPOD
Vector containing 'raw' data.
Definition: Vector.h:245
agx::observer_ptr< Journal >
agxModel::HeightFieldDeformerJournalRecorder::m_dataRoot
agx::ComponentRef m_dataRoot
Definition: HeightFieldDeformer.h:186
agxModel::HeightFieldDeformerJournalRecorder::m_journal
agx::JournalObserver m_journal
Definition: HeightFieldDeformer.h:188
agxModel::HeightFieldDeformer::getModifiedIndices
const agx::Vec2iVector & getModifiedIndices() const
Definition: HeightFieldDeformer.h:104
agx::ref_ptr< HeightFieldDeformer >
agxSDK::Simulation
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
Journal.h
agxModel::HeightFieldDeformerJournalRecorder::m_deformableHeightField
HeightFieldDeformerRef m_deformableHeightField
Definition: HeightFieldDeformer.h:183
agxData::Buffer
Abstract representation of a data buffer.
Definition: Buffer.h:55
agxModel::HeightFieldDeformer::m_valid
bool m_valid
Definition: HeightFieldDeformer.h:81
agxModel::HeightFieldDeformerJournalRecorder::m_journalAttachedCallback
agxSDK::Simulation::JournalAttachEvent::CallbackType m_journalAttachedCallback
Definition: HeightFieldDeformer.h:182
agx::TimeStamp
agx::Real TimeStamp
Definition: TimeStamp.h:26
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agxModel::HeightFieldDeformer::~HeightFieldDeformer
virtual ~HeightFieldDeformer()
Definition: HeightFieldDeformer.h:116
agxModel::HeightFieldDeformer::isValid
bool isValid() const
Is the deformer valid? If not, no actions will be taken.
Definition: HeightFieldDeformer.h:98
agxModel::HeightFieldDeformerJournalRecorder::m_heigthBuffer
agxData::BufferRef m_heigthBuffer
Definition: HeightFieldDeformer.h:185
agx::Uuid
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
agx::Callback2
Templated callback with two arguments.
Definition: Callback.h:139
agxModel::HeightFieldDeformerJournalRecorder
Utility class used to record HeightFieldDeformer in an agx::Journal.
Definition: HeightFieldDeformer.h:123
agxModel::HeightFieldDeformer::m_heightDifferences
agx::RealVector m_heightDifferences
Definition: HeightFieldDeformer.h:83
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agxModel::HeightFieldDeformer
HeightFieldDeformer contains a agxCollide::HeightField.
Definition: HeightFieldDeformer.h:36