AGX Dynamics  2.35.0.1
CellEntity.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
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a 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 
18 // AUTOMATICALLY GENERATED ENTITY, DO NOT EDIT! //
20 
21 #ifndef GENERATED_AGX_PHYSICS_HIERARCHICALGRID_CELL_H_PLUGIN
22 #define GENERATED_AGX_PHYSICS_HIERARCHICALGRID_CELL_H_PLUGIN
23 
24 #define AGX_ENTITY_WRAPPER 1
25 
26 
27 #ifdef _MSC_VER
28 # pragma warning(push)
29 // warning C4505: 'agxData::VectorAttributeT<T>::print' : unreferenced local function has been removed
30 # pragma warning( disable : 4505 )
31 // warning C4251: 'X' : class 'Y' needs to have dll-interface to be used by clients of class 'Z'
32 # pragma warning( disable : 4251 )
33 // warning C4355: 'this' : used in base member initializer list
34 # pragma warning( disable : 4355 )
35 // marked as __forceinline not inlined
36 # pragma warning( disable: 4714 )
37 #endif
38 
39 #include <agxData/EntityModel.h>
40 #include <agxData/EntityStorage.h>
41 #include <agxData/EntityRef.h>
42 #include <agxData/EntityPtr.h>
43 #include <agxData/EntityInstance.h>
44 #include <agx/Integer.h>
45 #include <agx/Real.h>
46 #include <agx/macros.h>
47 #include <agx/Integer.h>
48 #include <agx/Vec3.h>
49 #include <agx/Real.h>
50 #include <agx/IndexRange.h>
52 
53 namespace agx { namespace Physics { namespace HierarchicalGrid { class ContactZonePtr; }}}
54 
55 namespace agx
56 {
57  namespace Physics
58  {
59  namespace HierarchicalGrid
60  {
61 
62  class CellModel;
63  class CellData;
64  class CellPtr;
65  class CellInstance;
66  class CellSemantics;
67 
68 
70 
75  {
76  public:
77  typedef CellPtr PtrT;
78 
79  CellModel(const agx::String& name = "Cell");
80 
82  static CellModel* instance();
83 
86 
89 
91  virtual void shutdownCleanup() override;
92 
93 
94 
95  /* Attributes */
105  static const size_t childrenArraySize = 8;
108  static const size_t neighborsArraySize = 32;
117 
118  protected:
119  virtual ~CellModel();
120  virtual agxData::EntityData* createData(agxData::EntityStorage* storage) override;
121  virtual void configure(agx::TiXmlElement* eEntity) override;
122  virtual void initAttributeAccessors() override;
123  virtual void construct(agxData::EntityPtr instance) override;
125  };
126 
127 
129  #ifndef AGX_PHYSICS_HIERARCHICALGRID_CELL_DATA_SET_OVERRIDE
130  #define AGX_PHYSICS_HIERARCHICALGRID_CELL_DATA_SET
131  class AGXPHYSICS_EXPORT CellData : public agxData::EntityData
132  {
133  public:
134  CellInstance operator[] (size_t index);
135 
136  public:
137  agxData::Array< CellPtr >& instance;
144  agxData::Array< agx::IndexRange32 > collisionObjects;
147  static const size_t childrenArraySize = 8;
148  agxData::Array< agx::UInt8 > numChildren;
150  static const size_t neighborsArraySize = 32;
152  agxData::Array< agx::UInt32 > sortedIndex;
155  agxData::Array< agx::AtomicValue* > solveBodyOffsets;
156  agx::Real32 emptyThreshold;
157  agx::Real reorderingFrequency;
158  agx::Real sizeAlignment;
159 
160  public:
161  typedef agx::UInt8 tierType;
162  typedef agx::UInt8 invDepthType;
163  typedef agx::Vec3i idType;
164  typedef agx::Vec3 positionType;
165  typedef agx::UInt8 stateType;
166  typedef agx::Real32 emptyTimeType;
167  typedef agx::IndexRange32 collisionObjectsType;
168  typedef agx::UInt32 parentType;
169  typedef agx::UInt32 childrenType;
170  typedef agx::UInt8 numChildrenType;
171  typedef agx::UInt32 neighborsType;
172  typedef agx::UInt32 searchCostType;
173  typedef agx::UInt32 sortedIndexType;
174  typedef agx::Physics::HierarchicalGrid::ContactZonePtr internalZoneType;
175  typedef agx::UInt8 zoneTypeType;
176  typedef agx::AtomicValue* solveBodyOffsetsType;
177  typedef agx::Real32 emptyThresholdType;
178  typedef agx::Real reorderingFrequencyType;
179  typedef agx::Real sizeAlignmentType;
180 
181  public:
182  CellData(agxData::EntityStorage* storage);
183  CellData();
184 
185  protected:
186  virtual ~CellData() {}
187  virtual void setNumElements(agx::Index numElements) override;
188  virtual void synchronizeSharedAttribute(agxData::Value* value) override;
189 
190  private:
191  CellData& operator= (const CellData&) { return *this; }
192 
193  };
194  #endif
196 
197 
199  class AGXPHYSICS_EXPORT CellSemantics : protected agxData::EntityPtr
200  {
201  public:
202 
203  // Automatic getters
204  agx::UInt8 const& getTier() const;
205  agx::UInt8 const& getInvDepth() const;
206  agx::Vec3i const& getId() const;
207  agx::Vec3 const& getPosition() const;
208  agx::UInt8 const& getState() const;
209  agx::Real32 const& getEmptyTime() const;
210  agx::IndexRange32 const& getCollisionObjects() const;
211  agx::UInt32 const& getParent() const;
212  agx::UInt8 const& getNumChildren() const;
213  agx::UInt32 const& getSearchCost() const;
214  agx::UInt32 const& getSortedIndex() const;
215  agx::Physics::HierarchicalGrid::ContactZonePtr const& getInternalZone() const;
216  agx::UInt8 const& getZoneType() const;
217  agx::AtomicValue* const& getSolveBodyOffsets() const;
218 
219  // Semantics defined by explicit kernels
220 
221  // Automatic setters
222  void setTier(agx::UInt8 const& value);
223  void setInvDepth(agx::UInt8 const& value);
224  void setId(agx::Vec3i const& value);
225  void setPosition(agx::Vec3 const& value);
226  void setState(agx::UInt8 const& value);
227  void setEmptyTime(agx::Real32 const& value);
228  void setCollisionObjects(agx::IndexRange32 const& value);
229  void setParent(agx::UInt32 const& value);
230  void setNumChildren(agx::UInt8 const& value);
231  void setSearchCost(agx::UInt32 const& value);
232  void setSortedIndex(agx::UInt32 const& value);
233  void setInternalZone(agx::Physics::HierarchicalGrid::ContactZonePtr const& value);
234  void setZoneType(agx::UInt8 const& value);
235  void setSolveBodyOffsets(agx::AtomicValue* const& value);
236 
237 
238  protected:
239  friend class CellPtr;
240  friend class CellInstance;
241  CellSemantics();
242  };
244 
245 
246 
249  class CALLABLE CellPtr : public agxData::EntityPtr
250  {
251  public:
253  typedef CellData DataType;
254  typedef CellInstance InstanceType;
255 
256  public:
262  AGXPHYSICS_EXPORT CellPtr& operator= (const agxData::EntityInstance& instance);
263  AGXPHYSICS_EXPORT CellInstance instance();
264  AGXPHYSICS_EXPORT const CellInstance instance() const;
265 
266  AGXPHYSICS_EXPORT CellSemantics* operator->();
267  AGXPHYSICS_EXPORT const CellSemantics* operator->() const;
268 
269  CellData* getData();
270  const CellData* getData() const;
271 
272 
277 
282 
287 
292 
297 
302 
307 
312 
316  AGXPHYSICS_EXPORT agx::UInt32 const& children(size_t index) const;
317 
322 
326  AGXPHYSICS_EXPORT agx::UInt32 const& neighbors(size_t index) const;
327 
332 
337 
342 
347 
352 
357 
362 
367 
369  // Only used by tolua!
370  #ifdef AGX_GENERATED_TOLUA_WRAPPER
371  inline agx::UInt8 const& getTier() const { return (*this)->getTier(); }
372  inline agx::UInt8 const& getInvDepth() const { return (*this)->getInvDepth(); }
373  inline agx::Vec3i const& getId() const { return (*this)->getId(); }
374  inline agx::Vec3 const& getPosition() const { return (*this)->getPosition(); }
375  inline agx::UInt8 const& getState() const { return (*this)->getState(); }
376  inline agx::Real32 const& getEmptyTime() const { return (*this)->getEmptyTime(); }
377  inline agx::IndexRange32 const& getCollisionObjects() const { return (*this)->getCollisionObjects(); }
378  inline agx::UInt32 const& getParent() const { return (*this)->getParent(); }
379  inline agx::UInt8 const& getNumChildren() const { return (*this)->getNumChildren(); }
380  inline agx::UInt32 const& getSearchCost() const { return (*this)->getSearchCost(); }
381  inline agx::UInt32 const& getSortedIndex() const { return (*this)->getSortedIndex(); }
382  inline agx::Physics::HierarchicalGrid::ContactZonePtr const& getInternalZone() const { return (*this)->getInternalZone(); }
383  inline agx::UInt8 const& getZoneType() const { return (*this)->getZoneType(); }
384  inline agx::AtomicValue* const& getSolveBodyOffsets() const { return (*this)->getSolveBodyOffsets(); }
385 
386 
387  inline void setTier(agx::UInt8 const& value) { (*this)->setTier(value); }
388  inline void setInvDepth(agx::UInt8 const& value) { (*this)->setInvDepth(value); }
389  inline void setId(agx::Vec3i const& value) { (*this)->setId(value); }
390  inline void setPosition(agx::Vec3 const& value) { (*this)->setPosition(value); }
391  inline void setState(agx::UInt8 const& value) { (*this)->setState(value); }
392  inline void setEmptyTime(agx::Real32 const& value) { (*this)->setEmptyTime(value); }
393  inline void setCollisionObjects(agx::IndexRange32 const& value) { (*this)->setCollisionObjects(value); }
394  inline void setParent(agx::UInt32 const& value) { (*this)->setParent(value); }
395  inline void setNumChildren(agx::UInt8 const& value) { (*this)->setNumChildren(value); }
396  inline void setSearchCost(agx::UInt32 const& value) { (*this)->setSearchCost(value); }
397  inline void setSortedIndex(agx::UInt32 const& value) { (*this)->setSortedIndex(value); }
398  inline void setInternalZone(agx::Physics::HierarchicalGrid::ContactZonePtr const& value) { (*this)->setInternalZone(value); }
399  inline void setZoneType(agx::UInt8 const& value) { (*this)->setZoneType(value); }
400  inline void setSolveBodyOffsets(agx::AtomicValue* const& value) { (*this)->setSolveBodyOffsets(value); }
401  #endif
403 
404  };
405 
406 
408  class AGXPHYSICS_EXPORT CellInstance : public agxData::EntityInstance
409  {
410  public:
411  CellInstance();
412  CellInstance(CellData* data, agx::Index index);
413  CellInstance(agxData::EntityStorage *storage, agx::Index index);
414  CellInstance(const agxData::EntityInstance& other);
415  CellInstance(const agxData::EntityPtr& ptr);
416 
417  CellData* getData();
418  const CellData* getData() const;
419 
420  public:
422  agx::UInt8& tier();
424  agx::UInt8 const& tier() const;
425 
427  agx::UInt8& invDepth();
429  agx::UInt8 const& invDepth() const;
430 
432  agx::Vec3i& id();
434  agx::Vec3i const& id() const;
435 
437  agx::Vec3& position();
439  agx::Vec3 const& position() const;
440 
442  agx::UInt8& state();
444  agx::UInt8 const& state() const;
445 
447  agx::Real32& emptyTime();
449  agx::Real32 const& emptyTime() const;
450 
452  agx::IndexRange32& collisionObjects();
454  agx::IndexRange32 const& collisionObjects() const;
455 
457  agx::UInt32& parent();
459  agx::UInt32 const& parent() const;
460 
462  agxData::Array< agx::UInt32 > const children() const;
463  agx::UInt32& children(size_t index);
464  agx::UInt32 const& children(size_t index) const;
465 
467  agx::UInt8& numChildren();
469  agx::UInt8 const& numChildren() const;
470 
471  agxData::Array< agx::UInt32 > neighbors();
472  agxData::Array< agx::UInt32 > const neighbors() const;
473  agx::UInt32& neighbors(size_t index);
474  agx::UInt32 const& neighbors(size_t index) const;
475 
477  agx::UInt32& searchCost();
479  agx::UInt32 const& searchCost() const;
480 
482  agx::UInt32& sortedIndex();
484  agx::UInt32 const& sortedIndex() const;
485 
489  agx::Physics::HierarchicalGrid::ContactZonePtr const& internalZone() const;
490 
492  agx::UInt8& zoneType();
494  agx::UInt8 const& zoneType() const;
495 
497  agx::AtomicValue*& solveBodyOffsets();
499  agx::AtomicValue* const& solveBodyOffsets() const;
500 
502  agx::Real32& emptyThreshold();
504  agx::Real32 const& emptyThreshold() const;
505 
507  agx::Real& reorderingFrequency();
509  agx::Real const& reorderingFrequency() const;
510 
512  agx::Real& sizeAlignment();
514  agx::Real const& sizeAlignment() const;
515 
516  };
518 
519 
520 
522  typedef agxData::Array<CellPtr> CellPtrArray;
523 
524 
525 
527  /* Implementation */
528  //-----------------------------------------------------------------------------------------------------
529  //-----------------------------------------------------------------------------------------------------
530  inline CellInstance agx::Physics::HierarchicalGrid::CellData::operator[] (size_t index) { return CellInstance(this, (agx::Index)index); }
531  //-----------------------------------------------------------------------------------------------------
533  AGX_FORCE_INLINE CellPtr::CellPtr(agxData::EntityStorage* storage, agx::Index id) : agxData::EntityPtr(storage, id) {}
534  AGX_FORCE_INLINE CellPtr::CellPtr(const agxData::EntityPtr& ptr) : agxData::EntityPtr(ptr)
535  {
537  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
538  EntityPtr::getModel()->fullPath().c_str(), CellModel::instance()->fullPath().c_str());
539  }
540 
541  AGX_FORCE_INLINE CellPtr::CellPtr(const agxData::EntityInstance& instance) : agxData::EntityPtr(instance)
542  {
543  agxAssertN(!instance || instance.isInstanceOf(CellModel::instance()),
544  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
545  EntityPtr::getModel()->fullPath().c_str(), CellModel::instance()->fullPath().c_str());
546  }
547 
548  AGX_FORCE_INLINE CellPtr& CellPtr::operator= (const agxData::EntityPtr& ptr)
549  {
551  agxAssertN(!ptr || ptr.isInstanceOf(CellModel::instance()),
552  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
553  EntityPtr::getModel()->fullPath().c_str(), CellModel::instance()->fullPath().c_str());
554  return *this;
555  }
556 
557  AGX_FORCE_INLINE CellPtr& CellPtr::operator= (const agxData::EntityInstance& instance)
558  {
560  agxAssertN(!instance || instance.isInstanceOf(CellModel::instance()),
561  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
562  EntityPtr::getModel()->fullPath().c_str(), CellModel::instance()->fullPath().c_str());
563  return *this;
564  }
565 
566  inline CellInstance CellPtr::instance() { return agxData::EntityPtr::instance(); }
567  inline const CellInstance CellPtr::instance() const { return agxData::EntityPtr::instance(); }
568  AGX_FORCE_INLINE CellSemantics* CellPtr::operator->() { return (CellSemantics* )this; }
569  AGX_FORCE_INLINE const CellSemantics* CellPtr::operator->() const { return (const CellSemantics* )this; }
570  AGX_FORCE_INLINE CellData* CellPtr::getData() { return static_cast<CellData* >(agxData::EntityPtr::getData()); }
571  AGX_FORCE_INLINE const CellData* CellPtr::getData() const { return static_cast<const CellData* >(agxData::EntityPtr::getData()); }
572 
573  AGX_FORCE_INLINE agx::UInt8& CellPtr::tier() { verifyIndex(); return getData()->tier[calculateIndex()]; }
574  AGX_FORCE_INLINE agx::UInt8 const& CellPtr::tier() const { verifyIndex(); return getData()->tier[calculateIndex()]; }
575 
576  AGX_FORCE_INLINE agx::UInt8& CellPtr::invDepth() { verifyIndex(); return getData()->invDepth[calculateIndex()]; }
577  AGX_FORCE_INLINE agx::UInt8 const& CellPtr::invDepth() const { verifyIndex(); return getData()->invDepth[calculateIndex()]; }
578 
579  AGX_FORCE_INLINE agx::Vec3i& CellPtr::id() { verifyIndex(); return getData()->id[calculateIndex()]; }
580  AGX_FORCE_INLINE agx::Vec3i const& CellPtr::id() const { verifyIndex(); return getData()->id[calculateIndex()]; }
581 
582  AGX_FORCE_INLINE agx::Vec3& CellPtr::position() { verifyIndex(); return getData()->position[calculateIndex()]; }
583  AGX_FORCE_INLINE agx::Vec3 const& CellPtr::position() const { verifyIndex(); return getData()->position[calculateIndex()]; }
584 
585  AGX_FORCE_INLINE agx::UInt8& CellPtr::state() { verifyIndex(); return getData()->state[calculateIndex()]; }
586  AGX_FORCE_INLINE agx::UInt8 const& CellPtr::state() const { verifyIndex(); return getData()->state[calculateIndex()]; }
587 
588  AGX_FORCE_INLINE agx::Real32& CellPtr::emptyTime() { verifyIndex(); return getData()->emptyTime[calculateIndex()]; }
589  AGX_FORCE_INLINE agx::Real32 const& CellPtr::emptyTime() const { verifyIndex(); return getData()->emptyTime[calculateIndex()]; }
590 
591  AGX_FORCE_INLINE agx::IndexRange32& CellPtr::collisionObjects() { verifyIndex(); return getData()->collisionObjects[calculateIndex()]; }
592  AGX_FORCE_INLINE agx::IndexRange32 const& CellPtr::collisionObjects() const { verifyIndex(); return getData()->collisionObjects[calculateIndex()]; }
593 
594  AGX_FORCE_INLINE agx::UInt32& CellPtr::parent() { verifyIndex(); return getData()->parent[calculateIndex()]; }
595  AGX_FORCE_INLINE agx::UInt32 const& CellPtr::parent() const { verifyIndex(); return getData()->parent[calculateIndex()]; }
596 
597  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > CellPtr::children() { verifyIndex(); return getData()->children.slice(agx::IndexRange32(calculateIndex() * (agx::Index)CellData::childrenArraySize, (calculateIndex()+1) * (agx::Index)CellData::childrenArraySize)); }
598  AGX_FORCE_INLINE const agxData::Array< agx::UInt32 > CellPtr::children() const { verifyIndex(); return getData()->children.slice(agx::IndexRange32(calculateIndex() * (agx::Index)CellData::childrenArraySize, (calculateIndex()+1) * (agx::Index)CellData::childrenArraySize)); }
599  AGX_FORCE_INLINE agx::UInt32& CellPtr::children(size_t index) { return this->children()[index]; }
600  AGX_FORCE_INLINE agx::UInt32 const& CellPtr::children(size_t index) const { return this->children()[index]; }
601 
602  AGX_FORCE_INLINE agx::UInt8& CellPtr::numChildren() { verifyIndex(); return getData()->numChildren[calculateIndex()]; }
603  AGX_FORCE_INLINE agx::UInt8 const& CellPtr::numChildren() const { verifyIndex(); return getData()->numChildren[calculateIndex()]; }
604 
605  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > CellPtr::neighbors() { verifyIndex(); return getData()->neighbors.slice(agx::IndexRange32(calculateIndex() * (agx::Index)CellData::neighborsArraySize, (calculateIndex()+1) * (agx::Index)CellData::neighborsArraySize)); }
606  AGX_FORCE_INLINE const agxData::Array< agx::UInt32 > CellPtr::neighbors() const { verifyIndex(); return getData()->neighbors.slice(agx::IndexRange32(calculateIndex() * (agx::Index)CellData::neighborsArraySize, (calculateIndex()+1) * (agx::Index)CellData::neighborsArraySize)); }
607  AGX_FORCE_INLINE agx::UInt32& CellPtr::neighbors(size_t index) { return this->neighbors()[index]; }
608  AGX_FORCE_INLINE agx::UInt32 const& CellPtr::neighbors(size_t index) const { return this->neighbors()[index]; }
609 
610  AGX_FORCE_INLINE agx::UInt32& CellPtr::searchCost() { verifyIndex(); return getData()->searchCost[calculateIndex()]; }
611  AGX_FORCE_INLINE agx::UInt32 const& CellPtr::searchCost() const { verifyIndex(); return getData()->searchCost[calculateIndex()]; }
612 
613  AGX_FORCE_INLINE agx::UInt32& CellPtr::sortedIndex() { verifyIndex(); return getData()->sortedIndex[calculateIndex()]; }
614  AGX_FORCE_INLINE agx::UInt32 const& CellPtr::sortedIndex() const { verifyIndex(); return getData()->sortedIndex[calculateIndex()]; }
615 
616  AGX_FORCE_INLINE agx::Physics::HierarchicalGrid::ContactZonePtr& CellPtr::internalZone() { verifyIndex(); return getData()->internalZone[calculateIndex()]; }
617  AGX_FORCE_INLINE agx::Physics::HierarchicalGrid::ContactZonePtr const& CellPtr::internalZone() const { verifyIndex(); return getData()->internalZone[calculateIndex()]; }
618 
619  AGX_FORCE_INLINE agx::UInt8& CellPtr::zoneType() { verifyIndex(); return getData()->zoneType[calculateIndex()]; }
620  AGX_FORCE_INLINE agx::UInt8 const& CellPtr::zoneType() const { verifyIndex(); return getData()->zoneType[calculateIndex()]; }
621 
622  AGX_FORCE_INLINE agx::AtomicValue*& CellPtr::solveBodyOffsets() { verifyIndex(); return getData()->solveBodyOffsets[calculateIndex()]; }
623  AGX_FORCE_INLINE agx::AtomicValue* const& CellPtr::solveBodyOffsets() const { verifyIndex(); return getData()->solveBodyOffsets[calculateIndex()]; }
624 
625  AGX_FORCE_INLINE agx::Real32& CellPtr::emptyThreshold() { verifyIndex(); return getData()->emptyThreshold; }
626  AGX_FORCE_INLINE agx::Real32 const& CellPtr::emptyThreshold() const { verifyIndex(); return getData()->emptyThreshold; }
627 
628  AGX_FORCE_INLINE agx::Real& CellPtr::reorderingFrequency() { verifyIndex(); return getData()->reorderingFrequency; }
629  AGX_FORCE_INLINE agx::Real const& CellPtr::reorderingFrequency() const { verifyIndex(); return getData()->reorderingFrequency; }
630 
631  AGX_FORCE_INLINE agx::Real& CellPtr::sizeAlignment() { verifyIndex(); return getData()->sizeAlignment; }
632  AGX_FORCE_INLINE agx::Real const& CellPtr::sizeAlignment() const { verifyIndex(); return getData()->sizeAlignment; }
633 
634  //-----------------------------------------------------------------------------------------------------
635  AGX_FORCE_INLINE CellInstance::CellInstance() {}
636  AGX_FORCE_INLINE CellInstance::CellInstance(CellData* data, agx::Index index) : agxData::EntityInstance(data, index) {}
637  AGX_FORCE_INLINE CellInstance::CellInstance(agxData::EntityStorage* storage, agx::Index index) : agxData::EntityInstance(storage, index) {}
638  AGX_FORCE_INLINE CellInstance::CellInstance(const agxData::EntityInstance& other) : agxData::EntityInstance(other)
639  {
640  agxAssertN(!other || other.isInstanceOf(CellModel::instance()),
641  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
643  }
644 
645  AGX_FORCE_INLINE CellInstance::CellInstance(const agxData::EntityPtr& ptr) : agxData::EntityInstance(ptr)
646  {
648  "Entity type mismatch. Storage contains entity data for type \'%s\', instance pointer is of type \'%s\'",
650  }
651 
652 
653  AGX_FORCE_INLINE CellData* CellInstance::getData() { return static_cast<CellData* >(agxData::EntityInstance::getData()); }
654  AGX_FORCE_INLINE const CellData* CellInstance::getData() const { return static_cast<const CellData* >(agxData::EntityInstance::getData()); }
655 
656  AGX_FORCE_INLINE agx::UInt8& CellInstance::tier() { verifyIndex(); return getData()->tier[getIndex()]; }
657  AGX_FORCE_INLINE agx::UInt8 const& CellInstance::tier() const { verifyIndex(); return getData()->tier[getIndex()]; }
658 
659  AGX_FORCE_INLINE agx::UInt8& CellInstance::invDepth() { verifyIndex(); return getData()->invDepth[getIndex()]; }
660  AGX_FORCE_INLINE agx::UInt8 const& CellInstance::invDepth() const { verifyIndex(); return getData()->invDepth[getIndex()]; }
661 
662  AGX_FORCE_INLINE agx::Vec3i& CellInstance::id() { verifyIndex(); return getData()->id[getIndex()]; }
663  AGX_FORCE_INLINE agx::Vec3i const& CellInstance::id() const { verifyIndex(); return getData()->id[getIndex()]; }
664 
665  AGX_FORCE_INLINE agx::Vec3& CellInstance::position() { verifyIndex(); return getData()->position[getIndex()]; }
666  AGX_FORCE_INLINE agx::Vec3 const& CellInstance::position() const { verifyIndex(); return getData()->position[getIndex()]; }
667 
668  AGX_FORCE_INLINE agx::UInt8& CellInstance::state() { verifyIndex(); return getData()->state[getIndex()]; }
669  AGX_FORCE_INLINE agx::UInt8 const& CellInstance::state() const { verifyIndex(); return getData()->state[getIndex()]; }
670 
671  AGX_FORCE_INLINE agx::Real32& CellInstance::emptyTime() { verifyIndex(); return getData()->emptyTime[getIndex()]; }
672  AGX_FORCE_INLINE agx::Real32 const& CellInstance::emptyTime() const { verifyIndex(); return getData()->emptyTime[getIndex()]; }
673 
674  AGX_FORCE_INLINE agx::IndexRange32& CellInstance::collisionObjects() { verifyIndex(); return getData()->collisionObjects[getIndex()]; }
675  AGX_FORCE_INLINE agx::IndexRange32 const& CellInstance::collisionObjects() const { verifyIndex(); return getData()->collisionObjects[getIndex()]; }
676 
677  AGX_FORCE_INLINE agx::UInt32& CellInstance::parent() { verifyIndex(); return getData()->parent[getIndex()]; }
678  AGX_FORCE_INLINE agx::UInt32 const& CellInstance::parent() const { verifyIndex(); return getData()->parent[getIndex()]; }
679 
680  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > CellInstance::children() { verifyIndex(); return getData()->children.slice(agx::IndexRange32(getIndex() * (agx::Index)CellData::childrenArraySize, (getIndex()+1) * (agx::Index)CellData::childrenArraySize)); }
681  AGX_FORCE_INLINE const agxData::Array< agx::UInt32 > CellInstance::children() const { verifyIndex(); return getData()->children.slice(agx::IndexRange32(getIndex() * (agx::Index)CellData::childrenArraySize, (getIndex()+1) * (agx::Index)CellData::childrenArraySize)); }
682  AGX_FORCE_INLINE agx::UInt32& CellInstance::children(size_t index) { return this->children()[index]; }
683  AGX_FORCE_INLINE agx::UInt32 const& CellInstance::children(size_t index) const { return this->children()[index]; }
684 
685  AGX_FORCE_INLINE agx::UInt8& CellInstance::numChildren() { verifyIndex(); return getData()->numChildren[getIndex()]; }
686  AGX_FORCE_INLINE agx::UInt8 const& CellInstance::numChildren() const { verifyIndex(); return getData()->numChildren[getIndex()]; }
687 
688  AGX_FORCE_INLINE agxData::Array< agx::UInt32 > CellInstance::neighbors() { verifyIndex(); return getData()->neighbors.slice(agx::IndexRange32(getIndex() * (agx::Index)CellData::neighborsArraySize, (getIndex()+1) * (agx::Index)CellData::neighborsArraySize)); }
689  AGX_FORCE_INLINE const agxData::Array< agx::UInt32 > CellInstance::neighbors() const { verifyIndex(); return getData()->neighbors.slice(agx::IndexRange32(getIndex() * (agx::Index)CellData::neighborsArraySize, (getIndex()+1) * (agx::Index)CellData::neighborsArraySize)); }
690  AGX_FORCE_INLINE agx::UInt32& CellInstance::neighbors(size_t index) { return this->neighbors()[index]; }
691  AGX_FORCE_INLINE agx::UInt32 const& CellInstance::neighbors(size_t index) const { return this->neighbors()[index]; }
692 
693  AGX_FORCE_INLINE agx::UInt32& CellInstance::searchCost() { verifyIndex(); return getData()->searchCost[getIndex()]; }
694  AGX_FORCE_INLINE agx::UInt32 const& CellInstance::searchCost() const { verifyIndex(); return getData()->searchCost[getIndex()]; }
695 
696  AGX_FORCE_INLINE agx::UInt32& CellInstance::sortedIndex() { verifyIndex(); return getData()->sortedIndex[getIndex()]; }
697  AGX_FORCE_INLINE agx::UInt32 const& CellInstance::sortedIndex() const { verifyIndex(); return getData()->sortedIndex[getIndex()]; }
698 
699  AGX_FORCE_INLINE agx::Physics::HierarchicalGrid::ContactZonePtr& CellInstance::internalZone() { verifyIndex(); return getData()->internalZone[getIndex()]; }
700  AGX_FORCE_INLINE agx::Physics::HierarchicalGrid::ContactZonePtr const& CellInstance::internalZone() const { verifyIndex(); return getData()->internalZone[getIndex()]; }
701 
702  AGX_FORCE_INLINE agx::UInt8& CellInstance::zoneType() { verifyIndex(); return getData()->zoneType[getIndex()]; }
703  AGX_FORCE_INLINE agx::UInt8 const& CellInstance::zoneType() const { verifyIndex(); return getData()->zoneType[getIndex()]; }
704 
705  AGX_FORCE_INLINE agx::AtomicValue*& CellInstance::solveBodyOffsets() { verifyIndex(); return getData()->solveBodyOffsets[getIndex()]; }
706  AGX_FORCE_INLINE agx::AtomicValue* const& CellInstance::solveBodyOffsets() const { verifyIndex(); return getData()->solveBodyOffsets[getIndex()]; }
707 
708  AGX_FORCE_INLINE agx::Real32& CellInstance::emptyThreshold() { verifyIndex(); return getData()->emptyThreshold; }
709  AGX_FORCE_INLINE agx::Real32 const& CellInstance::emptyThreshold() const { verifyIndex(); return getData()->emptyThreshold; }
710 
711  AGX_FORCE_INLINE agx::Real& CellInstance::reorderingFrequency() { verifyIndex(); return getData()->reorderingFrequency; }
712  AGX_FORCE_INLINE agx::Real const& CellInstance::reorderingFrequency() const { verifyIndex(); return getData()->reorderingFrequency; }
713 
714  AGX_FORCE_INLINE agx::Real& CellInstance::sizeAlignment() { verifyIndex(); return getData()->sizeAlignment; }
715  AGX_FORCE_INLINE agx::Real const& CellInstance::sizeAlignment() const { verifyIndex(); return getData()->sizeAlignment; }
716 
717  //-----------------------------------------------------------------------------------------------------
718  AGX_FORCE_INLINE CellSemantics::CellSemantics() {}
719  //-----------------------------------------------------------------------------------------------------
721  }
722  }
723 }
724 
725 AGX_TYPE_BINDING(agx::Physics::HierarchicalGrid::CellPtr, "Physics.HierarchicalGrid.CellPtr")
726 AGX_TYPE_BINDING(agx::Physics::HierarchicalGrid::CellInstance, "Physics.HierarchicalGrid.CellInstance")
727 
728 #ifdef _MSC_VER
729 # pragma warning(pop)
730 #endif
731 
732 #undef AGX_ENTITY_WRAPPER
733 #undef AGX_ENTITY_NAMESPACE
734 #endif
735 
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
#define AGXPHYSICS_EXPORT
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
Entity instance provides access to a single instance in an EntityStorage.
bool isInstanceOf(agxData::EntityModel *model) const
agxData::EntityData * getData()
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
Definition: EntityModel.h:64
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:52
bool isInstanceOf(agxData::EntityModel *model) const
agxData::EntityData * getData()
agxData::EntityInstance instance()
Definition: EntityPtr.h:269
EntityPtr & operator=(const EntityPtr &other)=default
Data storage for a collection of entity instances of a specified EntityModel.
Definition: EntityStorage.h:73
Abstract representation of a value.
Definition: Value.h:43
A range of indices.
Definition: IndexRange.h:33
agx::String fullPath() const
Abstract description of the data attributes for the Physics.HierarchicalGrid.Cell entity.
Definition: CellEntity.h:75
virtual void shutdownCleanup() override
This is part of internal cleanup and should not be called by users.
static agxData::ScalarAttributeT< agx::UInt32 > * searchCostAttribute
Definition: CellEntity.h:109
static agxData::ScalarAttributeT< agx::Physics::HierarchicalGrid::ContactZonePtr > * internalZoneAttribute
Definition: CellEntity.h:111
static agxData::ScalarAttributeT< agx::UInt8 > * stateAttribute
Definition: CellEntity.h:100
virtual void initAttributeAccessors() override
static agxData::ScalarAttributeT< agx::IndexRange32 > * collisionObjectsAttribute
Definition: CellEntity.h:102
virtual void configure(agx::TiXmlElement *eEntity) override
static CellPtr createInstance()
Create and return a pointer to a new instance in the default storage for this entity model.
static agxData::ScalarAttributeT< agx::Vec3 > * positionAttribute
Definition: CellEntity.h:99
static agxData::SharedAttributeT< agx::Real32 > * emptyThresholdAttribute
Definition: CellEntity.h:114
static agxData::ScalarAttributeT< agx::Vec3i > * idAttribute
Definition: CellEntity.h:98
static agxData::ScalarAttributeT< agx::UInt8 > * zoneTypeAttribute
Definition: CellEntity.h:112
static agxData::ScalarAttributeT< agx::UInt32 > * sortedIndexAttribute
Definition: CellEntity.h:110
static agxData::ScalarAttributeT< agx::UInt32 > * parentAttribute
Definition: CellEntity.h:103
static agxData::SharedAttributeT< agx::Real > * sizeAlignmentAttribute
Definition: CellEntity.h:116
CellModel(const agx::String &name="Cell")
void construct(agx::Physics::HierarchicalGrid::CellPtr cell)
static agxData::SharedAttributeT< agx::Real > * reorderingFrequencyAttribute
Definition: CellEntity.h:115
static agxData::ScalarAttributeT< agx::UInt8 > * numChildrenAttribute
Definition: CellEntity.h:106
static agxData::ScalarAttributeT< agx::UInt32 > * childrenAttribute
Definition: CellEntity.h:104
static agxData::ScalarAttributeT< agx::UInt8 > * invDepthAttribute
Definition: CellEntity.h:97
static agxData::ScalarAttributeT< agx::Real32 > * emptyTimeAttribute
Definition: CellEntity.h:101
static agxData::PointerAttributeT< agx::AtomicValue * > * solveBodyOffsetsAttribute
Definition: CellEntity.h:113
static agxData::ScalarAttributeT< agx::UInt32 > * neighborsAttribute
Definition: CellEntity.h:107
static agxData::ScalarAttributeT< agx::UInt8 > * tierAttribute
Definition: CellEntity.h:96
static agxData::EntityStorage * defaultStorage()
virtual agxData::EntityData * createData(agxData::EntityStorage *storage) override
virtual void construct(agxData::EntityPtr instance) override
Pointer to a entity instance of type Physics.HierarchicalGrid.Cell.
Definition: CellEntity.h:250
AGXPHYSICS_EXPORT agxData::Array< agx::UInt32 > const children() const
AGXPHYSICS_EXPORT agxData::Array< agx::UInt32 > neighbors()
AGXPHYSICS_EXPORT agx::Real & reorderingFrequency()
AGXPHYSICS_EXPORT agx::UInt8 const & invDepth() const
AGXPHYSICS_EXPORT agx::IndexRange32 & collisionObjects()
AGXPHYSICS_EXPORT agx::UInt32 const & parent() const
AGXPHYSICS_EXPORT agxData::Array< agx::UInt32 > children()
AGXPHYSICS_EXPORT agx::UInt32 const & searchCost() const
AGXPHYSICS_EXPORT agx::Real const & sizeAlignment() const
AGXPHYSICS_EXPORT CellPtr(const agxData::EntityInstance &instance)
AGXPHYSICS_EXPORT agx::AtomicValue *const & solveBodyOffsets() const
AGXPHYSICS_EXPORT agx::UInt32 & neighbors(size_t index)
AGXPHYSICS_EXPORT agx::Physics::HierarchicalGrid::ContactZonePtr const & internalZone() const
AGXPHYSICS_EXPORT agx::UInt8 & numChildren()
AGXPHYSICS_EXPORT agxData::Array< agx::UInt32 > const neighbors() const
AGXPHYSICS_EXPORT agx::Real32 const & emptyThreshold() const
AGXPHYSICS_EXPORT agx::UInt32 const & sortedIndex() const
AGXPHYSICS_EXPORT agx::Real const & reorderingFrequency() const
AGXPHYSICS_EXPORT agx::AtomicValue *& solveBodyOffsets()
AGXPHYSICS_EXPORT agx::Physics::HierarchicalGrid::ContactZonePtr & internalZone()
AGXPHYSICS_EXPORT CellPtr(const agxData::EntityPtr &ptr)
AGXPHYSICS_EXPORT agx::UInt32 & searchCost()
AGXPHYSICS_EXPORT agx::UInt8 & tier()
AGXPHYSICS_EXPORT CellInstance instance()
AGXPHYSICS_EXPORT agx::Vec3 & position()
AGXPHYSICS_EXPORT const CellInstance instance() const
AGXPHYSICS_EXPORT const CellSemantics * operator->() const
AGXPHYSICS_EXPORT agx::UInt32 & children(size_t index)
AGXPHYSICS_EXPORT agx::UInt8 & invDepth()
AGXPHYSICS_EXPORT agx::UInt32 const & children(size_t index) const
AGXPHYSICS_EXPORT agx::Real32 & emptyThreshold()
AGXPHYSICS_EXPORT agx::UInt8 & zoneType()
AGXPHYSICS_EXPORT agx::UInt32 & sortedIndex()
const CellData * getData() const
AGXPHYSICS_EXPORT agx::UInt8 const & tier() const
AGXPHYSICS_EXPORT agx::Real & sizeAlignment()
AGXPHYSICS_EXPORT agx::Vec3i & id()
AGXPHYSICS_EXPORT CellSemantics * operator->()
AGXPHYSICS_EXPORT agx::UInt8 & state()
AGXPHYSICS_EXPORT agx::Vec3i const & id() const
AGXPHYSICS_EXPORT agx::IndexRange32 const & collisionObjects() const
AGXPHYSICS_EXPORT agx::UInt32 & parent()
AGXPHYSICS_EXPORT agx::UInt8 const & state() const
AGXPHYSICS_EXPORT agx::Real32 const & emptyTime() const
AGXPHYSICS_EXPORT agx::UInt8 const & numChildren() const
AGXPHYSICS_EXPORT agx::Vec3 const & position() const
AGXPHYSICS_EXPORT agx::UInt8 const & zoneType() const
AGXPHYSICS_EXPORT agx::Real32 & emptyTime()
AGXPHYSICS_EXPORT agx::UInt32 const & neighbors(size_t index) const
AGXPHYSICS_EXPORT CellPtr(agxData::EntityStorage *storage, agx::Index id)
Pointer to a entity instance of type Physics.HierarchicalGrid.ContactZone.
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define agxAssertN(expr, format,...)
Definition: debug.h:145
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:97
#define CALLABLE
Definition: macros.h:72
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:96
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes for low level data storage for AGX.
Definition: Container.h:23
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt32
Definition: Integer.h:40
double Real
Definition: Real.h:42
uint8_t UInt8
Definition: Integer.h:38
float Real32
Definition: Real.h:44
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Definition: Object.h:364
UInt32 Index
Definition: Integer.h:52