OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4MeshDenumerator Class Reference

#include <C4MeshDenumerator.h>

Inheritance diagram for C4MeshDenumerator:
[legend]
Collaboration diagram for C4MeshDenumerator:
[legend]

Public Member Functions

 C4MeshDenumerator ()
 
 C4MeshDenumerator (C4Def *def)
 
 C4MeshDenumerator (C4Object *object)
 
C4ObjectGetObject ()
 
void CompileFunc (StdCompiler *pComp, StdMeshInstance::AttachedMesh *attach) override
 
void DenumeratePointers (StdMeshInstance::AttachedMesh *attach) override
 
bool ClearPointers (C4Object *pObj) override
 

Detailed Description

Definition at line 22 of file C4MeshDenumerator.h.

Constructor & Destructor Documentation

C4MeshDenumerator::C4MeshDenumerator ( )
inline

Definition at line 29 of file C4MeshDenumerator.h.

29 : Object(nullptr) {}
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:34
C4MeshDenumerator::C4MeshDenumerator ( C4Def def)
inline

Definition at line 30 of file C4MeshDenumerator.h.

30 : Def(def), Object(nullptr) {}
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:34
C4MeshDenumerator::C4MeshDenumerator ( C4Object object)
inline

Definition at line 31 of file C4MeshDenumerator.h.

31 : Def(nullptr), Object(object) {}
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:34

Member Function Documentation

bool C4MeshDenumerator::ClearPointers ( C4Object pObj)
overridevirtual

Reimplemented from StdMeshInstance::AttachedMesh::Denumerator.

Definition at line 90 of file C4MeshDenumerator.cpp.

91 {
92  if(Object == pObj)
93  {
94  Object = nullptr;
95  // Return false causes the attached mesh to be deleted by StdMeshInstance
96  return false;
97  }
98 
99  return true;
100 }
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:34
void C4MeshDenumerator::CompileFunc ( StdCompiler pComp,
StdMeshInstance::AttachedMesh attach 
)
overridevirtual

Implements StdMeshInstance::AttachedMesh::Denumerator.

Definition at line 26 of file C4MeshDenumerator.cpp.

References C4MeshDenumeratorFactory, StdMeshInstance::AttachedMesh::Child, StdCompiler::excCorrupt(), C4Def::Graphics, StdCompiler::isDeserializer(), mkNamingAdapt(), mkNamingContextPtrAdapt(), mkNamingCountAdapt(), mkParAdapt(), StdMeshInstance::AttachedMesh::OwnChild, C4DefGraphics::pDef, C4DefGraphics::Type, C4DefGraphics::TYPE_Mesh, and StdCompiler::Value().

27 {
28  if(pComp->isDeserializer())
29  {
30  int32_t def;
31  pComp->Value(mkNamingCountAdapt(def, "ChildInstance"));
32 
33  if(def)
34  {
35  C4DefGraphics* pGfx = nullptr;
36  pComp->Value(mkNamingAdapt(C4DefGraphicsAdapt(pGfx), "ChildMesh"));
37  Def = pGfx->pDef;
38 
39  if(pGfx->Type != C4DefGraphics::TYPE_Mesh)
40  pComp->excCorrupt("ChildMesh points to non-mesh graphics");
41  assert(!attach->Child);
42  pComp->Value(mkParAdapt(mkNamingContextPtrAdapt(attach->Child, *pGfx->Mesh, "ChildInstance"), C4MeshDenumeratorFactory));
43  assert(attach->Child != nullptr);
44  attach->OwnChild = true; // Delete the newly allocated child instance when the parent instance is gone
45 
46  // TODO: Do we leak pGfx?
47  }
48  else
49  {
50  pComp->Value(mkNamingAdapt(Object, "ChildObject"));
51  attach->OwnChild = false; // Keep child instance when parent instance is gone since it belongs to a different object
52  }
53  }
54  else
55  {
56  int32_t def = 0;
57  if(Def) ++def;
58  pComp->Value(mkNamingCountAdapt(def, "ChildInstance"));
59 
60  if(Def)
61  {
62  assert(attach->OwnChild);
63  C4DefGraphics* pGfx = &Def->Graphics;
64  assert(pGfx->Type == C4DefGraphics::TYPE_Mesh);
65  pComp->Value(mkNamingAdapt(C4DefGraphicsAdapt(pGfx), "ChildMesh"));
66  pComp->Value(mkParAdapt(mkNamingContextPtrAdapt(attach->Child, *pGfx->Mesh, "ChildInstance"), C4MeshDenumeratorFactory));
67  }
68  else
69  {
70  assert(!attach->OwnChild);
71  pComp->Value(mkNamingAdapt(Object, "ChildObject"));
72  }
73  }
74 }
StdNamingCountAdapt< int_t > mkNamingCountAdapt(int_t &iCount, const char *szName)
Definition: StdAdaptors.h:976
void excCorrupt(const char *szMessage,...)
Definition: StdCompiler.h:249
const StdMeshInstance::AttachedMesh::DenumeratorFactoryFunc C4MeshDenumeratorFactory
StdContextPtrAdapt< T, ContextT > mkNamingContextPtrAdapt(T *&rpObj, const ContextT &ctx, const char *szNaming)
Definition: StdAdaptors.h:611
StdMeshInstance * Child
Definition: StdMesh.h:511
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:34
GraphicsType Type
Definition: C4DefGraphics.h:48
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:458
C4DefGraphics Graphics
Definition: C4Def.h:192

Here is the call graph for this function:

void C4MeshDenumerator::DenumeratePointers ( StdMeshInstance::AttachedMesh attach)
overridevirtual

Reimplemented from StdMeshInstance::AttachedMesh::Denumerator.

Definition at line 76 of file C4MeshDenumerator.cpp.

References StdMeshInstance::AttachedMesh::Child, C4ObjectPtr::DenumeratePointers(), StdMeshInstance::AttachedMesh::OwnChild, and C4Object::pMeshInstance.

77 {
78  Object.DenumeratePointers();
79 
80  // Set child instance of attach after denumeration
81  if(Object)
82  {
83  assert(!attach->OwnChild);
84  assert(!attach->Child || attach->Child == Object->pMeshInstance);
85  if(!attach->Child)
86  attach->Child = Object->pMeshInstance;
87  }
88 }
StdMeshInstance * Child
Definition: StdMesh.h:511
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:34
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155

Here is the call graph for this function:

C4Object* C4MeshDenumerator::GetObject ( )
inline

Definition at line 33 of file C4MeshDenumerator.h.

33 { return Object; }
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:34

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