33 # pragma warning(push) 34 # pragma warning(disable: 6011) // Disable warningC6011: dereferencing nullptr pointer 42 class GlobalResultStorage;
48 class SimulationFrameWriter;
78 virtual void configure(agx::TiXmlElement *eStorage)
override;
85 void addListener(EventListener *listener);
86 void removeListener(EventListener *listener);
87 bool hasListener(EventListener *listener);
109 size_t capacity()
const;
114 size_t getNumBytes()
const;
125 void reserve(
size_t size);
133 template <
typename T>
136 template <
typename T>
151 void resize(
size_t size,
bool initializeElements =
true);
153 size_t presize(
size_t size,
size_t initialSize = 0);
156 void destroyInstance(
size_t id);
158 template <
typename VectorT>
159 void destroyInstances(
const VectorT& instances);
165 void swapInstances(
const InstanceSwapVector &swaps);
168 void swapInstances(
const InstanceSwapLocalVector& swaps);
228 size_t idToIndex(
size_t id)
const;
233 size_t indexToId(
size_t index)
const;
239 agxData::EntityData *getData();
241 template <
typename T>
244 template <
typename T>
245 const T* getData()
const;
252 void setUseInstanceTable(
bool flag);
257 bool useInstanceTable()
const;
291 void print(std::ostream& stream)
const;
294 void verifyConsistency();
300 template <
typename T>
301 T&
get(
const agx::Name& attributeName,
size_t index);
305 void preparePermutation();
320 template <
typename T>
323 template <
typename T>
331 void keyFrameResize(
size_t size,
size_t capacity);
333 void setEnableEvents(
bool flag);
339 void printInstanceTable()
const;
355 friend class EntityData;
357 void commitBatch(
size_t size);
365 void swapInstances(
size_t index1,
size_t index2);
366 void init(
size_t initialCapacity);
373 void elementBufferReallocationCallback(
Buffer* elementBuffer);
381 void destroyInstances(
const EntityPtr* instances,
size_t numInstances,
bool triggerEvent =
true);
389 template <
typename T>
398 bool m_useInstanceTable;
399 bool m_implicitResize;
401 bool m_usedResizeMethod;
404 BufferTable m_bufferTable;
407 EntityDataRef m_dataSet;
410 AttributeTable m_customAttributes;
423 Buffer::Event::CallbackType m_elementBufferReallocationCallback;
424 EventDispatch m_eventDispatch;
445 AGX_FORCE_INLINE bool EntityStorage::useInstanceTable()
const {
return m_useInstanceTable; }
448 AGX_FORCE_INLINE const BufferTable& EntityStorage::getBuffers()
const {
return m_bufferTable; }
457 template <
typename T>
460 agxAssert(agxData::getFormat<T>()->
is(agxData::getFormat<EntityPtr>()));
464 template <
typename T>
472 buffer = this->createBuffer(attribute);
478 template <
typename T>
481 Buffer *buffer = this->getBuffer(attribute);
485 template <
typename T>
488 for (
size_t i = 0; i < m_buffers.size(); ++i)
490 Buffer *buffer = m_buffers[i];
491 if (buffer->
getName() == attributeName)
496 return m_buffers[0]->getElement<T>(0);
502 return m_idToIndexArray[id];
513 destroyInstance(instance.
getId());
522 template <
typename T>
525 template <
typename T>
526 AGX_FORCE_INLINE const T *EntityStorage::getData()
const {
return m_dataSet->as<
const T>(); }
540 return m_storage->idToIndex(
id);
546 return m_storage->indexToId(index);
551 return this->createInstances(1);
556 if (m_numElements + numInstances >= m_storage->size())
558 if (!m_hasBatchInstances)
560 m_storage->beginBatch();
561 m_hasBatchInstances =
true;
566 m_numElements = head;
570 m_numElements += numInstances;
572 return instanceIndex;
578 if (m_hasBatchInstances)
580 m_storage->commitBatch(m_numElements);
581 m_hasBatchInstances =
false;
597 return m_storage->getData();
602 template <
typename T>
605 agxAssert(dynamic_cast<T *>(this->getData()));
606 return *
static_cast<T *
>(this->getData());
609 template <
typename T>
616 return (
agx::Index)m_storage->idToIndex(m_id);
620 template <
typename T>
624 agxAssertN(m_storage,
"Can not access attribute \'%s\' from an invalid pointer.", attribute->
fullName().c_str());
625 Buffer *buffer = m_storage->getBuffer(attribute);
627 agxAssertN(index < m_storage->size(),
"%s: Entity (%p, %u) claims to have index %u, but storage size is %u.", m_storage->getPath().c_str(), (
void *)m_storage, (
unsigned)m_id, (unsigned)index, (
unsigned)m_storage->size());
628 return *(T *)buffer->getElement(index);
635 agxAssertN(index < m_storage->size(),
"%s: Entity (%p, %u) claims to have index %u, but storage size is %u.", m_storage->getPath().c_str(), (
void *)m_storage, (
unsigned)m_id, (unsigned)index, (
unsigned)m_storage->size());
640 template <
typename T>
643 return this->getElement<T>(attribute);
646 template <
typename T>
649 return this->getElement<const T>(attribute);
652 template <
typename T>
655 return this->getElement<T>(attribute);
658 template <
typename T>
661 return this->getElement<const T>(attribute);
665 template <
typename T>
671 template <
typename T>
679 template <
typename T>
685 template <
typename T>
691 template <
typename T>
697 template <
typename T>
703 template <
typename T>
707 Buffer *buffer = this->getBuffer(attribute);
710 size_t arraySize = buffer->getElementArraySize();
715 template <
typename T>
718 return const_cast<EntityStorage *
>(
this)->dereferenceMultipliedAttribute(entity, attribute);
723 template <
typename VectorT>
724 void EntityStorage::destroyInstances(
const VectorT& instances)
726 this->destroyInstances(instances.begin(), instances.size());
732 return this->getPermutationBuffer(attribute->
getId());
737 return m_permutationBuffers[index];
742 template <
typename T>
747 return const_cast<T&
>(value->
get<T>());
750 template <
typename T>
753 return const_cast<EntityPtr *
>(
this)->
operator()(attribute);
759 return m_storage ? m_storage->getEntityModel() :
nullptr;
764 return m_storage ? m_storage->getEntityModel() :
nullptr;
772 m_storage->swapInstanceIds(m_id, other.m_id);
780 m_storage->swapInstances(calculateIndex(), other.
calculateIndex());
786 return m_storage && m_storage->getEntityModel()->is(model);
811 m_data =
const_cast<EntityData *
>(other.
getData());
832 return m ? m->
is(model) :
false;
841 agxAssertN(index < storage->size(),
"%s: Entity instance (%p, %u) is out of bounds, storage size is %u.", storage->
getPath().
c_str(), (
void *)storage, (
unsigned)index, (unsigned)storage->
size());
868 template <
typename T>
873 template <
typename T>
878 template <
typename T>
882 return m_entityPtr.getElement<T>(m_attribute);
885 template <
typename T>
889 return m_entityPtr.getElement<T>(m_attribute);
892 template <
typename T>
895 return m_entityPtr.
isValid() && m_attribute;
899 template <
typename T>
902 return !this->isValid();
905 template <
typename T>
908 return this->isValid();
916 # pragma warning(pop) agxData::EntityStorage * getStorage()
Alias for getData()->getStorage()
Representation of a path, a list of name components.
AGXTERRAIN_EXPORT void clear()
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
agxData::EntityData * getData()
bool is(const agx::Model *other) const
Inheritance with partial specialization due to bug with ref_ptr containers.
agxData::LocalVector< std::pair< size_t, size_t > > InstanceSwapLocalVector
static const agx::Name IdToIndexName
size_t indexToId(size_t index) const
Convert between instance id and data index.
Data storage for a collection of entity instances of a specified EntityModel.
A component is an object containing other objects, enabling hierarchical structuring.
A model is an abstract representation of the class of an agx::Object.
agx::Index getIndex() const
Abstract representation of a value.
agxData::EntityModel * getEntityModel()
#define agxAssertN(expr, format,...)
AGXCORE_EXPORT Model * getModel(const Path &path, const Path &_namespace=Path())
Entity instance provides access to a single instance in an EntityStorage.
agx::String fullName() const
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
#define AGX_DECLARE_POINTER_TYPES(type)
T align_ceil(T value, T alignment)
Representation of a name string.
Type-specific Array used for fast access into the data held by a Buffer.
EntityPtr operator[](size_t index)
const char * c_str() const
Vector containing 'raw' data.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agxData::EntityModel * getModel()
Alias for getData()->getStorage()->getModel()
IndexRangeT< agx::UInt > IndexRange
An abstract attribute description, part of an Entity.
bool is() const
Subclass test.
Abstract representation of a data buffer.
void verifyIndex() const
Check for broken ptr, by verifying that the index is active in the storage.
Contains classes for low level data storage for AGX.
T & getElement(size_t index)
std::ostream & operator<<(std::ostream &os, const agx::AddedMassInteraction::Matrix6x6 &m)
agx::VectorPOD< std::pair< size_t, size_t > > InstanceSwapVector
const agx::Name & getName() const
Callback1< T1 > CallbackType
EntityInstance()
Constructors.
agx::HashTable< Attribute *, BufferRef > BufferTable
An abstract description of a data entity stored using SOA (structure of arrays) pattern in a EntitySt...
agx::Index calculateId() const
bool isInstanceOf(agxData::EntityModel *model) const
AGXTERRAIN_EXPORT TimingStorage & getStorage()
EntityPtr at(size_t index)
Class for writing serialized data in binary format to a stream.
#define agxAssert1(expr, msg)
agxData::ValueRefT< agx::UInt > capacityParameter
#define AGX_DECLARE_VECTOR_TYPES(type)
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
Inheritance with partial specialization due to bug with ref_ptr containers.
agxData::EntityStorage * getStorage() const
An agx::Device is an abstract representation of a device on which data can be stored and processed...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
agx::Index calculateIndex() const
Calculate the index using the indirect id.
agx::UInt32 getId() const
agx::Object is a refcounted object with a name.
agx::Path getPath() const
agxData::ValueRefT< agx::UInt > sizeParameter
static const agx::Name IndexToIdName