+ | Portal matrices reflection

This commit is contained in:
TheRedShip
2025-01-08 12:07:26 +01:00
parent fe440958dc
commit 8e4d844f38
8 changed files with 113 additions and 68 deletions

View File

@ -70,7 +70,7 @@ void Scene::updateGPUData()
_gpu_objects.clear();
_gpu_materials.clear();
for (int i = 0; i < _objects.size(); i++)
for (unsigned int i = 0; i < _objects.size(); i++)
{
Object *obj = _objects[i];
@ -115,13 +115,18 @@ void Scene::updateGPUData()
gpu_obj.vertex2 = portal->getEdge2();
gpu_obj.normal = portal->getNormal();
gpu_obj.transform = glm::mat4(portal->getTransform());
gpu_obj.radius = i + 2;
if (_objects[i - 2]->getType() == Object::Type::PORTAL)
gpu_obj.radius = i - 2;
Portal *linked = static_cast<Portal *>(_objects[i - 2]);
Quad *quad = portal->createSupportQuad();
_objects.push_back(quad);
if (portal->getLinkedPortalIndex() == -1)
{
if (linked->getType() == Object::Type::PORTAL && linked->getLinkedPortalIndex() == static_cast<int>(i))
portal->setLinkedPortalIndex(i - 2);
else
portal->setLinkedPortalIndex(i + 2);
}
gpu_obj.radius = portal->getLinkedPortalIndex();
}
_gpu_objects.push_back(gpu_obj);

View File

@ -111,6 +111,9 @@ bool SceneParser::parseLine(const std::string &line)
Object *obj = it->second(ss);
(void) _scene->getMaterial(obj->getMaterialIndex()); //verify material
if (obj->getType() == Object::Type::PORTAL)
_scene->addObject(static_cast<Portal *>(obj)->createSupportQuad());
_scene->addObject(obj);
}