From f9668df80e3a9e941bdedbf1a61948154800acd1 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 4 Oct 2017 22:08:26 +0200 Subject: [PATCH] fixed some bugs --- src/geometry.cpp | 13 +++++-------- src/geoplg.cpp | 1 + tools/clumpview/main.cpp | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/geometry.cpp b/src/geometry.cpp index f678caa..356af89 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -601,7 +601,7 @@ Geometry::correctTristripWinding(void) rwFree(header); // Now allocate indices and copy them this->allocateMeshes(newhead->numMeshes, newhead->totalIndices, 0); - memcpy(this->meshHeader->getMeshes()->indices, indices, newhead->totalIndices*2); + memcpy(this->meshHeader->getMeshes()->indices, indices, this->meshHeader->totalIndices*2); rwFree(indices); } @@ -623,14 +623,13 @@ Geometry::removeUnusedMaterials(void) int32 numMaterials = 0; /* Build new material list and map */ for(uint32 i = 0; i < mh->numMeshes; i++){ - if(m->numIndices <= 0) + if(m[i].numIndices <= 0) continue; - materials[numMaterials] = m->material; - m->material->refCount++; - int32 oldid = this->matList.findIndex(m->material); + materials[numMaterials] = m[i].material; + m[i].material->refCount++; + int32 oldid = this->matList.findIndex(m[i].material); map[oldid] = numMaterials; numMaterials++; - m++; } for(int32 i = 0; i < this->matList.numMaterials; i++) this->matList.materials[i]->destroy(); @@ -644,7 +643,6 @@ Geometry::removeUnusedMaterials(void) MeshHeader *newmh = this->allocateMeshes(numMaterials, mh->totalIndices, 0); newmh->flags = mh->flags; Mesh *newm = newmh->getMeshes(); - m = mh->getMeshes(); for(uint32 i = 0; i < mh->numMeshes; i++){ if(m[i].numIndices <= 0) continue; @@ -655,7 +653,6 @@ Geometry::removeUnusedMaterials(void) newmh->setupIndices(); /* Copy indices */ newm = newmh->getMeshes();; - m = mh->getMeshes(); for(uint32 i = 0; i < mh->numMeshes; i++){ if(m[i].numIndices <= 0) continue; diff --git a/src/geoplg.cpp b/src/geoplg.cpp index 2083b23..7b2abda 100644 --- a/src/geoplg.cpp +++ b/src/geoplg.cpp @@ -42,6 +42,7 @@ Geometry::allocateMeshes(int32 numMeshes, uint32 numIndices, bool32 noIndices) if(this->meshHeader){ oldNumMeshes = this->meshHeader->numMeshes; mh = (MeshHeader*)rwResize(this->meshHeader, sz, MEMDUR_EVENT | ID_GEOMETRY); + this->meshHeader = mh; }else{ oldNumMeshes = 0; mh = (MeshHeader*)rwNew(sz, MEMDUR_EVENT | ID_GEOMETRY); diff --git a/tools/clumpview/main.cpp b/tools/clumpview/main.cpp index e0eaa72..cc069d1 100644 --- a/tools/clumpview/main.cpp +++ b/tools/clumpview/main.cpp @@ -322,11 +322,11 @@ Draw(float timeDelta) camera->update(); camera->m_rwcam->beginUpdate(); -// Scene.clump->render(); + Scene.clump->render(); // im2dtest(); // tlTest(Scene.clump); - im3dtest(); - printScreen("Hello, World!", 10, 10); +// im3dtest(); +// printScreen("Hello, World!", 10, 10); camera->m_rwcam->endUpdate(); camera->m_rwcam->showRaster();