OpenClonk
C4DefGraphicsPtrBackup Class Reference

#include <C4DefGraphics.h>

Public Member Functions

 C4DefGraphicsPtrBackup ()
 
 ~C4DefGraphicsPtrBackup ()
 
void Add (C4DefGraphics *pGraphics)
 
void AssignUpdate ()
 
void AssignRemoval ()
 
StdMeshMaterialUpdateGetUpdater ()
 

Detailed Description

Definition at line 124 of file C4DefGraphics.h.

Constructor & Destructor Documentation

◆ C4DefGraphicsPtrBackup()

C4DefGraphicsPtrBackup::C4DefGraphicsPtrBackup ( )

Definition at line 608 of file C4DefGraphics.cpp.

608  :
609  MeshMaterialUpdate(::MeshMaterialManager),
610  MeshAnimationUpdate(::Definitions.GetSkeletonLoader())
611 {
612 }
C4DefList Definitions
Definition: C4Globals.cpp:49
StdMeshMatManager MeshMaterialManager
StdMeshSkeletonLoader & GetSkeletonLoader()
Definition: C4DefList.cpp:526

◆ ~C4DefGraphicsPtrBackup()

C4DefGraphicsPtrBackup::~C4DefGraphicsPtrBackup ( )

Definition at line 614 of file C4DefGraphics.cpp.

615 {
616  if(!fApplied) AssignRemoval();
617 
618  for(auto & Entry : Entries)
619  delete Entry;
620 }

References AssignRemoval().

Here is the call graph for this function:

Member Function Documentation

◆ Add()

void C4DefGraphicsPtrBackup::Add ( C4DefGraphics pGraphics)

Definition at line 622 of file C4DefGraphics.cpp.

623 {
624  for(C4DefGraphics* pCur = pGfx; pCur != nullptr; pCur = pCur->pNext)
625  Entries.push_back(new C4DefGraphicsPtrBackupEntry(pCur));
626 
627  // Remove all mesh materials that were loaded from this definition
628  C4Def* pDef = pGfx->pDef;
630  {
631  StdStrBuf Filename;
632  Filename.Copy(pDef->Filename);
633  Filename.Append("/"); Filename.Append(GetFilename(iter->FileName.getData()));
634 
635  if(Filename == iter->FileName)
636  iter = ::MeshMaterialManager.Remove(iter, &MeshMaterialUpdate);
637  else
638  ++iter;
639  }
640 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:42
C4AdditionalDefGraphics * pNext
Definition: C4DefGraphics.h:37
Definition: C4Def.h:99
char Filename[_MAX_FNAME_LEN]
Definition: C4Def.h:176
void Remove(const StdStrBuf &name, class StdMeshMaterialUpdate *update)
void Copy()
Definition: StdBuf.h:467
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519

References StdStrBuf::Append(), StdMeshMatManager::Begin(), StdStrBuf::Copy(), StdMeshMatManager::End(), C4Def::Filename, GetFilename(), MeshMaterialManager, C4DefGraphics::pDef, C4DefGraphics::pNext, and StdMeshMatManager::Remove().

Referenced by C4DefList::Reload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AssignRemoval()

void C4DefGraphicsPtrBackup::AssignRemoval ( )

Definition at line 642 of file C4DefGraphics.cpp.

643 {
644  MeshMaterialUpdate.Cancel();
645 
646  // Remove gfx
647  for(auto & Entry : Entries)
648  Entry->AssignRemoval();
649 
650  fApplied = true;
651 }

References StdMeshMaterialUpdate::Cancel().

Referenced by ~C4DefGraphicsPtrBackup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AssignUpdate()

void C4DefGraphicsPtrBackup::AssignUpdate ( )

Definition at line 653 of file C4DefGraphics.cpp.

654 {
655  // Update mesh materials for all meshes
656  for(auto & iter : Definitions.table)
657  if(iter.second->Graphics.Type == C4DefGraphics::TYPE_Mesh)
658  MeshMaterialUpdate.Update(iter.second->Graphics.Mesh);
659 
660  // Then, update mesh references in instances, attach bones by name, and update sprite gfx
661  for(auto & Entry : Entries)
662  Entry->AssignUpdate();
663 
664  // Update mesh materials and animations for all mesh instances.
665  for (C4Object *pObj : Objects)
666  {
667  if (pObj && pObj->Status)
668  {
669  if(pObj->pMeshInstance)
670  UpdateMesh(pObj->pMeshInstance);
671  for (C4GraphicsOverlay* pGfxOverlay = pObj->pGfxOverlay; pGfxOverlay; pGfxOverlay = pGfxOverlay->GetNext())
672  if(pGfxOverlay->pMeshInstance)
673  UpdateMesh(pGfxOverlay->pMeshInstance);
674  }
675  }
676 
677  fApplied = true;
678 }
C4GameObjects Objects
Definition: C4Globals.cpp:48
Table table
Definition: C4DefList.h:33
C4GraphicsOverlay * GetNext() const
void Update(StdMesh *mesh) const

References Definitions, C4GraphicsOverlay::GetNext(), Objects, C4DefList::table, C4DefGraphics::TYPE_Mesh, and StdMeshMaterialUpdate::Update().

Referenced by C4DefList::Reload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetUpdater()

StdMeshMaterialUpdate& C4DefGraphicsPtrBackup::GetUpdater ( )
inline

Definition at line 137 of file C4DefGraphics.h.

137 { return MeshMaterialUpdate; }

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