Make geometry list store pointers
This commit is contained in:
@@ -68,7 +68,7 @@ public:
|
||||
Camera* getActiveCamera();
|
||||
|
||||
std::string name;
|
||||
std::vector<VertexArray> geometryList; //TODO store this as pointers.
|
||||
std::vector<VertexArray*> geometryList;
|
||||
std::vector<Texture*> textureList;
|
||||
std::vector<Shader> shaderList;
|
||||
|
||||
|
@@ -68,11 +68,11 @@ VertexArray* Entity::getGeometry() {
|
||||
if (engine->world->geometryList.empty())
|
||||
loadGeometry();
|
||||
for (auto& vArray : engine->world->geometryList)
|
||||
for (auto& entity : vArray.usedBy)
|
||||
for (auto& entity : vArray->usedBy)
|
||||
if (instanceOf(this, entity)) {
|
||||
if (std::find(vArray.usedBy.begin(), vArray.usedBy.end(), this) == vArray.usedBy.end()) //If this is the first time the entity is using it.
|
||||
vArray.usedBy.push_back(this);
|
||||
return &vArray;
|
||||
if (std::find(vArray->usedBy.begin(), vArray->usedBy.end(), this) == vArray->usedBy.end()) //If this is the first time the entity is using it.
|
||||
vArray->usedBy.push_back(this);
|
||||
return vArray;
|
||||
}
|
||||
loadGeometry();
|
||||
return getGeometry();
|
||||
|
@@ -95,7 +95,7 @@ void VertexArray::erase() const {
|
||||
engine->setError(ENGINE_ERROR_CODE::VERTEX_ARRAY_ERASED_WHILE_IN_USE, false);
|
||||
|
||||
for (int i = 0; i < engine->world->geometryList.size(); i++)
|
||||
if (&engine->world->geometryList[i] == this)
|
||||
if (engine->world->geometryList[i] == this)
|
||||
engine->world->geometryList.erase(engine->world->geometryList.begin() + i);
|
||||
delete this;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ VertexArray::VertexArray(Entity* entity, const std::string& filename, bool store
|
||||
load(filename);
|
||||
usedBy.push_back(entity);
|
||||
if (storeOnGeometryList)
|
||||
engine->world->geometryList.push_back(*this);
|
||||
engine->world->geometryList.push_back(new VertexArray(*this));
|
||||
}
|
||||
|
||||
OBB VertexArray::getCachedOBB(const Matrix3x3& rotationMatrix) const {
|
||||
|
Reference in New Issue
Block a user