fixed some bugs

This commit is contained in:
aap 2017-10-04 22:08:26 +02:00
parent 017e86053a
commit f9668df80e
3 changed files with 9 additions and 11 deletions

View File

@ -601,7 +601,7 @@ Geometry::correctTristripWinding(void)
rwFree(header); rwFree(header);
// Now allocate indices and copy them // Now allocate indices and copy them
this->allocateMeshes(newhead->numMeshes, newhead->totalIndices, 0); 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); rwFree(indices);
} }
@ -623,14 +623,13 @@ Geometry::removeUnusedMaterials(void)
int32 numMaterials = 0; int32 numMaterials = 0;
/* Build new material list and map */ /* Build new material list and map */
for(uint32 i = 0; i < mh->numMeshes; i++){ for(uint32 i = 0; i < mh->numMeshes; i++){
if(m->numIndices <= 0) if(m[i].numIndices <= 0)
continue; continue;
materials[numMaterials] = m->material; materials[numMaterials] = m[i].material;
m->material->refCount++; m[i].material->refCount++;
int32 oldid = this->matList.findIndex(m->material); int32 oldid = this->matList.findIndex(m[i].material);
map[oldid] = numMaterials; map[oldid] = numMaterials;
numMaterials++; numMaterials++;
m++;
} }
for(int32 i = 0; i < this->matList.numMaterials; i++) for(int32 i = 0; i < this->matList.numMaterials; i++)
this->matList.materials[i]->destroy(); this->matList.materials[i]->destroy();
@ -644,7 +643,6 @@ Geometry::removeUnusedMaterials(void)
MeshHeader *newmh = this->allocateMeshes(numMaterials, mh->totalIndices, 0); MeshHeader *newmh = this->allocateMeshes(numMaterials, mh->totalIndices, 0);
newmh->flags = mh->flags; newmh->flags = mh->flags;
Mesh *newm = newmh->getMeshes(); Mesh *newm = newmh->getMeshes();
m = mh->getMeshes();
for(uint32 i = 0; i < mh->numMeshes; i++){ for(uint32 i = 0; i < mh->numMeshes; i++){
if(m[i].numIndices <= 0) if(m[i].numIndices <= 0)
continue; continue;
@ -655,7 +653,6 @@ Geometry::removeUnusedMaterials(void)
newmh->setupIndices(); newmh->setupIndices();
/* Copy indices */ /* Copy indices */
newm = newmh->getMeshes();; newm = newmh->getMeshes();;
m = mh->getMeshes();
for(uint32 i = 0; i < mh->numMeshes; i++){ for(uint32 i = 0; i < mh->numMeshes; i++){
if(m[i].numIndices <= 0) if(m[i].numIndices <= 0)
continue; continue;

View File

@ -42,6 +42,7 @@ Geometry::allocateMeshes(int32 numMeshes, uint32 numIndices, bool32 noIndices)
if(this->meshHeader){ if(this->meshHeader){
oldNumMeshes = this->meshHeader->numMeshes; oldNumMeshes = this->meshHeader->numMeshes;
mh = (MeshHeader*)rwResize(this->meshHeader, sz, MEMDUR_EVENT | ID_GEOMETRY); mh = (MeshHeader*)rwResize(this->meshHeader, sz, MEMDUR_EVENT | ID_GEOMETRY);
this->meshHeader = mh;
}else{ }else{
oldNumMeshes = 0; oldNumMeshes = 0;
mh = (MeshHeader*)rwNew(sz, MEMDUR_EVENT | ID_GEOMETRY); mh = (MeshHeader*)rwNew(sz, MEMDUR_EVENT | ID_GEOMETRY);

View File

@ -322,11 +322,11 @@ Draw(float timeDelta)
camera->update(); camera->update();
camera->m_rwcam->beginUpdate(); camera->m_rwcam->beginUpdate();
// Scene.clump->render(); Scene.clump->render();
// im2dtest(); // im2dtest();
// tlTest(Scene.clump); // tlTest(Scene.clump);
im3dtest(); // im3dtest();
printScreen("Hello, World!", 10, 10); // printScreen("Hello, World!", 10, 10);
camera->m_rwcam->endUpdate(); camera->m_rwcam->endUpdate();
camera->m_rwcam->showRaster(); camera->m_rwcam->showRaster();