Duplicate works!

This commit is contained in:
andreja6
2018-10-21 16:11:31 -07:00
parent 1c9b93d6ab
commit 90e74e5133
4 changed files with 5 additions and 7 deletions

View File

@@ -16,9 +16,9 @@ Instance::Instance(void)
Instance::Instance(const Instance &oinst) Instance::Instance(const Instance &oinst)
{ {
parent = oinst.parent; setParent(oinst.parent);
name = oinst.name; name = oinst.name;
className = "BaseInstance"; className = oinst.className;
} }
void Instance::render(RenderDevice* rd) void Instance::render(RenderDevice* rd)

View File

@@ -18,7 +18,7 @@ public:
void addChild(Instance*); void addChild(Instance*);
void removeChild(Instance*); void removeChild(Instance*);
Instance* getParent(); Instance* getParent();
Instance* clone() const { return new Instance(*this); } virtual Instance* clone() const { return new Instance(*this); }
protected: protected:
std::string className; std::string className;
Instance* parent; // Another pointer. Instance* parent; // Another pointer.

View File

@@ -28,7 +28,7 @@ PhysicalInstance::PhysicalInstance(const PhysicalInstance &oinst)
name = oinst.name; name = oinst.name;
className = "Part"; className = "Part";
canCollide = oinst.canCollide; canCollide = oinst.canCollide;
setParent(oinst.parent);
anchored = oinst.anchored; anchored = oinst.anchored;
size = oinst.size; size = oinst.size;
setCFrame(oinst.cFrame); setCFrame(oinst.cFrame);

View File

@@ -252,9 +252,7 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
std::vector<Instance*> newinst; std::vector<Instance*> newinst;
for(size_t i = 0; i < selectedInstances.size(); i++) for(size_t i = 0; i < selectedInstances.size(); i++)
{ {
Instance* inst = selectedInstances.at(i)->clone(); newinst.push_back(selectedInstances.at(i)->clone());
newinst.push_back(inst);
inst->setParent(selectedInstances.at(i)->getParent());
} }
selectedInstances = newinst; selectedInstances = newinst;
} }