mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
+ | Multiple sphere sent to GPU working
This commit is contained in:
@ -19,10 +19,43 @@ Scene::Scene()
|
||||
|
||||
Scene::~Scene()
|
||||
{
|
||||
delete _camera;
|
||||
delete (_camera);
|
||||
}
|
||||
|
||||
Camera *Scene::getCamera(void) const
|
||||
{
|
||||
return (_camera);
|
||||
}
|
||||
|
||||
void Scene::addObject(std::unique_ptr<Object> object)
|
||||
{
|
||||
_objects.push_back(std::move(object));
|
||||
|
||||
this->updateGPUData();
|
||||
}
|
||||
|
||||
void Scene::updateGPUData()
|
||||
{
|
||||
_gpuObjects.clear();
|
||||
for (const auto& obj : _objects)
|
||||
{
|
||||
GPUObject gpuObj;
|
||||
gpuObj.position = obj->getPosition();
|
||||
gpuObj.color = obj->getMaterial().color;
|
||||
gpuObj.roughness = obj->getMaterial().roughness;
|
||||
gpuObj.specular = obj->getMaterial().specular;
|
||||
gpuObj.type = static_cast<int>(obj->getType());
|
||||
|
||||
if (obj->getType() == Object::Type::SPHERE) {
|
||||
auto sphere = static_cast<const Sphere*>(obj.get());
|
||||
gpuObj.radius = sphere->getRadius();
|
||||
}
|
||||
|
||||
_gpuObjects.push_back(gpuObj);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<GPUObject>& Scene::getGPUData() const
|
||||
{
|
||||
return (_gpuObjects);
|
||||
}
|
Reference in New Issue
Block a user