isle-portable/LEGO1/viewmanager/viewlodlist.h
Anonymous Maarten b996fff6fa
Support building isle with modern MSVC + msys2 (#421)
* cmake: detect older MSVC and define ENABLE_DECOMP_ASSERTS to enable decomp asserts

* Add /Zc:__cplusplus to define __cplusplus with c++ version number

* Silence deprecated CRT releated warnings

* LegoCameraController overrids some methods that are not defined in its parent(s)

* Tgl::Device::GetDrawnTriangleCount does not exist (FIXME: INCORRECT FIX -> Tgl::Device should be updated instead)

* Remove copy/pasted APP_ICON from lego1 resource.h header

* Implement empty ViewLODList::Dump method

* Also enable "compat mode" for newer MSVC compilers

* Only do decomp assertions when using older MSVC compilers

* msys2 mingw compat (cannot pass reference of rvalue)

* Fix msys2 mingw warning: declaration 'class Tgl::Group' does not declare anything

* Add FIXME comment to LEgo3DView::m_previousRenderTime

* LegoView1 is 16 bytes bigger then LegoView ==> 4 32-bit pointers

* include string.h for strlen

* Fix overrides

* Fix constness of method

* Fixes

* Formatting

* Add size assert for MxFrequencyMeter

* ci: build isle with msys2 + msvc on GitHub actions

* Set vcvars for msvc

* msys2 needs the msys2 shell

* Build in default shell

* isle is not 64-bit yet (I think)

* Print bitness

* Use amd64_x64 cross tools

* Minor updates

* Add more names

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
2024-01-10 23:34:32 +01:00

129 lines
2.8 KiB
C++

#ifndef VIEWLODLIST_H
#define VIEWLODLIST_H
#include "assert.h"
#include "compat.h"
#include "mxstl/stlcompat.h"
#include "realtime/lodlist.h"
#include <string.h>
#pragma warning(disable : 4237)
#pragma warning(disable : 4786)
class ViewLOD;
class ViewLODListManager;
//////////////////////////////////////////////////////////////////////////////
// ViewLODList
//
// An ViewLODList is an LODList that is shared among instances of the "same ROI".
//
// ViewLODLists are managed (created and destroyed) by ViewLODListManager.
//
class ViewLODList : public LODList<ViewLOD> {
friend ViewLODListManager;
protected:
ViewLODList(size_t capacity);
~ViewLODList();
public:
inline int AddRef();
inline int Release();
#ifdef _DEBUG
void Dump(void (*pTracer)(const char*, ...)) const;
#endif
private:
int m_refCount;
ViewLODListManager* m_owner;
};
//////////////////////////////////////////////////////////////////////////////
//
// ??? for now, until we have symbol management
typedef const char* ROIName;
struct ROINameComparator {
bool operator()(const ROIName& rName1, const ROIName& rName2) const
{
return strcmp((const char*) rName1, (const char*) rName2) > 0;
}
};
//////////////////////////////////////////////////////////////////////////////
//
// ViewLODListManager
//
// ViewLODListManager manages creation and sharing of ViewLODLists.
// It stores ViewLODLists under a name, the name of the ROI where
// the ViewLODList belongs.
// VTABLE: LEGO1 0x100dbdbc
// SIZE 0x14
class ViewLODListManager {
typedef map<ROIName, ViewLODList*, ROINameComparator> ViewLODListMap;
public:
ViewLODListManager();
virtual ~ViewLODListManager();
// ??? should LODList be const
// creates an LODList with room for lodCount LODs for a named ROI
// returned LODList has a refCount of 1, i.e. caller must call Release()
// when it no longer holds on to the list
ViewLODList* Create(const ROIName& rROIName, int lodCount);
// returns an LODList for a named ROI
// returned LODList's refCount is increased, i.e. caller must call Release()
// when it no longer holds on to the list
ViewLODList* Lookup(const ROIName&) const;
void Destroy(ViewLODList* lodList);
#ifdef _DEBUG
void Dump(void (*pTracer)(const char*, ...)) const;
#endif
private:
ViewLODListMap m_map;
};
//////////////////////////////////////////////////////////////////////////////
//
// ViewLODList implementation
inline ViewLODList::ViewLODList(size_t capacity) : LODList<ViewLOD>(capacity), m_refCount(0)
{
}
inline ViewLODList::~ViewLODList()
{
assert(m_refCount == 0);
}
inline int ViewLODList::AddRef()
{
return ++m_refCount;
}
inline int ViewLODList::Release()
{
assert(m_refCount > 0);
if (!--m_refCount)
m_owner->Destroy(this);
return m_refCount;
}
#ifdef _DEBUG
inline void ViewLODList::Dump(void (*pTracer)(const char*, ...)) const
{
// FIXME: dump something
}
#endif
#endif // VIEWLODLIST_H