31 # pragma warning(push) 32 # pragma warning(disable: 6011) // Disable warningC6011: dereferencing nullptr pointer 39 class GlobalResultBuffer;
61 virtual void configure(agx::TiXmlElement *eBuffer)
override;
62 virtual void snapshot(agx::TiXmlNode *eParent,
const agx::String& directory)
const override;
73 void addListener(EventListener *listener);
74 void removeListener(EventListener *listener);
75 bool hasListener(EventListener *listener);
105 template <
typename T>
108 template <
typename T>
123 size_t capacity()
const;
133 void resize(
size_t size,
bool initializeElements =
true);
134 void presize(
size_t size,
size_t initialSize);
144 void reserve(
size_t size);
155 const void* ptr()
const;
157 template <
typename T>
160 template <
typename T>
161 const T *ptr()
const;
171 template <
typename T>
172 T& getElement(
size_t index);
174 template <
typename T>
175 const T& getElement(
size_t index)
const;
187 void *getElement(
size_t index);
188 const void *getElement(
size_t index)
const;
190 void *kernelOverflowReallocation(
size_t size);
191 void deleteOverflowBuffer(
void *buffer,
size_t numElements);
193 void *allocateBackBuffer();
194 void swapBackBuffer(
void *backBuffer);
199 size_t getElementArraySize()
const;
218 static void copy(
Buffer *target,
size_t targetOffset,
const Buffer *source,
size_t sourceOffset,
size_t numElements);
229 void print(std::ostream& stream)
const;
254 Buffer *getGlobalOrderBuffer();
255 const Buffer *getGlobalOrderBuffer()
const;
257 Buffer *getOrCreateGlobalOrderBuffer();
263 Buffer *getElementBuffer();
264 const Buffer *getElementBuffer()
const;
269 void setElementBuffer(
Buffer *buffer);
286 void setElementInitializer(
const RangeCallback& callback);
287 void setElementDestructor(
const RangeCallback& callback);
289 Buffer *getOriginalBuffer();
290 const Buffer *getOriginalBuffer()
const;
295 virtual void buildNavigationTree(agxJson::Value& eNode)
const override;
306 virtual void reallocate(
size_t size);
313 void signalReallocation();
318 void keyFrameReserve(
size_t capacity);
333 void setOriginalBuffer(
Buffer *buffer);
364 template <
typename T>
375 void setBuffer(
Buffer *buffer);
383 void *allocateBytes(
size_t numBytes);
384 void deallocateBytes(
void *buffer,
size_t numBytes);
395 template <
typename T>
399 template <
typename T2>
413 void push_back(
const T& value);
418 template <
typename T2>
419 bool contains(
const T2& value)
const;
421 template <
typename T2>
422 size_t find(
const T2& value)
const;
424 T& operator[] (
size_t index);
425 const T& operator[] (
size_t index)
const;
428 const T& at(
size_t index)
const;
431 const T& front()
const;
434 const T& back()
const;
438 const_iterator
begin()
const;
441 const_iterator
end()
const;
466 AGX_FORCE_INLINE size_t Buffer::getElementArraySize()
const {
return m_elementArraySize.get() ? m_elementArraySize->get() : 1; }
482 template <
typename T>
485 agxAssertN(m_format->is(agxData::getFormat<T>()) && m_format->getSize() == agxData::getFormat<T>()->getSize(),
"Type mismatch! Buffer has type %s, requested array of type %s", m_format->fullName().c_str(), agxData::getFormat<T>()->fullName().c_str());
489 template <
typename T>
492 return const_cast<Buffer *
>(
this)->getArray<T>();
502 template <
typename T>
506 return static_cast<T *
>(m_ptr);
509 template <
typename T>
512 return const_cast<Buffer *
>(
this)->ptr<T>();
516 template <
typename T>
528 template <
typename T>
531 return const_cast<Buffer *
>(
this)->getElement<T>(index);
544 return const_cast<Buffer *
>(
this)->getElement(index);
563 template <
typename T>
568 return m_buffer->getGlobalResult();
571 template <
typename T>
577 template <
typename T>
580 if (numElements == 0)
583 return this->getGlobalResult()->commit(*
this, numElements, localResult, sortIndex);
586 template <
typename T>
589 if (numElements == 0)
592 return this->getGlobalResult()->commit(*
this, numElements, localResult);
595 template <
typename T>
template <
typename T2>
601 return this->getGlobalResult()->commit(*
this, vector, sortIndex);
605 template <
typename T>
template <
typename T2>
611 return this->getGlobalResult()->commit(*
this, vector);
619 template <
typename T>
622 template <
typename T>
632 if (buffer !=
nullptr)
644 this->
init(buffer, range);
732 template <
typename T>
743 template <
typename T>
748 result.
m_ptr = (T *)buffer;
754 template <
typename T>
759 template <
typename T>
762 #ifndef AGX_ENTITY_WRAPPER 768 template <
typename T>
771 #ifndef AGX_ENTITY_WRAPPER 776 template <
typename T>
781 template <
typename T>
784 this->m_ptr = vec.
ptr();
788 template <
typename T>
792 this->m_ptr = vec.
ptr();
793 this->m_range = range;
796 template <
typename T>
799 this->m_ptr = vec.
ptr();
803 template <
typename T>
807 this->m_ptr = vec.
ptr();
808 this->m_range = range;
811 template <
typename T>
815 agxAssert1(!m_range.empty(),
"Can not take back element of an empty array!");
816 return ((T*)m_ptr)[m_range.size()-1];
819 template <
typename T>
823 agxAssert1(!m_range.empty(),
"Can not take back element of an empty array!");
824 return ((T*)m_ptr)[m_range.size()-1];
827 template <
typename T>
831 agxAssert1(!m_range.empty(),
"Can not take front element of an empty array!");
832 return ((T*)m_ptr)[0];
835 template <
typename T>
839 agxAssert1(!m_range.empty(),
"Can not take front element of an empty array!");
840 return ((T*)m_ptr)[0];
844 template <
typename T>
847 agxAssert1(m_ptr,
"Array does not have an active buffer!");
848 agxAssertN(index < m_range.size(),
"Array index %llu is out of bounds, size is %llu", (
long long unsigned)index, (
long long unsigned)m_range.size());
849 return ((T*)m_ptr)[index];
853 template <
typename T>
856 return const_cast<Array<T>*
>(
this)->
operator[](index);
859 template <
typename T>
863 agxVerifyN(index < m_range.size(),
"Array index %llu is out of bounds, size is %llu", (
long long unsigned)index, (
long long unsigned)m_range.size());
864 return ((T*)m_ptr)[index];
867 template <
typename T>
870 return const_cast<Array<T>*
>(
this)->at(index);
874 template <
typename T>
881 template <
typename T>
884 return this->slice(subRange);
887 template <
typename T>
890 template <
typename T>
893 template <
typename T>
896 template <
typename T>
899 template <
typename T>
903 template <
typename T>
907 template <
typename T>
template <
typename T2>
910 for (
size_t i = 0, numElements = size(); i < numElements; ++i)
912 if ((*
this)[i] == element)
919 template <
typename T>
template <
typename T2>
926 template <
typename T>
927 std::ostream& operator << ( std::ostream& output, const Array<T>& array)
929 for (
size_t i = 0; i < array.size(); i++)
933 if (i < array.size()-1)
944 template <
typename T>
template <
typename T2>
947 const Buffer *buffer =
dynamic_cast<const Buffer *
>(object);
948 return buffer ? buffer->
getFormat() == agxData::getFormat<T>() :
false;
951 template <
typename T>
956 template <
typename T>
961 template <
typename T>
967 template <
typename T>
974 template <
typename T>
977 return const_cast<BufferT<T> *
>(
this)->array();
982 template <
typename T>
989 array().range().end()++;
990 ::new((
void *)&array().
back()) T(value);
993 template <
typename T>
999 array().range().end()--;
1003 template <
typename T>
1006 for (
size_t i = 0; i <
m_size; ++i)
1010 array().range().end() = 0;
1013 template <
typename T>
template <
typename T2>
1016 return array().contains(value);
1019 template <
typename T>
template <
typename T2>
1022 return array().find(value);
1025 template <
typename T>
1028 return array()[index];
1031 template <
typename T>
1034 return const_cast<BufferT<T> *
>(
this)->
operator[](index);
1037 template <
typename T>
1040 return array().at(index);
1043 template <
typename T>
1049 template <
typename T>
1052 return array().front();
1055 template <
typename T>
1061 template <
typename T>
1064 return array().back();
1067 template <
typename T>
1075 template <
typename T>
1078 return array().begin();
1081 template <
typename T>
1084 return array().begin();
1087 template <
typename T>
1090 return array().end();
1093 template <
typename T>
1096 return array().end();
1099 template <
typename T>
1105 template <
typename T>
1111 template <
typename T>
1117 template <
typename T>
1123 template <
typename T>
1135 # pragma warning(pop) agxData::ValueRefT< agx::UInt > capacityParameter
EntityStorage * m_storage
AGXTERRAIN_EXPORT void clear()
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
AGXCORE_EXPORT Type * getType(const agx::String &name)
T & operator[](size_t index)
EventDispatch m_eventDispatch
bool is(const agx::Model *other) const
The Container is the base class for several of the container classes proided by AGX, such as agx::Vector and agx::HashSet.
VectorPOD< Index > IndexVector
agxData::BufferRef m_elementBuffer
static agx::UInt MIN_BUFFER_CAPACITY
RangeCallback m_initializer
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
bool contains(const T2 &value) const
#define agxVerifyN(expr, format,...)
agx::IndexRange32 m_range
static agxData::Array< T > raw(T *buffer, agx::Index size)
Array creation helper method that creates an array covering the given memory area.
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.
Abstract representation of a value.
AGXCORE_EXPORT Format * getFormat(const agx::String &typeFormatName)
#define agxAssertN(expr, format,...)
Array()
Create a new invalid array.
Transactions are used to reserve exclusive memory areas in which the threads can write their data...
AbstractArray()
Create a new invalid array.
void reserve(size_t size)
Reserve space for future buffer expansion.
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
#define AGX_DECLARE_POINTER_TYPES(type)
Representation of a name string.
Arrays are fast accessors into the data, or a portion of it, held by a Buffer.
static agx::UInt ALIGNMENT
void setRange(size_t startIndex, size_t endIndex)
Set the range of the buffer that the array will cover.
agx::IndexRange32 & range()
Type-specific Array used for fast access into the data held by a Buffer.
Base class providing referencing counted objects.
agxData::Buffer * m_buffer
void _setBuffer(agxData::Buffer *buffer)
Set the buffer while maintaining the current range, should normally not be used.
agx::ByteAllocator m_allocator
GlobalResult is used by kernels to generate result data from different threads.
agx::GlobalResultBuffer * m_globalResult
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::GlobalResult::Transaction allocateResult(size_t numElements)
static agx::Real CAPACITY_MULTIPLIER
void * ptr()
Get access to the raw data buffer.
agxData::Value::Event::CallbackType m_resizeCallback
void init()
Set to empty array.
An abstract attribute description, part of an Entity.
Abstract representation of a data buffer.
Contains classes for low level data storage for AGX.
agxData::ValueRefT< agx::UInt > sizeParameter
agxData::Value::Event::CallbackType m_reserveCallback
void push_back(const T &value)
void sync()
Updates the internal data access pointer. Called when the back end buffer is reallocated.
agxData::ShareHandleRef m_shareHandle
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
agx::Event1< Buffer * > Event
Callback1< T1 > CallbackType
Event reallocationEvent
Triggered when buffer is reallocated.
const agxData::Buffer * buffer() const
agxData::Array< T > & getArray()
Convenience method to get an direct data array.
size_t find(const T2 &value) const
agxData::Format * getFormat()
AGXTERRAIN_EXPORT TimingStorage & getStorage()
#define agxAssert1(expr, msg)
agxData::BufferRef m_globalOrderBuffer
T * ptr()
Get access to the internal data buffer.
agx::Callback2< Buffer *, const agx::IndexRange & > RangeCallback
Specify a custom element initializer callback.
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
#define AGX_DECLARE_VECTOR_TYPES(type)
bool AGXCORE_EXPORT isShutdown()
IndexRangeT< agx::UInt32 > IndexRange32
agxData::Buffer * m_originalBuffer
An agx::Device is an abstract representation of a device on which data can be stored and processed...
agxData::ValueRef m_defaultElementValue
RangeCallback m_destructor
agxData::Format * getFormat()
T * ptr()
Get access to the internal data buffer.
agx::Container * m_sharedContainer