OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 StdMeshMatrix & GetFinalTransformation () 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

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

Definition at line 499 of file StdMesh.h.

Constructor & Destructor Documentation

StdMeshInstance::AttachedMesh::AttachedMesh ( )
default
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
const StdMeshSkeleton & GetSkeleton() const
Definition: StdMesh.h:203
StdMeshInstance * Child
Definition: StdMesh.h:511
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
StdMeshInstance * Parent
Definition: StdMesh.h:510

Here is the call graph for this function:

StdMeshInstance::AttachedMesh::~AttachedMesh ( )

Definition at line 982 of file StdMesh.cpp.

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

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

Definition at line 1055 of file StdMesh.cpp.

1056 {
1057  return ChildDenumerator->ClearPointers(pObj);
1058 }
virtual bool ClearPointers(class C4Object *pObj)
Definition: StdMesh.h:496
Denumerator * ChildDenumerator
Definition: StdMesh.h:513
void StdMeshInstance::AttachedMesh::CompileFunc ( StdCompiler pComp,
DenumeratorFactoryFunc  Factory 
)

Definition at line 1015 of file StdMesh.cpp.

References StdMeshInstance::AM_DrawBefore, StdMeshInstance::AM_MatchSkeleton, StdCompiler::isDeserializer(), mkBitfieldAdapt(), mkNamingAdapt(), mkParAdapt(), 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:850
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:953
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:458

Here is the call graph for this function:

void StdMeshInstance::AttachedMesh::DenumeratePointers ( )

Definition at line 1042 of file StdMesh.cpp.

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
const StdMeshSkeleton & GetSkeleton() const
Definition: StdMesh.h:203
StdMeshInstance * Child
Definition: StdMesh.h:511
void DenumeratePointers()
Definition: StdMesh.cpp:1672
AttachedMesh * AttachParent
Definition: StdMesh.h:661
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
StdMeshInstance * Parent
Definition: StdMesh.h:510
template<typename T >
static Denumerator* StdMeshInstance::AttachedMesh::DenumeratorFactory ( )
inlinestatic

Definition at line 502 of file StdMesh.h.

502 { return new T; }
unsigned int StdMeshInstance::AttachedMesh::GetChildBone ( ) const
inline

Definition at line 526 of file StdMesh.h.

526 { return ChildBone; }
const StdMeshMatrix& StdMeshInstance::AttachedMesh::GetFinalTransformation ( ) const
inline

Definition at line 518 of file StdMesh.h.

518 { return FinalTrans; }
uint32_t StdMeshInstance::AttachedMesh::GetFlags ( ) const
inline

Definition at line 519 of file StdMesh.h.

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

519 { return Flags; }

Here is the caller graph for this function:

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

Definition at line 525 of file StdMesh.h.

525 { return ParentBone; }
void StdMeshInstance::AttachedMesh::SetAttachTransformation ( const StdMeshMatrix &  transformation)

Definition at line 1009 of file StdMesh.cpp.

1010 {
1011  AttachTrans = transformation;
1012  FinalTransformDirty = true;
1013 }
bool StdMeshInstance::AttachedMesh::SetChildBone ( const StdStrBuf bone)

Definition at line 999 of file StdMesh.cpp.

References 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 }
const StdMeshSkeleton & GetSkeleton() const
Definition: StdMesh.h:203
StdMeshInstance * Child
Definition: StdMesh.h:511
const StdMeshBone * GetBoneByName(const StdStrBuf &name) const
Definition: StdMesh.cpp:386
unsigned int Index
Definition: StdMesh.h:32
const StdMesh & GetMesh() const
Definition: StdMesh.h:622

Here is the caller graph for this function:

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

Definition at line 989 of file StdMesh.cpp.

References StdMeshBone::Index.

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
unsigned int Index
Definition: StdMesh.h:32
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
StdMeshInstance * Parent
Definition: StdMesh.h:510

Friends And Related Function Documentation

friend class StdMeshInstance
friend

Definition at line 485 of file StdMesh.h.

friend class StdMeshUpdate
friend

Definition at line 486 of file StdMesh.h.

Member Data Documentation

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

Definition at line 513 of file StdMesh.h.

uint32_t StdMeshInstance::AttachedMesh::Number {0}
bool StdMeshInstance::AttachedMesh::OwnChild {true}

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