diff --git a/LEGO1/viewmanager/viewlodlist.cpp b/LEGO1/viewmanager/viewlodlist.cpp index 6d6dfdb2..920444e9 100644 --- a/LEGO1/viewmanager/viewlodlist.cpp +++ b/LEGO1/viewmanager/viewlodlist.cpp @@ -1,6 +1,7 @@ #include "viewlodlist.h" #include "decomp.h" +#include "viewlod.h" #include @@ -17,10 +18,33 @@ ViewLODListManager::ViewLODListManager() { } -// STUB: LEGO1 0x100a7130 +// FUNCTION: LEGO1 0x100a7130 ViewLODListManager::~ViewLODListManager() { - // TODO + ViewLODListMap::iterator iterator; + + // delete all ViewLODLists + for (iterator = m_map.begin(); !(iterator == m_map.end()); ++iterator) { + const ROIName& rROIName = (*iterator).first; + ViewLODList* pLODList = (*iterator).second; + + // LODList's refCount should be 0 + assert(pLODList->m_refCount == 0); + + // ???who pops and deletes LODObjects + while (pLODList->Size() > 0) { + delete const_cast(pLODList->PopBack()); + } + + delete pLODList; + // ??? for now + delete[] const_cast(rROIName); + } + + // ??? correct way of "emptying" map + m_map.erase(m_map.begin(), m_map.end()); + + assert(m_map.begin() == m_map.end()); } // FUNCTION: LEGO1 0x100a72c0 @@ -63,10 +87,23 @@ ViewLODList* ViewLODListManager::Create(const ROIName& rROIName, int lodCount) return pLODList; } -// STUB: LEGO1 0x100a75b0 -ViewLODList* ViewLODListManager::Lookup(const ROIName&) const +// FUNCTION: LEGO1 0x100a75b0 +ViewLODList* ViewLODListManager::Lookup(const ROIName& p_roiName) const { - return NULL; + // returned ViewLODList's refCount is increased, i.e. caller must call Release() + // when it no longer holds on to the list + + ViewLODListMap::const_iterator iterator = m_map.find(p_roiName); + ViewLODList* pLODList = 0; + + if (!(iterator == m_map.end())) { + pLODList = (*iterator).second; + + assert(pLODList); + pLODList->AddRef(); + } + + return pLODList; } // STUB: LEGO1 0x100a7680 diff --git a/LEGO1/viewmanager/viewroi.cpp b/LEGO1/viewmanager/viewroi.cpp index 790ab1b6..8d8cbb6b 100644 --- a/LEGO1/viewmanager/viewroi.cpp +++ b/LEGO1/viewmanager/viewroi.cpp @@ -41,22 +41,40 @@ void ViewROI::UpdateWorldData(const Matrix4& parent2world) } } -// STUB: LEGO1 0x100a9fc0 +// FUNCTION: LEGO1 0x100a9fc0 void ViewROI::VTable0x24(const Matrix4& p_transform) { - // TODO + OrientableROI::VTable0x24(p_transform); + if (geometry) { + Tgl::FloatMatrix4 matrix; + Matrix4 in(matrix); + SETMAT4(in, m_local2world); + geometry->SetTransformation(matrix); + } } -// STUB: LEGO1 0x100aa0a0 +// FUNCTION: LEGO1 0x100aa0a0 void ViewROI::SetLocalTransform(const Matrix4& p_transform) { - // TODO + OrientableROI::SetLocalTransform(p_transform); + if (geometry) { + Tgl::FloatMatrix4 matrix; + Matrix4 in(matrix); + SETMAT4(in, m_local2world); + geometry->SetTransformation(matrix); + } } -// STUB: LEGO1 0x100aa180 +// FUNCTION: LEGO1 0x100aa180 void ViewROI::VTable0x1c() { - // TODO + OrientableROI::VTable0x1c(); + if (geometry) { + Tgl::FloatMatrix4 matrix; + Matrix4 in(matrix); + SETMAT4(in, m_local2world); + geometry->SetTransformation(matrix); + } } // FUNCTION: LEGO1 0x100aa500