mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
+ | Offset bvh in the parsing
This commit is contained in:
@ -240,7 +240,7 @@ void ObjParser::parseMtl(std::stringstream &input_line, Scene &scene)
|
||||
file.close();
|
||||
}
|
||||
|
||||
void ObjParser::parse(Scene &scene)
|
||||
void ObjParser::parse(Scene &scene, glm::vec3 offset)
|
||||
{
|
||||
std::string line;
|
||||
std::string identifier;
|
||||
@ -275,6 +275,6 @@ void ObjParser::parse(Scene &scene)
|
||||
}
|
||||
}
|
||||
|
||||
scene.addBvh(_triangles);
|
||||
scene.addBvh(_triangles, offset);
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ void Scene::addObject(Object *obj)
|
||||
_gpu_objects.push_back(gpu_obj);
|
||||
}
|
||||
|
||||
void Scene::addBvh(std::vector<Triangle> &triangles)
|
||||
void Scene::addBvh(std::vector<Triangle> &triangles, glm::vec3 offset)
|
||||
{
|
||||
GPUBvhData new_bvh_data;
|
||||
std::vector<GPUBvh> new_bvhs_list;
|
||||
@ -153,8 +153,9 @@ void Scene::addBvh(std::vector<Triangle> &triangles)
|
||||
|
||||
BVH *bvh = new BVH(triangles, 0, triangles.size());
|
||||
new_bvhs_list = bvh->getGPUBvhs();
|
||||
|
||||
new_bvh_data.offset = glm::vec3(0., 0., 0.);
|
||||
|
||||
std::cout << glm::to_string(offset) << std::endl;
|
||||
new_bvh_data.offset = offset;
|
||||
new_bvh_data.bvh_start_index = _gpu_bvh.size();
|
||||
new_bvh_data.triangle_start_index = _gpu_triangles.size();
|
||||
|
||||
|
@ -95,6 +95,20 @@ void SceneParser::parseCamera(std::stringstream &line)
|
||||
|
||||
}
|
||||
|
||||
void SceneParser::parseObj(std::stringstream &line)
|
||||
{
|
||||
std::string name;
|
||||
float x = 0.;
|
||||
float y = 0.;
|
||||
float z = 0.;
|
||||
|
||||
line >> name;
|
||||
line >> x >> y >> z;
|
||||
|
||||
ObjParser obj(name);
|
||||
obj.parse(*_scene, glm::vec3(x, y, z));
|
||||
}
|
||||
|
||||
bool SceneParser::parseLine(const std::string &line)
|
||||
{
|
||||
if (line.empty() || line[0] == '#')
|
||||
@ -128,11 +142,7 @@ bool SceneParser::parseLine(const std::string &line)
|
||||
else if (identifier == "CAM")
|
||||
this->parseCamera(ss);
|
||||
else if (identifier == "OBJ")
|
||||
{
|
||||
ss >> identifier;
|
||||
ObjParser obj(identifier);
|
||||
obj.parse(*_scene);
|
||||
}
|
||||
this->parseObj(ss);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user