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

Definition at line 612 of file C4DefGraphics.cpp.

612  :
613  MeshMaterialUpdate(::MeshMaterialManager),
614  MeshAnimationUpdate(::Definitions.GetSkeletonLoader()),
615  fApplied(false)
616 {
617 }
StdMeshSkeletonLoader & GetSkeletonLoader()
Definition: C4DefList.cpp:512
C4DefList Definitions
Definition: C4Globals.cpp:49
StdMeshMatManager MeshMaterialManager
C4DefGraphicsPtrBackup::~C4DefGraphicsPtrBackup ( )

Definition at line 619 of file C4DefGraphics.cpp.

References AssignRemoval().

620 {
621  if(!fApplied) AssignRemoval();
622 
623  for(std::list<C4DefGraphicsPtrBackupEntry*>::iterator iter = Entries.begin(); iter != Entries.end(); ++iter)
624  delete *iter;
625 }

Here is the call graph for this function:

Member Function Documentation

void C4DefGraphicsPtrBackup::Add ( C4DefGraphics pGraphics)

Definition at line 627 of file C4DefGraphics.cpp.

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

Referenced by C4DefList::Reload().

628 {
629  for(C4DefGraphics* pCur = pGfx; pCur != nullptr; pCur = pCur->pNext)
630  Entries.push_back(new C4DefGraphicsPtrBackupEntry(pCur));
631 
632  // Remove all mesh materials that were loaded from this definition
633  C4Def* pDef = pGfx->pDef;
635  {
636  StdStrBuf Filename;
637  Filename.Copy(pDef->Filename);
638  Filename.Append("/"); Filename.Append(GetFilename(iter->FileName.getData()));
639 
640  if(Filename == iter->FileName)
641  iter = ::MeshMaterialManager.Remove(iter, &MeshMaterialUpdate);
642  else
643  ++iter;
644  }
645 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:55
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
Definition: C4Def.h:100
C4AdditionalDefGraphics * pNext
Definition: C4DefGraphics.h:37
char Filename[_MAX_FNAME+1]
Definition: C4Def.h:179
void Copy()
Definition: StdBuf.h:475
StdMeshMatManager MeshMaterialManager
void Remove(const StdStrBuf &name, class StdMeshMaterialUpdate *update)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4DefGraphicsPtrBackup::AssignRemoval ( )

Definition at line 647 of file C4DefGraphics.cpp.

References StdMeshMaterialUpdate::Cancel().

Referenced by ~C4DefGraphicsPtrBackup().

648 {
649  MeshMaterialUpdate.Cancel();
650 
651  // Remove gfx
652  for(std::list<C4DefGraphicsPtrBackupEntry*>::iterator iter = Entries.begin(); iter != Entries.end(); ++iter)
653  (*iter)->AssignRemoval();
654 
655  fApplied = true;
656 }

Here is the call graph for this function:

Here is the caller graph for this function:

void C4DefGraphicsPtrBackup::AssignUpdate ( )

Definition at line 658 of file C4DefGraphics.cpp.

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

Referenced by C4DefList::Reload().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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: