Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed scene and cleanup xxx_model names #1031

Merged
merged 8 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions apps/ysceneitrace/ysceneitrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using namespace yocto;
#include <deque>

namespace yocto {
void print_obj_camera(scene_camera* camera);
void print_obj_camera(sceneio_camera* camera);
}; // namespace yocto

// Application scene
Expand All @@ -51,10 +51,10 @@ struct app_state {
string name = "";

// scene
scene_model* ioscene = new scene_model{};
trace_scene* scene = new trace_scene{};
scene_camera* iocamera = nullptr;
trace_camera* camera = nullptr;
sceneio_scene* ioscene = new sceneio_scene{};
trace_scene* scene = new trace_scene{};
sceneio_camera* iocamera = nullptr;
trace_camera* camera = nullptr;

// options
trace_params params = {};
Expand All @@ -69,12 +69,12 @@ struct app_state {
ogl_image_params glparams = {};

// editing
scene_camera* selected_camera = nullptr;
scene_instance* selected_instance = nullptr;
scene_shape* selected_shape = nullptr;
scene_material* selected_material = nullptr;
scene_environment* selected_environment = nullptr;
scene_texture* selected_texture = nullptr;
sceneio_camera* selected_camera = nullptr;
sceneio_instance* selected_instance = nullptr;
sceneio_shape* selected_shape = nullptr;
sceneio_material* selected_material = nullptr;
sceneio_environment* selected_environment = nullptr;
sceneio_texture* selected_texture = nullptr;

// computation
int render_sample = 0;
Expand Down Expand Up @@ -119,15 +119,16 @@ struct app_states {
};

// Construct a scene from io
void init_scene(trace_scene* scene, scene_model* ioscene, trace_camera*& camera,
scene_camera* iocamera, progress_callback progress_cb = {}) {
void init_scene(trace_scene* scene, sceneio_scene* ioscene,
trace_camera*& camera, sceneio_camera* iocamera,
progress_callback progress_cb = {}) {
// handle progress
auto progress = vec2i{
0, (int)ioscene->cameras.size() + (int)ioscene->environments.size() +
(int)ioscene->materials.size() + (int)ioscene->textures.size() +
(int)ioscene->shapes.size() + (int)ioscene->instances.size()};

auto camera_map = unordered_map<scene_camera*, trace_camera*>{};
auto camera_map = unordered_map<sceneio_camera*, trace_camera*>{};
camera_map[nullptr] = nullptr;
for (auto iocamera : ioscene->cameras) {
if (progress_cb)
Expand All @@ -140,7 +141,7 @@ void init_scene(trace_scene* scene, scene_model* ioscene, trace_camera*& camera,
camera_map[iocamera] = camera;
}

auto texture_map = unordered_map<scene_texture*, trace_texture*>{};
auto texture_map = unordered_map<sceneio_texture*, trace_texture*>{};
texture_map[nullptr] = nullptr;
for (auto iotexture : ioscene->textures) {
if (progress_cb)
Expand All @@ -154,7 +155,7 @@ void init_scene(trace_scene* scene, scene_model* ioscene, trace_camera*& camera,
texture_map[iotexture] = texture;
}

auto material_map = unordered_map<scene_material*, trace_material*>{};
auto material_map = unordered_map<sceneio_material*, trace_material*>{};
material_map[nullptr] = nullptr;
for (auto iomaterial : ioscene->materials) {
if (progress_cb)
Expand Down Expand Up @@ -184,7 +185,7 @@ void init_scene(trace_scene* scene, scene_model* ioscene, trace_camera*& camera,
material_map[iomaterial] = material;
}

auto shape_map = unordered_map<scene_shape*, trace_shape*>{};
auto shape_map = unordered_map<sceneio_shape*, trace_shape*>{};
shape_map[nullptr] = nullptr;
for (auto ioshape : ioscene->shapes) {
if (progress_cb) progress_cb("converting shapes", progress.x++, progress.y);
Expand Down Expand Up @@ -297,7 +298,7 @@ void load_scene_async(app_states* apps, const string& filename,
}

bool draw_widgets(
gui_window* win, scene_model* ioscene, scene_camera* iocamera) {
gui_window* win, sceneio_scene* ioscene, sceneio_camera* iocamera) {
if (!iocamera) return false;
auto edited = 0;
draw_label(win, "name", iocamera->name);
Expand All @@ -323,7 +324,7 @@ bool draw_widgets(
}

bool draw_widgets(
gui_window* win, scene_model* ioscene, scene_texture* iotexture) {
gui_window* win, sceneio_scene* ioscene, sceneio_texture* iotexture) {
if (!iotexture) return false;
auto edited = 0;
draw_label(win, "name", iotexture->name);
Expand All @@ -338,7 +339,7 @@ bool draw_widgets(
}

bool draw_widgets(
gui_window* win, scene_model* ioscene, scene_material* iomaterial) {
gui_window* win, sceneio_scene* ioscene, sceneio_material* iomaterial) {
if (!iomaterial) return false;
auto edited = 0;
draw_label(win, "name", iomaterial->name);
Expand Down Expand Up @@ -381,7 +382,8 @@ bool draw_widgets(
return edited;
}

bool draw_widgets(gui_window* win, scene_model* ioscene, scene_shape* ioshape) {
bool draw_widgets(
gui_window* win, sceneio_scene* ioscene, sceneio_shape* ioshape) {
if (!ioshape) return false;
auto edited = 0;
draw_label(win, "name", ioshape->name);
Expand All @@ -408,7 +410,7 @@ bool draw_widgets(gui_window* win, scene_model* ioscene, scene_shape* ioshape) {
}

bool draw_widgets(
gui_window* win, scene_model* ioscene, scene_instance* ioobject) {
gui_window* win, sceneio_scene* ioscene, sceneio_instance* ioobject) {
if (!ioobject) return false;
auto edited = 0;
draw_label(win, "name", ioobject->name);
Expand All @@ -422,8 +424,8 @@ bool draw_widgets(
return edited;
}

bool draw_widgets(
gui_window* win, scene_model* ioscene, scene_environment* ioenvironment) {
bool draw_widgets(gui_window* win, sceneio_scene* ioscene,
sceneio_environment* ioenvironment) {
if (!ioenvironment) return false;
auto edited = 0;
draw_label(win, "name", ioenvironment->name);
Expand Down Expand Up @@ -554,7 +556,7 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) {
}
end_header(win);
}
auto get_texture = [app](scene_texture* iotexture) {
auto get_texture = [app](sceneio_texture* iotexture) {
return get_element(iotexture, app->ioscene->textures, app->scene->textures);
};
if (!app->ioscene->cameras.empty() && begin_header(win, "cameras")) {
Expand Down Expand Up @@ -812,8 +814,7 @@ int main(int argc, const char* argv[]) {
auto ray = camera_ray(app->camera->frame, app->camera->lens,
app->camera->lens, app->camera->film,
vec2f{ij.x + 0.5f, ij.y + 0.5f} /
vec2f{(float)app->render.width(),
(float)app->render.height()});
vec2f{(float)app->render.width(), (float)app->render.height()});
if (auto isec = intersect_scene_bvh(app->scene, ray); isec.hit) {
app->selected_instance = app->ioscene->instances[isec.instance];
}
Expand Down
15 changes: 8 additions & 7 deletions apps/ysceneitraces/ysceneitraces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,16 @@ void reset_display(app_state* app) {
}

// Construct a scene from io
void init_scene(trace_scene* scene, scene_model* ioscene, trace_camera*& camera,
scene_camera* iocamera, progress_callback progress_cb = {}) {
void init_scene(trace_scene* scene, sceneio_scene* ioscene,
trace_camera*& camera, sceneio_camera* iocamera,
progress_callback progress_cb = {}) {
// handle progress
auto progress = vec2i{
0, (int)ioscene->cameras.size() + (int)ioscene->environments.size() +
(int)ioscene->materials.size() + (int)ioscene->textures.size() +
(int)ioscene->shapes.size() + (int)ioscene->instances.size()};

auto camera_map = unordered_map<scene_camera*, trace_camera*>{};
auto camera_map = unordered_map<sceneio_camera*, trace_camera*>{};
camera_map[nullptr] = nullptr;
for (auto iocamera : ioscene->cameras) {
if (progress_cb)
Expand All @@ -127,7 +128,7 @@ void init_scene(trace_scene* scene, scene_model* ioscene, trace_camera*& camera,
camera_map[iocamera] = camera;
}

auto texture_map = unordered_map<scene_texture*, trace_texture*>{};
auto texture_map = unordered_map<sceneio_texture*, trace_texture*>{};
texture_map[nullptr] = nullptr;
for (auto iotexture : ioscene->textures) {
if (progress_cb)
Expand All @@ -141,7 +142,7 @@ void init_scene(trace_scene* scene, scene_model* ioscene, trace_camera*& camera,
texture_map[iotexture] = texture;
}

auto material_map = unordered_map<scene_material*, trace_material*>{};
auto material_map = unordered_map<sceneio_material*, trace_material*>{};
material_map[nullptr] = nullptr;
for (auto iomaterial : ioscene->materials) {
if (progress_cb)
Expand Down Expand Up @@ -171,7 +172,7 @@ void init_scene(trace_scene* scene, scene_model* ioscene, trace_camera*& camera,
material_map[iomaterial] = material;
}

auto shape_map = unordered_map<scene_shape*, trace_shape*>{};
auto shape_map = unordered_map<sceneio_shape*, trace_shape*>{};
shape_map[nullptr] = nullptr;
for (auto ioshape : ioscene->shapes) {
if (progress_cb) progress_cb("converting shapes", progress.x++, progress.y);
Expand Down Expand Up @@ -251,7 +252,7 @@ int main(int argc, const char* argv[]) {
parse_cli(cli, argc, argv);

// scene loading
auto ioscene_guard = std::make_unique<scene_model>();
auto ioscene_guard = std::make_unique<sceneio_scene>();
auto ioscene = ioscene_guard.get();
auto ioerror = ""s;
if (!load_scene(app->filename, ioscene, ioerror, print_progress))
Expand Down
Loading