AGX Dynamics  2.37.2.0
HeightFieldDeformer.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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:
183  HeightFieldDeformerRef m_deformableHeightField;
189  };
190 }
191 
192 #endif
agx::ref_ptr< HeightFieldDeformer > HeightFieldDeformerRef
HeightFieldDeformer contains a agxCollide::HeightField.
agxSDK::Simulation::JournalAttachEvent::CallbackType m_journalAttachedCallback
Derive from this class to implement a listener for simulation step events.
agxCollide::HeightFieldRef m_heightField
const agx::Vec2iVector & getModifiedIndices() const
#define AGX_FORCE_INLINE
Definition: Object.h:59
agx::Real TimeStamp
Definition: TimeStamp.h:26
agxCollide::HeightField * getHeightField() const
Return the HeightFieldDeformer geometry (which is created in HeightFieldDeformer constructor) ...
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
Vector containing &#39;raw&#39; data.
Definition: Vector.h:245
Abstract representation of a data buffer.
Definition: Buffer.h:55
Utility class used to record HeightFieldDeformer in an agx::Journal.
Templated callback with two arguments.
Definition: Callback.h:139
A UUID, or Universally unique identifier, is intended to uniquely identify information in a distribut...
Definition: Uuid.h:41
#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
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
ActivationMask
Defines the event states for which a listener will be activated, a mask can be bitwise OR:ed from the...
bool isValid() const
Is the deformer valid? If not, no actions will be taken.
#define AGXMODEL_EXPORT
agx::VectorPOD< HeightFieldDeformer * > HeightFieldDeformerPtrVector
const agx::RealVector & getHeightDifferences() const
A HeightField is a collision shape that can be created from a grid structure, like an image...