mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 00:14:22 +00:00
Implement ViewROI and base classes (#287)
* Implement ViewROI and base classes * Clean up Orientable header * Move tgl to tgl subdirectory, and use target_include_directories * Move classes to submodules * Fix some missed references * Fix/match UpdateWorldData * Renaming / removing MxTypes / refactoring * Consistent naming for Matrix * Adjust format action * Add Vector3/Vector4 to Data vector * Add TGL comment * Add a comment about Matrix4Impl * Add ROI comment --------- Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com> Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
116
LEGO1/viewmanager/viewlodlist.h
Normal file
116
LEGO1/viewmanager/viewlodlist.h
Normal file
@@ -0,0 +1,116 @@
|
||||
#ifndef VIEWLODLIST_H
|
||||
#define VIEWLODLIST_H
|
||||
|
||||
#include "../compat.h"
|
||||
#include "../realtime/lodlist.h"
|
||||
#include "assert.h"
|
||||
|
||||
#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.
|
||||
|
||||
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&, 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;
|
||||
}
|
||||
|
||||
#endif // VIEWLODLIST_H
|
7
LEGO1/viewmanager/viewmanager.cpp
Normal file
7
LEGO1/viewmanager/viewmanager.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "viewmanager.h"
|
||||
|
||||
// OFFSET: LEGO1 0x100a64d0 STUB
|
||||
void ViewManager::RemoveAll(ViewROI*)
|
||||
{
|
||||
// TODO
|
||||
}
|
11
LEGO1/viewmanager/viewmanager.h
Normal file
11
LEGO1/viewmanager/viewmanager.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef VIEWMANAGER_H
|
||||
#define VIEWMANAGER_H
|
||||
|
||||
class ViewROI;
|
||||
|
||||
class ViewManager {
|
||||
public:
|
||||
__declspec(dllexport) void RemoveAll(ViewROI*);
|
||||
};
|
||||
|
||||
#endif // VIEWMANAGER_H
|
45
LEGO1/viewmanager/viewroi.cpp
Normal file
45
LEGO1/viewmanager/viewroi.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "viewroi.h"
|
||||
|
||||
#include "../decomp.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(ViewROI, 0xe0)
|
||||
|
||||
// OFFSET: LEGO1 0x100a9eb0
|
||||
float ViewROI::IntrinsicImportance() const
|
||||
{
|
||||
return .5;
|
||||
} // for now
|
||||
|
||||
// OFFSET: LEGO1 0x100a9ec0
|
||||
const Tgl::Group* ViewROI::GetGeometry() const
|
||||
{
|
||||
return geometry;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100a9ed0
|
||||
Tgl::Group* ViewROI::GetGeometry()
|
||||
{
|
||||
return geometry;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100a9ee0
|
||||
void ViewROI::UpdateWorldData(const Matrix4Data& parent2world)
|
||||
{
|
||||
OrientableROI::UpdateWorldData(parent2world);
|
||||
if (geometry) {
|
||||
// Tgl::FloatMatrix4 tgl_mat;
|
||||
Matrix4 mat;
|
||||
SETMAT4(mat, m_local2world.GetMatrix());
|
||||
Tgl::Result result = geometry->SetTransformation(mat);
|
||||
// assert(Tgl::Succeeded(result));
|
||||
}
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100aa250 TEMPLATE
|
||||
// ViewROI::`scalar deleting destructor'
|
||||
inline ViewROI::~ViewROI()
|
||||
{
|
||||
// SetLODList() will decrease refCount of LODList
|
||||
SetLODList(0);
|
||||
delete geometry;
|
||||
}
|
47
LEGO1/viewmanager/viewroi.h
Normal file
47
LEGO1/viewmanager/viewroi.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef VIEWROI_H
|
||||
#define VIEWROI_H
|
||||
|
||||
#include "../realtime/orientableroi.h"
|
||||
#include "../tgl/tgl.h"
|
||||
#include "viewlodlist.h"
|
||||
|
||||
/*
|
||||
ViewROI objects represent view objects, collections of view objects,
|
||||
etc. Basically, anything which can be placed in a scene and manipilated
|
||||
by the view manager is a ViewROI.
|
||||
*/
|
||||
class ViewROI : public OrientableROI {
|
||||
public:
|
||||
inline ViewROI(Tgl::Renderer* pRenderer, ViewLODList* lodList)
|
||||
{
|
||||
SetLODList(lodList);
|
||||
geometry = pRenderer->CreateGroup();
|
||||
}
|
||||
inline ~ViewROI();
|
||||
inline void SetLODList(ViewLODList* lodList)
|
||||
{
|
||||
// ??? inherently type unsafe - kind of... because, now, ROI
|
||||
// does not expose SetLODs() ...
|
||||
// solution: create pure virtual LODListBase* ROI::GetLODList()
|
||||
// and let derived ROI classes hold the LODList
|
||||
|
||||
if (m_lods) {
|
||||
reinterpret_cast<ViewLODList*>(m_lods)->Release();
|
||||
}
|
||||
|
||||
m_lods = lodList;
|
||||
|
||||
if (m_lods) {
|
||||
reinterpret_cast<ViewLODList*>(m_lods)->AddRef();
|
||||
}
|
||||
}
|
||||
virtual float IntrinsicImportance() const;
|
||||
virtual Tgl::Group* GetGeometry();
|
||||
virtual const Tgl::Group* GetGeometry() const;
|
||||
|
||||
protected:
|
||||
Tgl::Group* geometry;
|
||||
void UpdateWorldData(const Matrix4Data& parent2world);
|
||||
};
|
||||
|
||||
#endif // VIEWROI_H
|
Reference in New Issue
Block a user