Isle
Loading...
Searching...
No Matches
viewlodlist.h
Go to the documentation of this file.
1#ifndef VIEWLODLIST_H
2#define VIEWLODLIST_H
3
4#include "assert.h"
5#include "compat.h"
6#include "mxstl/stlcompat.h"
7#include "realtime/lodlist.h"
8
9#include <string.h>
10
11#pragma warning(disable : 4237)
12#pragma warning(disable : 4786)
13
14class ViewLOD;
16
18// ViewLODList
19//
20// An ViewLODList is an LODList that is shared among instances of the "same ROI".
21//
22// ViewLODLists are managed (created and destroyed) by ViewLODListManager.
23//
24
30class ViewLODList : public LODList<ViewLOD> {
31 friend ViewLODListManager;
32
33protected:
39 ViewLODList(size_t capacity, ViewLODListManager* owner);
40
44 ~ViewLODList() override;
45
46public:
51 inline int AddRef();
52
57 inline int Release();
58
59#ifdef _DEBUG
64 void Dump(void (*pTracer)(const char*, ...)) const;
65#endif
66
67private:
68 int m_refCount;
69 ViewLODListManager* m_owner;
70};
71
73//
74
79typedef const char* ROIName;
80
92 unsigned char operator()(const ROIName& rName1, const ROIName& rName2) const
93 {
94 return strcmp((const char*) rName1, (const char*) rName2) > 0;
95 }
96};
97
99//
100// ViewLODListManager
101//
102// ViewLODListManager manages creation and sharing of ViewLODLists.
103// It stores ViewLODLists under a name, the name of the ROI where
104// the ViewLODList belongs.
105
112
116 typedef map<ROIName, ViewLODList*, ROINameComparator> ViewLODListMap;
117
118public:
123
127 virtual ~ViewLODListManager();
128
136 ViewLODList* Create(const ROIName& rROIName, int lodCount);
137
144 ViewLODList* Lookup(const ROIName&) const;
145
151 unsigned char Destroy(ViewLODList* lodList);
152
153#ifdef _DEBUG
158 void Dump(void (*pTracer)(const char*, ...)) const;
159#endif
160
161private:
162 static int g_ROINameUID;
163
164 ViewLODListMap m_map;
165};
166
168//
169// Implementation notes:
170//
171// - ViewLODList instances are reference counted and deleted when their count reaches zero.
172// - Each list is associated with a string key (the ROI type's name) in ViewLODListManager.
173// - New lists are created with unique names in case of collisions, using g_ROINameUID for disambiguation.
174//
175// [AI] The overall pattern supports resource sharing among many ROI instances of the same type while maintaining
176// correct resource lifetime, suitable for geometry sharing in a 3D engine.
177//
178
179#endif // VIEWLODLIST_H
[AI] Type-safe extension of LODListBase, templated for any LODObject-derived type.
Definition: lodlist.h:110
[AI] Manages the lifecycle, lookup, and sharing of ViewLODList instances for different ROI names.
Definition: viewlodlist.h:111
ViewLODList * Create(const ROIName &rROIName, int lodCount)
[AI] Creates and registers a new ViewLODList for a named ROI, with space for the specified number of ...
Definition: viewlodlist.cpp:67
ViewLODListManager()
[AI] Constructs a ViewLODListManager; initializes internal structures.
Definition: viewlodlist.cpp:32
virtual ~ViewLODListManager()
[AI] Destroys the manager and all ViewLODLists it owns, ensuring proper cleanup of all managed instan...
Definition: viewlodlist.cpp:39
ViewLODList * Lookup(const ROIName &) const
[AI] Looks up an existing ViewLODList by ROI name, incrementing its reference count.
unsigned char Destroy(ViewLODList *lodList)
[AI] Destroys (removes and deletes) the given ViewLODList from the manager.
[AI] Reference-counted list of Level-of-Detail (LOD) objects associated with a single ROI (Realtime O...
Definition: viewlodlist.h:30
int Release()
[AI] Decrements the reference count.
~ViewLODList() override
[AI] Destructor for ViewLODList; asserts that no references remain before destroying.
ViewLODList(size_t capacity, ViewLODListManager *owner)
[AI] Constructs a ViewLODList with a given capacity and owner manager.
int AddRef()
[AI] Increments the reference count.
[AI] Represents a Level of Detail (LOD) object for rendering, implemented with a mesh builder and sup...
Definition: viewlod.h:20
[AI] STL compatibility layer header to provide consistent STL (Standard Template Library) types and a...
[AI] Comparator for ROIName (C-style strings) to be used as keys in maps, using strcmp for sorting.
Definition: viewlodlist.h:85
unsigned char operator()(const ROIName &rName1, const ROIName &rName2) const
[AI] Lexicographical comparison of two ROI names for map ordering.
Definition: viewlodlist.h:92
const char * ROIName
[AI] String type used as a key to identify uniquely-named ROI (Realtime Object Instance) classes.
Definition: viewlodlist.h:79