Tried to fix clearing children but failed miserably

This commit is contained in:
Vulpovile
2021-03-14 13:43:12 -07:00
parent 2a6d90ad66
commit 816a67a40b
6 changed files with 17 additions and 11 deletions

View File

@@ -216,7 +216,7 @@ void renderShape(const Enum::Shape::Value& shape, const Vector3& size, const Col
glPopMatrix(); glPopMatrix();
/*Plusses, can possibly integrate into cylinder code later on*/ /*Plusses, can possibly integrate into cylinder code later on*/
glVertexPointer(2, GL_FLOAT,0, square_arr); glVertexPointer(2, GL_FLOAT,0, square_arr);
glColor(Color3(127,127,127)); glColor3f(127,127,127);
glPushMatrix(); glPushMatrix();
glRotatef(90,0,1,0); glRotatef(90,0,1,0);
glTranslatef(0,0,-(size.z+0.001F)); glTranslatef(0,0,-(size.z+0.001F));

View File

@@ -8,5 +8,6 @@ class WorkspaceInstance :
public: public:
WorkspaceInstance(void); WorkspaceInstance(void);
~WorkspaceInstance(void); ~WorkspaceInstance(void);
void clearChildren();
std::vector<PartInstance *> partObjects; std::vector<PartInstance *> partObjects;
}; };

View File

@@ -6,6 +6,8 @@
#include <sstream> #include <sstream>
#include <commdlg.h> #include <commdlg.h>
#include "ErrorFunctions.h" #include "ErrorFunctions.h"
#include "Globals.h"
#include "Application.h"
using namespace std; using namespace std;
using namespace rapidxml; using namespace rapidxml;
@@ -60,6 +62,7 @@ void DataModelInstance::modXMLLevel(float modY)
void DataModelInstance::clearLevel() void DataModelInstance::clearLevel()
{ {
workspace->clearChildren(); workspace->clearChildren();
g_usableApp->_propWindow->UpdateSelected(this);
} }
PartInstance* DataModelInstance::makePart() PartInstance* DataModelInstance::makePart()
{ {

View File

@@ -140,6 +140,10 @@ void Instance::addChild(Instance* newChild)
void Instance::clearChildren() void Instance::clearChildren()
{ {
for (size_t i = 0; i < children.size(); i++)
{
delete children.at(i);
}
children.clear(); children.clear();
} }
void Instance::removeChild(Instance* oldChild) void Instance::removeChild(Instance* oldChild)

View File

@@ -245,19 +245,11 @@ bool PartInstance::collides(Box box)
void PartInstance::render(RenderDevice* rd) { void PartInstance::render(RenderDevice* rd) {
if (changed) if (changed)
{ {
changed=false;
Vector3 renderSize = size/2; Vector3 renderSize = size/2;
glNewList(glList, GL_COMPILE);
glNewList(glList, GL_COMPILE_AND_EXECUTE);
glColor(this->color);
renderShape(this->shape, renderSize, color); renderShape(this->shape, renderSize, color);
glEndList(); glEndList();
changed = false;
return;
changed=false;
} }
rd->setObjectToWorldMatrix(cFrame); rd->setObjectToWorldMatrix(cFrame);
glCallList(glList); glCallList(glList);

View File

@@ -9,6 +9,12 @@ WorkspaceInstance::WorkspaceInstance(void)
canDelete = false; canDelete = false;
} }
void WorkspaceInstance::clearChildren()
{
children.clear();
Instance::clearChildren();
}
WorkspaceInstance::~WorkspaceInstance(void) WorkspaceInstance::~WorkspaceInstance(void)
{ {
} }