SDLPP: make copySelf actually copy everything

This commit is contained in:
2020-12-18 16:02:02 +01:00
parent 67a56d31de
commit 20c30712b9
9 changed files with 36 additions and 3 deletions
+15
View File
@@ -104,4 +104,19 @@ std::shared_ptr< Renderer > RenderObject::getRenderer() const {
void RenderObject::setSceneID( int id ) {
scene_id = id;
}
void RenderObject::copyTo(std::shared_ptr<RenderObject> other) {
other->collisions.clear();
for ( auto &colider : collisions ) {
other->collisions.push_back(colider->copySelf());
}
other->texture.reset();
if ( texture ) {
other->texture = std::make_shared< Texture >( *texture );
}
other->polygon.reset();
if ( polygon ) {
other->polygon = polygon->copySelf();
}
other->colidedWith.clear();
}
} // namespace SDLPP