don't copy the model list. It can be very big - using pointer now,
garbage is not from the texture or object changes
This commit is contained in:
@@ -109,37 +109,42 @@ void OpenGLController::processInit()
|
||||
|
||||
void OpenGLController::deleteVectors()
|
||||
{
|
||||
while (!vModels.empty())
|
||||
if (vModels != NULL)
|
||||
{
|
||||
Modl* cursor = vModels.back();
|
||||
vModels.pop_back();
|
||||
|
||||
while (!cursor->segmLst.empty())
|
||||
while (!vModels->empty())
|
||||
{
|
||||
Segment* segmCuror = cursor->segmLst.back();
|
||||
cursor->segmLst.pop_back();
|
||||
Modl* cursor = vModels->back();
|
||||
vModels->pop_back();
|
||||
|
||||
delete segmCuror->uv;
|
||||
delete segmCuror->vertex;
|
||||
|
||||
while (!segmCuror->meshIndices.empty())
|
||||
while (!cursor->segmLst.empty())
|
||||
{
|
||||
std::vector<std::uint32_t>* meshCursor = segmCuror->meshIndices.back();
|
||||
meshCursor->clear();
|
||||
segmCuror->meshIndices.pop_back();
|
||||
delete meshCursor;
|
||||
Segment* segmCuror = cursor->segmLst.back();
|
||||
cursor->segmLst.pop_back();
|
||||
|
||||
delete segmCuror->uv;
|
||||
delete segmCuror->vertex;
|
||||
|
||||
while (!segmCuror->meshIndices.empty())
|
||||
{
|
||||
std::vector<std::uint32_t>* meshCursor = segmCuror->meshIndices.back();
|
||||
meshCursor->clear();
|
||||
segmCuror->meshIndices.pop_back();
|
||||
delete meshCursor;
|
||||
}
|
||||
|
||||
delete segmCuror;
|
||||
}
|
||||
|
||||
delete segmCuror;
|
||||
delete cursor;
|
||||
}
|
||||
|
||||
delete cursor;
|
||||
delete vModels;
|
||||
}
|
||||
|
||||
while (!vTextures.empty())
|
||||
{
|
||||
textureData* cursor = vTextures.back();
|
||||
vTextures.pop_back();
|
||||
cursor->data->clear();
|
||||
delete cursor->data;
|
||||
delete cursor;
|
||||
}
|
||||
@@ -207,16 +212,16 @@ glm::mat4 OpenGLController::getModelMatrix(unsigned int index)
|
||||
{
|
||||
glm::mat4 tempParentMatrix = glm::mat4(1.0f);
|
||||
|
||||
for (unsigned int loop = 0; loop < vModels.size(); loop++)
|
||||
for (unsigned int loop = 0; loop < vModels->size(); loop++)
|
||||
{
|
||||
if (!strcmp(vModels[index]->parent.c_str(), vModels[loop]->name.c_str()))
|
||||
if (!strcmp(vModels->at(index)->parent.c_str(), vModels->at(loop)->name.c_str()))
|
||||
{
|
||||
tempParentMatrix = getModelMatrix(loop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tempParentMatrix * vModels[index]->m4x4Translation;
|
||||
return tempParentMatrix * vModels->at(index)->m4x4Translation;
|
||||
}
|
||||
|
||||
glm::mat4 OpenGLController::getMVPMatrix(unsigned int index)
|
||||
@@ -311,16 +316,16 @@ void OpenGLController::updateScene()
|
||||
|
||||
int instanceOffset(0);
|
||||
|
||||
for (unsigned int modelIndex = 0; modelIndex < vModels.size(); modelIndex++)
|
||||
for (unsigned int modelIndex = 0; modelIndex < vModels->size(); modelIndex++)
|
||||
{
|
||||
// skip null, bones, shadowMesh, hidden things (don't increase textrue index!!)
|
||||
if (vModels[modelIndex]->type == null ||
|
||||
vModels[modelIndex]->type == bone ||
|
||||
vModels[modelIndex]->type == shadowMesh ||
|
||||
vModels[modelIndex]->renderFlags == 1)
|
||||
if (vModels->at(modelIndex)->type == null ||
|
||||
vModels->at(modelIndex)->type == bone ||
|
||||
vModels->at(modelIndex)->type == shadowMesh ||
|
||||
vModels->at(modelIndex)->renderFlags == 1)
|
||||
continue;
|
||||
|
||||
for (auto& segIt : vModels[modelIndex]->segmLst)
|
||||
for (auto& segIt : vModels->at(modelIndex)->segmLst)
|
||||
{
|
||||
// give texture to the shader
|
||||
std::uint32_t tempTexIndex = segIt->textureIndex >= vTextures.size() ? vTextures.size() - 1 : segIt->textureIndex;
|
||||
@@ -382,7 +387,7 @@ void OpenGLController::loadMsh(const char * path)
|
||||
// collect vertex data of all models
|
||||
std::vector<Vertex> tempBufferData;
|
||||
|
||||
for (auto& modIt : vModels) // for every model chunk
|
||||
for (auto& modIt : *vModels) // for every model chunk
|
||||
{
|
||||
for (auto& segIt : modIt->segmLst) // for every cluster
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user