2PL_ALWAYS_INLINE plGameObject::ConstChildIterator::ConstChildIterator(
plGameObject* pObject,
const plWorld* pWorld)
8PL_ALWAYS_INLINE
const plGameObject& plGameObject::ConstChildIterator::operator*()
const
13PL_ALWAYS_INLINE
const plGameObject* plGameObject::ConstChildIterator::operator->()
const
18PL_ALWAYS_INLINE plGameObject::ConstChildIterator::operator
const plGameObject*()
const
25 return m_pObject !=
nullptr;
35PL_ALWAYS_INLINE plGameObject::ChildIterator::ChildIterator(
plGameObject* pObject,
const plWorld* pWorld)
40PL_ALWAYS_INLINE
plGameObject& plGameObject::ChildIterator::operator*()
45PL_ALWAYS_INLINE
plGameObject* plGameObject::ChildIterator::operator->()
50PL_ALWAYS_INLINE plGameObject::ChildIterator::operator
plGameObject*()
57inline plGameObject::plGameObject() =
default;
59PL_ALWAYS_INLINE plGameObject::plGameObject(
const plGameObject& other)
106PL_ALWAYS_INLINE
plStringView plGameObject::GetName()
const
111PL_ALWAYS_INLINE
void plGameObject::SetNameInternal(
const char* szName)
116PL_ALWAYS_INLINE
const char* plGameObject::GetNameInternal()
const
121PL_ALWAYS_INLINE
void plGameObject::SetGlobalKeyInternal(
const char* szName)
128 return m_sName == sName;
136PL_ALWAYS_INLINE
void plGameObject::DisableChildChangesNotifications()
146PL_ALWAYS_INLINE
void plGameObject::DisableParentChangesNotifications()
153 for (plUInt32 i = 0; i < children.
GetCount(); ++i)
161 for (plUInt32 i = 0; i < children.
GetCount(); ++i)
169 return m_uiChildCount;
178PL_ALWAYS_INLINE
plVec3 plGameObject::GetLocalPosition()
const
180 return plSimdConversion::ToVec3(m_pTransformationData->m_localPosition);
184PL_ALWAYS_INLINE
void plGameObject::SetLocalRotation(
plQuat qRotation)
186 SetLocalRotation(plSimdConversion::ToQuat(qRotation));
189PL_ALWAYS_INLINE
plQuat plGameObject::GetLocalRotation()
const
191 return plSimdConversion::ToQuat(m_pTransformationData->m_localRotation);
195PL_ALWAYS_INLINE
void plGameObject::SetLocalScaling(
plVec3 vScaling)
197 SetLocalScaling(plSimdConversion::ToVec3(vScaling));
200PL_ALWAYS_INLINE
plVec3 plGameObject::GetLocalScaling()
const
202 return plSimdConversion::ToVec3(m_pTransformationData->m_localScaling);
206PL_ALWAYS_INLINE
void plGameObject::SetLocalUniformScaling(
float fScaling)
211PL_ALWAYS_INLINE
float plGameObject::GetLocalUniformScaling()
const
213 return m_pTransformationData->m_localScaling.w();
216PL_ALWAYS_INLINE
plTransform plGameObject::GetLocalTransform()
const
218 return plSimdConversion::ToTransform(GetLocalTransformSimd());
222PL_ALWAYS_INLINE
void plGameObject::SetGlobalPosition(
const plVec3& vPosition)
224 SetGlobalPosition(plSimdConversion::ToVec3(vPosition));
227PL_ALWAYS_INLINE
plVec3 plGameObject::GetGlobalPosition()
const
229 return plSimdConversion::ToVec3(m_pTransformationData->m_globalTransform.m_Position);
233PL_ALWAYS_INLINE
void plGameObject::SetGlobalRotation(
const plQuat& qRotation)
235 SetGlobalRotation(plSimdConversion::ToQuat(qRotation));
238PL_ALWAYS_INLINE
plQuat plGameObject::GetGlobalRotation()
const
240 return plSimdConversion::ToQuat(m_pTransformationData->m_globalTransform.m_Rotation);
244PL_ALWAYS_INLINE
void plGameObject::SetGlobalScaling(
const plVec3& vScaling)
246 SetGlobalScaling(plSimdConversion::ToVec3(vScaling));
249PL_ALWAYS_INLINE
plVec3 plGameObject::GetGlobalScaling()
const
251 return plSimdConversion::ToVec3(m_pTransformationData->m_globalTransform.m_Scale);
255PL_ALWAYS_INLINE
void plGameObject::SetGlobalTransform(
const plTransform& transform)
257#if PL_ENABLED(PL_GAMEOBJECT_VELOCITY)
258 m_pTransformationData->m_lastGlobalTransform = m_pTransformationData->m_globalTransform;
261 SetGlobalTransform(plSimdConversion::ToTransform(transform));
264PL_ALWAYS_INLINE
plTransform plGameObject::GetGlobalTransform()
const
266 return plSimdConversion::ToTransform(m_pTransformationData->m_globalTransform);
271 #if PL_ENABLED(PL_GAMEOBJECT_VELOCITY)
272 return plSimdConversion::ToTransform(m_pTransformationData->m_lastGlobalTransform);
274 return plSimdConversion::ToTransform(m_pTransformationData->m_globalTransform);
281 m_pTransformationData->m_localPosition = vPosition;
285 UpdateGlobalTransformAndBoundsRecursive();
289PL_ALWAYS_INLINE
const plSimdVec4f& plGameObject::GetLocalPositionSimd()
const
291 return m_pTransformationData->m_localPosition;
297 m_pTransformationData->m_localRotation = qRotation;
301 UpdateGlobalTransformAndBoundsRecursive();
305PL_ALWAYS_INLINE
const plSimdQuat& plGameObject::GetLocalRotationSimd()
const
307 return m_pTransformationData->m_localRotation;
313 plSimdFloat uniformScale = m_pTransformationData->m_localScaling.w();
314 m_pTransformationData->m_localScaling = vScaling;
315 m_pTransformationData->m_localScaling.SetW(uniformScale);
319 UpdateGlobalTransformAndBoundsRecursive();
323PL_ALWAYS_INLINE
const plSimdVec4f& plGameObject::GetLocalScalingSimd()
const
325 return m_pTransformationData->m_localScaling;
331 m_pTransformationData->m_localScaling.SetW(fScaling);
335 UpdateGlobalTransformAndBoundsRecursive();
339PL_ALWAYS_INLINE
plSimdFloat plGameObject::GetLocalUniformScalingSimd()
const
341 return m_pTransformationData->m_localScaling.w();
344PL_ALWAYS_INLINE
plSimdTransform plGameObject::GetLocalTransformSimd()
const
346 const plSimdVec4f vScale = m_pTransformationData->m_localScaling * m_pTransformationData->m_localScaling.w();
347 return plSimdTransform(m_pTransformationData->m_localPosition, m_pTransformationData->m_localRotation, vScale);
351PL_ALWAYS_INLINE
void plGameObject::SetGlobalPosition(
const plSimdVec4f& vPosition)
353 UpdateLastGlobalTransform();
355 m_pTransformationData->m_globalTransform.m_Position = vPosition;
357 m_pTransformationData->UpdateLocalTransform();
361 UpdateGlobalTransformAndBoundsRecursive();
365PL_ALWAYS_INLINE
const plSimdVec4f& plGameObject::GetGlobalPositionSimd()
const
367 return m_pTransformationData->m_globalTransform.m_Position;
371PL_ALWAYS_INLINE
void plGameObject::SetGlobalRotation(
const plSimdQuat& qRotation)
373 UpdateLastGlobalTransform();
375 m_pTransformationData->m_globalTransform.m_Rotation = qRotation;
377 m_pTransformationData->UpdateLocalTransform();
381 UpdateGlobalTransformAndBoundsRecursive();
385PL_ALWAYS_INLINE
const plSimdQuat& plGameObject::GetGlobalRotationSimd()
const
387 return m_pTransformationData->m_globalTransform.m_Rotation;
391PL_ALWAYS_INLINE
void plGameObject::SetGlobalScaling(
const plSimdVec4f& vScaling)
393 UpdateLastGlobalTransform();
395 m_pTransformationData->m_globalTransform.m_Scale = vScaling;
397 m_pTransformationData->UpdateLocalTransform();
401 UpdateGlobalTransformAndBoundsRecursive();
405PL_ALWAYS_INLINE
const plSimdVec4f& plGameObject::GetGlobalScalingSimd()
const
407 return m_pTransformationData->m_globalTransform.m_Scale;
411PL_ALWAYS_INLINE
void plGameObject::SetGlobalTransform(
const plSimdTransform& transform)
413 UpdateLastGlobalTransform();
415 m_pTransformationData->m_globalTransform = transform;
420 m_pTransformationData->m_globalTransform.m_Scale.SetW(1.0f);
421 m_pTransformationData->UpdateLocalTransform();
425 UpdateGlobalTransformAndBoundsRecursive();
429PL_ALWAYS_INLINE
const plSimdTransform& plGameObject::GetGlobalTransformSimd()
const
431 return m_pTransformationData->m_globalTransform;
434PL_ALWAYS_INLINE
const plSimdTransform& plGameObject::GetLastGlobalTransformSimd()
const
436#if PL_ENABLED(PL_GAMEOBJECT_VELOCITY)
437 return m_pTransformationData->m_lastGlobalTransform;
439 return m_pTransformationData->m_globalTransform;
448PL_ALWAYS_INLINE
void plGameObject::DisableStaticTransformChangesNotifications()
455 return plSimdConversion::ToBBoxSphere(m_pTransformationData->m_localBounds);
460 return plSimdConversion::ToBBoxSphere(m_pTransformationData->m_globalBounds);
463PL_ALWAYS_INLINE
const plSimdBBoxSphere& plGameObject::GetLocalBoundsSimd()
const
465 return m_pTransformationData->m_localBounds;
468PL_ALWAYS_INLINE
const plSimdBBoxSphere& plGameObject::GetGlobalBoundsSimd()
const
470 return m_pTransformationData->m_globalBounds;
475 return m_pTransformationData->m_hSpatialData;
483PL_ALWAYS_INLINE
void plGameObject::DisableComponentChangesNotifications()
503 out_components.
Clear();
505 for (plUInt32 i = 0; i < m_Components.
GetCount(); ++i)
510 out_components.
PushBack(
static_cast<T*
>(pComponent));
518 out_components.
Clear();
520 for (plUInt32 i = 0; i < m_Components.
GetCount(); ++i)
525 out_components.
PushBack(
static_cast<const T*
>(pComponent));
542 return m_Components.GetUserData<ComponentUserData>().m_uiVersion;
547 return SendMessageInternal(ref_msg,
false);
552 return SendMessageInternal(ref_msg,
false);
557 return SendMessageRecursiveInternal(ref_msg,
false);
562 return SendMessageRecursiveInternal(ref_msg,
false);
572 return m_pTransformationData->m_uiStableRandomSeed;
577 m_pTransformationData->m_uiStableRandomSeed = uiSeed;
582PL_ALWAYS_INLINE
void plGameObject::TransformationData::UpdateGlobalTransformWithoutParent(plUInt32 uiUpdateCounter)
584 UpdateLastGlobalTransform(uiUpdateCounter);
586 m_globalTransform.m_Position = m_localPosition;
587 m_globalTransform.m_Rotation = m_localRotation;
588 m_globalTransform.m_Scale = m_localScaling * m_localScaling.w();
591PL_ALWAYS_INLINE
void plGameObject::TransformationData::UpdateGlobalTransformWithParent(plUInt32 uiUpdateCounter)
593 UpdateLastGlobalTransform(uiUpdateCounter);
595 const plSimdVec4f vScale = m_localScaling * m_localScaling.w();
596 const plSimdTransform localTransform(m_localPosition, m_localRotation, vScale);
600PL_FORCE_INLINE
void plGameObject::TransformationData::UpdateGlobalBounds()
602 m_globalBounds = m_localBounds;
603 m_globalBounds.Transform(m_globalTransform);
606PL_ALWAYS_INLINE
void plGameObject::TransformationData::UpdateLastGlobalTransform(plUInt32 uiUpdateCounter)
608#if PL_ENABLED(PL_GAMEOBJECT_VELOCITY)
609 if (m_uiLastGlobalTransformUpdateCounter != uiUpdateCounter)
611 m_lastGlobalTransform = m_globalTransform;
612 m_uiLastGlobalTransformUpdateCounter = uiUpdateCounter;
void PushBack(const T &value)
Pushes value at the end of the array.
Definition ArrayBase_inl.h:333
void Clear()
Clears the array.
Definition ArrayBase_inl.h:184
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
PL_ALWAYS_INLINE plUInt32 GetCount() const
Returns the number of elements in the array.
Definition ArrayPtr.h:142
Base class of all component types.
Definition Component.h:25
Definition DynamicArray.h:81
Iterates over all children of one object.
Definition GameObject.h:56
void operator++()
Shorthand for 'Next'.
Definition GameObject_inl.h:28
bool IsValid() const
Checks whether this iterator points to a valid object.
Definition GameObject_inl.h:23
This class represents an object inside the world.
Definition GameObject.h:32
plUInt16 GetComponentVersion() const
Returns the current version of components attached to this object. This version is increased whenever...
Definition GameObject_inl.h:540
void EnableComponentChangesNotifications()
Enables or disabled notification message 'plMsgComponentsChanged' when components are added or remove...
Definition GameObject_inl.h:478
void EnableParentChangesNotifications()
Enables or disabled notification message 'plMsgParentChanged' when the parent changes....
Definition GameObject_inl.h:141
bool TryGetComponentOfBaseType(T *&out_pComponent)
Tries to find a component of the given base type in the objects components list and returns the first...
bool SendMessage(plMessage &ref_msg)
Sends a message to all components of this object.
Definition GameObject_inl.h:545
plGameObjectHandle GetHandle() const
Returns a handle to this object.
Definition GameObject_inl.h:64
plArrayPtr< plComponent *const > GetComponents()
Returns a list of all components attached to this object.
Definition GameObject_inl.h:530
UpdateBehaviorIfStatic
Defines update behavior for global transforms when changing the local transform on a static game obje...
Definition GameObject.h:230
@ UpdateImmediately
Updates the hierarchy underneath the object immediately.
plUInt32 GetStableRandomSeed() const
Returns a random value that is chosen once during object creation and remains stable even throughout ...
Definition GameObject_inl.h:570
void EnableStaticTransformChangesNotifications()
Enables or disabled notification message 'plMsgTransformChanged' when this object is static and its t...
Definition GameObject_inl.h:443
bool IsDynamic() const
Returns whether this object is dynamic.
Definition GameObject_inl.h:69
void SetStableRandomSeed(plUInt32 uiSeed)
Overwrites the object's random seed value.
Definition GameObject_inl.h:575
void EnableChildChangesNotifications()
Enables or disabled notification message 'plMsgChildrenChanged' when children are added or removed....
Definition GameObject_inl.h:131
plSpatialDataHandle GetSpatialData() const
Returns a handle to the internal spatial data.
Definition GameObject_inl.h:473
bool GetActiveFlag() const
Checks whether the 'active flag' is set on this game object. Note that this does not mean that the ga...
Definition GameObject_inl.h:79
plTransform GetLastGlobalTransform() const
Last frame's global transform (only valid if PL_GAMEOBJECT_VELOCITY is set, otherwise the same as Get...
Definition GameObject_inl.h:269
bool IsActive() const
Checks whether this game object is in an active state.
Definition GameObject_inl.h:84
void SetGlobalKey(plStringView sGlobalKey)
Sets the global key to identify this object. Global keys must be unique within a world.
Definition GameObject_inl.h:99
void TryGetComponentsOfBaseType(plDynamicArray< T * > &out_components)
Tries to find components of the given base type in the objects components list and returns all matche...
Definition GameObject_inl.h:501
void SetLocalPosition(plVec3 vPosition)
Changes the position of the object local to its parent.
Definition GameObject_inl.h:173
const plTagSet & GetTags() const
Returns the tag set associated with this object.
Definition GameObject_inl.h:565
void SetName(plStringView sName)
Sets the name to identify this object. Does not have to be a unique name.
Definition GameObject_inl.h:89
void AddChildren(const plArrayPtr< const plGameObjectHandle > &children, plGameObject::TransformPreservation preserve=TransformPreservation::PreserveGlobal)
Adds the given objects as child objects.
Definition GameObject_inl.h:151
void DetachChild(const plGameObjectHandle &hChild, plGameObject::TransformPreservation preserve=TransformPreservation::PreserveGlobal)
Detaches the given child object from this object and makes it a top-level object.
Definition GameObject.cpp:439
void AddChild(const plGameObjectHandle &hChild, plGameObject::TransformPreservation preserve=TransformPreservation::PreserveGlobal)
Adds the given object as a child object.
Definition GameObject.cpp:428
bool SendMessageRecursive(plMessage &ref_msg)
Sends a message to all components of this object and then recursively to all children.
Definition GameObject_inl.h:555
plUInt32 GetChildCount() const
Returns the number of children.
Definition GameObject_inl.h:167
bool IsStatic() const
Returns whether this object is static.
Definition GameObject_inl.h:74
void DetachChildren(const plArrayPtr< const plGameObjectHandle > &children, plGameObject::TransformPreservation preserve=TransformPreservation::PreserveGlobal)
Detaches the given child objects from this object and makes them top-level objects.
Definition GameObject_inl.h:159
TransformPreservation
Defines during re-parenting what transform is going to be preserved.
Definition GameObject.h:165
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
void Assign(const char(&string)[N])
Assigning a new string from a string constant is a slow operation, but the hash computation can happe...
PL_ALWAYS_INLINE plStringView GetView() const
Returns a string view to this string's data.
Definition HashedString.h:128
Base class for all message types. Each message type has it's own id which is used to dispatch message...
Definition Message.h:22
bool IsInstanceOf(const plRTTI *pType) const
Returns whether the type of this instance is of the given type or derived from it.
Definition DynamicRTTI.cpp:6
Definition SimdBBoxSphere.h:6
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
T * GetData()
Returns a pointer to the array data, or nullptr if the array is empty.
Definition SmallArray_inl.h:444
plUInt32 GetCount() const
Returns the number of active elements in the array.
Definition SmallArray_inl.h:210
Definition Declarations.h:353
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A dynamic collection of tags featuring fast lookups.
Definition TagSet.h:23
A class to use together with plHashedString for quick comparisons with temporary strings that need no...
Definition HashedString.h:151
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
PL_ALWAYS_INLINE void Remove(const plBitflags< T > &rhs)
Removes the given flag.
Definition Bitflags.h:157
PL_ALWAYS_INLINE bool IsSet(Enum flag) const
Checks if certain flags are set within the bitfield.
Definition Bitflags.h:127
PL_ALWAYS_INLINE void Add(const plBitflags< T > &rhs)
Sets the given flag.
Definition Bitflags.h:151
A handle to a game object.
Definition Declarations.h:76
@ ParentChangesNotifications
The object should send a notification message when the parent is changes.
Definition Declarations.h:189
@ ActiveState
The object/component and all its parents have the active flag.
Definition Declarations.h:179
@ Dynamic
Usually detected automatically. A dynamic object will not cache render data across frames.
Definition Declarations.h:175
@ StaticTransformChangesNotifications
The object should send a notification message if it is static and its transform changes.
Definition Declarations.h:188
@ ChildChangesNotifications
The object should send a notification message when children are added or removed.
Definition Declarations.h:186
@ ComponentChangesNotifications
The object should send a notification message when components are added or removed.
Definition Declarations.h:187
@ ActiveFlag
The object/component has the 'active flag' set.
Definition Declarations.h:178