8 #ifndef __SIM_ObjectReader_h__
9 #define __SIM_ObjectReader_h__
40 virtual const GU_Detail *getSimGdp()
const = 0;
81 static bool isPackedObject(
const SIM_Object *obj);
97 bool isPivotValid()
const;
98 bool isPositionValid()
const;
99 bool isOrientationValid()
const;
100 bool isVelocityValid()
const;
101 bool isAngularVelocityValid()
const;
102 bool isNameValid()
const;
134 void setAngularVelocity(
const UT_Vector3 &avel);
135 void setName(
const char *
name);
159 template <
typename ARRAY_T>
163 bool isValid()
const {
return myAttrib.isValid(); }
175 template <
typename ARRAY_T>
182 bool isValid()
const {
return myAttrib.isValid(); }
211 bool hasPositionData()
const;
224 bool unpackBoundShapes(
GU_Detail &gdp,
bool apply_joint_xform =
true)
const;
234 template <
typename T,
typename ARRAY_HANDLE_T>
236 getArrayAttribElement(
const ARRAY_HANDLE_T &handle,
238 bool required =
true);
242 template <
typename T,
typename ARRAY_T>
244 setArrayAttribElement(BatchRWHandleA<ARRAY_T> &handle,
248 template <
typename T>
249 static constexpr
bool isScalar()
255 template <
typename T>
256 static int getTupleSize()
258 if constexpr (isScalar<T>())
261 return
T::tuple_size;
264 template <typename ATTRIB_T, typename
T>
267 if constexpr (isScalar<T>())
270 std::copy(src, src +
T::tuple_size, dest.
data());
273 template <typename
T, typename ATTRIB_T>
274 static
void setValue(const T &src, ATTRIB_T *dest)
276 if constexpr (isScalar<T>())
279 std::copy(src.data(), src.data() + T::tuple_size, dest);
289 BatchROHandleA<UT_Fpreal32Array> myPivot;
290 BatchROHandleA<UT_Fpreal32Array> myOrientation;
291 BatchROHandleA<UT_Fpreal32Array> myPosition;
292 BatchROHandleA<UT_Fpreal32Array> myScale;
295 template <
typename ARRAY_T>
300 myTupleSize(myAttrib.isValid() ? myAttrib->getTupleSize() : -1)
304 template <
typename ARRAY_T>
309 myTupleSize(myAttrib.isValid() ? myAttrib->getTupleSize() : -1)
313 template <
typename ARRAY_T>
319 myAttrib.set(myCacheOffset, myVals);
324 template <
typename ARRAY_T>
331 myAttrib.bind(gdp, owner, name, minsize);
332 myTupleSize = myAttrib.isValid() ? myAttrib->getTupleSize() : -1;
335 template <
typename T,
typename ARRAY_HANDLE_T>
339 exint i, T &elem,
bool required)
341 UT_ASSERT(handle.isValid() || !required);
342 if (!handle.isValid())
345 const int tuple_size = handle.myTupleSize;
346 if (handle.myTupleSize != getTupleSize<T>())
353 if (handle.myCacheOffset != offset)
357 handle.myAttrib.get(offset, handle.myVals);
358 handle.myCacheOffset =
offset;
361 if ((i + 1) * tuple_size > handle.myVals.entries())
364 getValue(handle.myVals.array() + i * tuple_size, elem);
369 template <
typename T,
typename ARRAY_T>
376 if (tuple_size != getTupleSize<T>())
390 handle.
myVals.setSize(n * tuple_size);
393 setValue(elem, handle.
myVals.array() + i * tuple_size);
Definition of a geometry attribute.
const GU_Agent * getAgent() const
virtual void getPositionTransform(UT_Matrix4D &xform, bool scale=true) const =0
virtual UT_Quaternion getOrientation() const =0
virtual UT_Vector3 getCentroid() const =0
exint getTransformId() const
const SIM_Object & getObject() const
Return the SIM_Object.
SYS_FORCE_INLINE GA_Offset getPointOffset() const
GA_Offset getPointOffset() const
GA_RWHandleT< ARRAY_T > myAttrib
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
GA_ROHandleT< ARRAY_T > myAttrib
#define GA_INVALID_OFFSET
BatchROHandleA(const GA_Attribute *attrib=nullptr)
__hostdev__ float getValue(uint32_t i) const
static void setArrayAttribElement(BatchRWHandleA< ARRAY_T > &handle, GA_Offset offset, exint i, exint n, const T &elem)
#define UT_ASSERT_MSG(ZZ,...)
GA_API const UT_StringHolder scale
const GU_PrimPacked * getPrimitive() const
virtual const GU_Detail * getSimGdp() const =0
Return the SIM_Object's geometry.
PXL_API const char * getName(const ColorSpace *space)
Return the name of the color space.
SYS_FORCE_INLINE T get(GA_Offset off, int comp=0) const
GLuint const GLchar * name
virtual ~SIM_BaseObjectReader()
const SIM_Object & myObject
GA_API const UT_StringHolder orient
const GEO_Primitive * getPrimitive() const
Returns the primitive associated with the current point offset.
SYS_FORCE_INLINE GA_Offset getPointOffset() const
BatchRWHandleA(GA_Attribute *attrib=nullptr)
Vec3< typename MatType::value_type > getScale(const MatType &mat)
Return a Vec3 representing the lengths of the passed matrix's upper 3×3's rows.
GA_API const UT_StringHolder pivot
void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1)
virtual GU_ConstDetailHandle getObjectGdp() const =0
Container class for all geometry.
static bool getArrayAttribElement(const ARRAY_HANDLE_T &handle, GA_Offset offset, exint i, T &elem, bool required=true)