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 ()
 
virtual void CompileFunc (StdCompiler *pComp, StdMeshInstance::AttachedMesh *attach)
 
virtual void DenumeratePointers (StdMeshInstance::AttachedMesh *attach)
 
virtual bool ClearPointers (C4Object *pObj)
 

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 : Def(nullptr), Object(nullptr) {}
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:35
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:35
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:35

Member Function Documentation

bool C4MeshDenumerator::ClearPointers ( C4Object pObj)
virtual

Reimplemented from StdMeshInstance::AttachedMesh::Denumerator.

Definition at line 89 of file C4MeshDenumerator.cpp.

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

Implements StdMeshInstance::AttachedMesh::Denumerator.

Definition at line 25 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().

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

Here is the call graph for this function:

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

Reimplemented from StdMeshInstance::AttachedMesh::Denumerator.

Definition at line 75 of file C4MeshDenumerator.cpp.

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

76 {
77  Object.DenumeratePointers();
78 
79  // Set child instance of attach after denumeration
80  if(Object)
81  {
82  assert(!attach->OwnChild);
83  assert(!attach->Child || attach->Child == Object->pMeshInstance);
84  if(!attach->Child)
85  attach->Child = Object->pMeshInstance;
86  }
87 }
StdMeshInstance * Child
Definition: StdMesh.h:513
C4Object * Object(C4PropList *_this)
Definition: C4AulDefFunc.h:35
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:35

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