OpenClonk
StdMeshInstance::AttachedMesh Class Reference

#include <StdMesh.h>

Collaboration diagram for StdMeshInstance::AttachedMesh:
[legend]

Classes

class  Denumerator
 

Public Types

typedef Denumerator *(* DenumeratorFactoryFunc) ()
 

Public Member Functions

 AttachedMesh ()
 
 AttachedMesh (unsigned int number, StdMeshInstance *parent, StdMeshInstance *child, bool own_child, Denumerator *denumerator, unsigned int parent_bone, unsigned int child_bone, const StdMeshMatrix &transform, uint32_t flags)
 
 ~AttachedMesh ()
 
bool SetParentBone (const StdStrBuf &bone)
 
bool SetChildBone (const StdStrBuf &bone)
 
void SetAttachTransformation (const StdMeshMatrix &transformation)
 
const StdMeshMatrixGetFinalTransformation () const
 
uint32_t GetFlags () const
 
void CompileFunc (StdCompiler *pComp, DenumeratorFactoryFunc Factory)
 
void DenumeratePointers ()
 
bool ClearPointers (class C4Object *pObj)
 
unsigned int GetParentBone () const
 
unsigned int GetChildBone () const
 

Static Public Member Functions

template<typename T >
static DenumeratorDenumeratorFactory ()
 

Public Attributes

uint32_t Number {0}
 
StdMeshInstanceParent {nullptr}
 
StdMeshInstanceChild {nullptr}
 
bool OwnChild {true}
 
DenumeratorChildDenumerator {nullptr}
 

Friends

class StdMeshInstance
 
class StdMeshUpdate
 

Detailed Description

Definition at line 483 of file StdMesh.h.

Member Typedef Documentation

◆ DenumeratorFactoryFunc

typedef Denumerator*(* StdMeshInstance::AttachedMesh::DenumeratorFactoryFunc) ()

Definition at line 499 of file StdMesh.h.

Constructor & Destructor Documentation

◆ AttachedMesh() [1/2]

StdMeshInstance::AttachedMesh::AttachedMesh ( )
default

Referenced by StdMeshInstanceAnimationNode::ClearPointers().

Here is the caller graph for this function:

◆ AttachedMesh() [2/2]

StdMeshInstance::AttachedMesh::AttachedMesh ( unsigned int  number,
StdMeshInstance parent,
StdMeshInstance child,
bool  own_child,
Denumerator denumerator,
unsigned int  parent_bone,
unsigned int  child_bone,
const StdMeshMatrix transform,
uint32_t  flags 
)

Definition at line 973 of file StdMesh.cpp.

References StdMeshInstance::GetMesh(), and StdMesh::GetSkeleton().

974  :
975  Number(number), Parent(parent), Child(child), OwnChild(own_child), ChildDenumerator(denumerator),
976  ParentBone(parent_bone), ChildBone(child_bone), AttachTrans(transform), Flags(flags),
977  FinalTransformDirty(true)
978 {
979  MapBonesOfChildToParent(parent->GetMesh().GetSkeleton(), child->GetMesh().GetSkeleton());
980 }
Denumerator * ChildDenumerator
Definition: StdMesh.h:513
StdMeshInstance * Child
Definition: StdMesh.h:511
const StdMeshSkeleton & GetSkeleton() const
Definition: StdMesh.h:203
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
StdMeshInstance * Parent
Definition: StdMesh.h:510
Here is the call graph for this function:

◆ ~AttachedMesh()

StdMeshInstance::AttachedMesh::~AttachedMesh ( )

Definition at line 982 of file StdMesh.cpp.

References Child, ChildDenumerator, and OwnChild.

983 {
984  if (OwnChild)
985  delete Child;
986  delete ChildDenumerator;
987 }
Denumerator * ChildDenumerator
Definition: StdMesh.h:513
StdMeshInstance * Child
Definition: StdMesh.h:511

Member Function Documentation

◆ ClearPointers()

bool StdMeshInstance::AttachedMesh::ClearPointers ( class C4Object pObj)

Definition at line 1055 of file StdMesh.cpp.

References StdMeshInstance::AM_MatchSkeleton, ChildDenumerator, StdMeshInstance::AttachedMesh::Denumerator::ClearPointers(), and StdMeshSkeleton::GetMatchingBones().

1056 {
1057  return ChildDenumerator->ClearPointers(pObj);
1058 }
virtual bool ClearPointers(class C4Object *pObj)
Definition: StdMesh.h:496
Denumerator * ChildDenumerator
Definition: StdMesh.h:513
Here is the call graph for this function:

◆ CompileFunc()

void StdMeshInstance::AttachedMesh::CompileFunc ( StdCompiler pComp,
DenumeratorFactoryFunc  Factory 
)

Definition at line 1015 of file StdMesh.cpp.

References StdMeshInstance::AM_DrawBefore, StdMeshInstance::AM_MatchSkeleton, ChildDenumerator, StdCompiler::isDeserializer(), mkBitfieldAdapt(), mkNamingAdapt(), mkParAdapt(), Number, and StdCompiler::Value().

1016 {
1017  if(pComp->isDeserializer())
1018  {
1019  FinalTransformDirty = true;
1020  ChildDenumerator = Factory();
1021  }
1022 
1023  const StdBitfieldEntry<uint8_t> AM_Entries[] =
1024  {
1025  { "MatchSkeleton", AM_MatchSkeleton },
1026  { "DrawBefore", AM_DrawBefore },
1027  { nullptr, 0 }
1028  };
1029 
1030  pComp->Value(mkNamingAdapt(Number, "Number"));
1031  pComp->Value(mkNamingAdapt(ParentBone, "ParentBone")); // TODO: Save as string
1032  pComp->Value(mkNamingAdapt(ChildBone, "ChildBone")); // TODO: Save as string (note we can only resolve this in DenumeratePointers then!)
1033  pComp->Value(mkNamingAdapt(mkMatrixAdapt(AttachTrans), "AttachTransformation"));
1034 
1035  uint8_t dwSyncFlags = static_cast<uint8_t>(Flags);
1036  pComp->Value(mkNamingAdapt(mkBitfieldAdapt(dwSyncFlags, AM_Entries), "Flags", 0u));
1037  if(pComp->isDeserializer()) Flags = dwSyncFlags;
1038 
1039  pComp->Value(mkParAdapt(*ChildDenumerator, this));
1040 }
Definition: StdAdaptors.h:868
Denumerator * ChildDenumerator
Definition: StdMesh.h:513
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
StdBitfieldAdapt< T > mkBitfieldAdapt(T &rVal, const StdBitfieldEntry< T > *pNames)
Definition: StdAdaptors.h:971
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:476
Here is the call graph for this function:

◆ DenumeratePointers()

void StdMeshInstance::AttachedMesh::DenumeratePointers ( )

Definition at line 1042 of file StdMesh.cpp.

References StdMeshInstance::AttachParent, Child, ChildDenumerator, StdMeshInstance::AttachedMesh::Denumerator::DenumeratePointers(), StdMeshInstance::DenumeratePointers(), StdMeshInstance::GetMesh(), StdMesh::GetSkeleton(), OwnChild, and Parent.

1043 {
1045 
1046  assert(Child != nullptr);
1047  Child->AttachParent = this;
1048 
1049  MapBonesOfChildToParent(Parent->GetMesh().GetSkeleton(), Child->GetMesh().GetSkeleton());
1050 
1051  if(OwnChild)
1053 }
Denumerator * ChildDenumerator
Definition: StdMesh.h:513
virtual void DenumeratePointers(AttachedMesh *attach)
Definition: StdMesh.h:495
StdMeshInstance * Child
Definition: StdMesh.h:511
const StdMeshSkeleton & GetSkeleton() const
Definition: StdMesh.h:203
void DenumeratePointers()
Definition: StdMesh.cpp:1672
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
AttachedMesh * AttachParent
Definition: StdMesh.h:661
StdMeshInstance * Parent
Definition: StdMesh.h:510
Here is the call graph for this function:

◆ DenumeratorFactory()

template<typename T >
static Denumerator* StdMeshInstance::AttachedMesh::DenumeratorFactory ( )
inlinestatic

Definition at line 502 of file StdMesh.h.

502 { return new T; }

◆ GetChildBone()

unsigned int StdMeshInstance::AttachedMesh::GetChildBone ( ) const
inline

Definition at line 526 of file StdMesh.h.

526 { return ChildBone; }

◆ GetFinalTransformation()

const StdMeshMatrix& StdMeshInstance::AttachedMesh::GetFinalTransformation ( ) const
inline

Definition at line 518 of file StdMesh.h.

518 { return FinalTrans; }

◆ GetFlags()

uint32_t StdMeshInstance::AttachedMesh::GetFlags ( ) const
inline

Definition at line 519 of file StdMesh.h.

References CompileFunc().

Referenced by StdMeshInstance::GetBoneCount(), and StdMeshInstance::GetBoneTransform().

519 { return Flags; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetParentBone()

unsigned int StdMeshInstance::AttachedMesh::GetParentBone ( ) const
inline

Definition at line 525 of file StdMesh.h.

525 { return ParentBone; }

◆ SetAttachTransformation()

void StdMeshInstance::AttachedMesh::SetAttachTransformation ( const StdMeshMatrix transformation)

Definition at line 1009 of file StdMesh.cpp.

1010 {
1011  AttachTrans = transformation;
1012  FinalTransformDirty = true;
1013 }

◆ SetChildBone()

bool StdMeshInstance::AttachedMesh::SetChildBone ( const StdStrBuf bone)

Definition at line 999 of file StdMesh.cpp.

References Child, StdMeshSkeleton::GetBoneByName(), StdMeshInstance::GetMesh(), StdMesh::GetSkeleton(), and StdMeshBone::Index.

Referenced by StdMeshUpdate::Update().

1000 {
1001  const StdMeshBone* bone_obj = Child->GetMesh().GetSkeleton().GetBoneByName(bone);
1002  if (!bone_obj) return false;
1003  ChildBone = bone_obj->Index;
1004 
1005  FinalTransformDirty = true;
1006  return true;
1007 }
StdMeshInstance * Child
Definition: StdMesh.h:511
const StdMeshSkeleton & GetSkeleton() const
Definition: StdMesh.h:203
const StdMeshBone * GetBoneByName(const StdStrBuf &name) const
Definition: StdMesh.cpp:386
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
unsigned int Index
Definition: StdMesh.h:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetParentBone()

bool StdMeshInstance::AttachedMesh::SetParentBone ( const StdStrBuf bone)

Definition at line 989 of file StdMesh.cpp.

References StdMeshSkeleton::GetBoneByName(), StdMeshInstance::GetMesh(), StdMesh::GetSkeleton(), StdMeshBone::Index, and Parent.

990 {
991  const StdMeshBone* bone_obj = Parent->GetMesh().GetSkeleton().GetBoneByName(bone);
992  if (!bone_obj) return false;
993  ParentBone = bone_obj->Index;
994 
995  FinalTransformDirty = true;
996  return true;
997 }
const StdMeshSkeleton & GetSkeleton() const
Definition: StdMesh.h:203
const StdMeshBone * GetBoneByName(const StdStrBuf &name) const
Definition: StdMesh.cpp:386
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
unsigned int Index
Definition: StdMesh.h:32
StdMeshInstance * Parent
Definition: StdMesh.h:510
Here is the call graph for this function:

Friends And Related Function Documentation

◆ StdMeshInstance

friend class StdMeshInstance
friend

Definition at line 485 of file StdMesh.h.

◆ StdMeshUpdate

friend class StdMeshUpdate
friend

Definition at line 486 of file StdMesh.h.

Member Data Documentation

◆ Child

◆ ChildDenumerator

Denumerator* StdMeshInstance::AttachedMesh::ChildDenumerator {nullptr}

Definition at line 513 of file StdMesh.h.

Referenced by ClearPointers(), CompileFunc(), DenumeratePointers(), and ~AttachedMesh().

◆ Number

uint32_t StdMeshInstance::AttachedMesh::Number {0}

◆ OwnChild

◆ Parent


The documentation for this class was generated from the following files: