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

Better names for scene elements. #1240

Merged
merged 12 commits into from
Jun 9, 2021
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
10 changes: 5 additions & 5 deletions apps/yimage/yimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void add_command(const cli_command& cli, const string& name,
// convert images
int run_convert(const convert_params& params) {
// load
auto image = color_image{};
auto image = image_data{};
auto ioerror = string{};
if (!load_image(params.image, image, ioerror)) return print_fatal(ioerror);

Expand Down Expand Up @@ -110,7 +110,7 @@ int run_view(const view_params& params) {
// view images
int run_view(const view_params& params) {
// load
auto images = vector<color_image>(params.images.size());
auto images = vector<image_data>(params.images.size());
for (auto idx = 0; idx < (int)params.images.size(); idx++) {
auto ioerror = string{};
if (!load_image(params.images[idx], images[idx], ioerror))
Expand Down Expand Up @@ -152,7 +152,7 @@ int run_grade(const grade_params& params) {
// grade images
int run_grade(const grade_params& params) {
// load image
auto image = color_image{};
auto image = image_data{};
auto ioerror = string{};
if (!load_image(params.image, image, ioerror)) return print_fatal(ioerror);

Expand Down Expand Up @@ -189,7 +189,7 @@ void add_command(const cli_command& cli, const string& name,
int run_diff(const diff_params& params) {
// load
auto ioerror = string{};
auto image1 = color_image{}, image2 = color_image{};
auto image1 = image_data{}, image2 = image_data{};
if (!load_image(params.image1, image1, ioerror)) return false;
if (!load_image(params.image2, image2, ioerror)) return false;

Expand Down Expand Up @@ -253,7 +253,7 @@ void add_command(const cli_command& cli, const string& name,
int run_setalpha(const setalpha_params& params) {
// load
auto ioerror = string{};
auto image = color_image{}, alpha = color_image{};
auto image = image_data{}, alpha = image_data{};
if (!load_image(params.image, image, ioerror)) return print_fatal(ioerror);
if (!load_image(params.alpha, alpha, ioerror)) return print_fatal(ioerror);

Expand Down
76 changes: 38 additions & 38 deletions apps/ymesh/ymesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int run_view(const view_params& params) {
// view shapes
int run_view(const view_params& params) {
// load mesh
auto shape = scene_shape{};
auto shape = shape_data{};
auto ioerror = ""s;
if (path_filename(params.shape) == ".ypreset") {
if (!make_shape_preset(shape, path_basename(params.shape), ioerror))
Expand Down Expand Up @@ -110,7 +110,7 @@ int run_glview(const glview_params& params) {

#else

static scene_model make_shapescene(const scene_shape& ioshape_) {
static scene_data make_shapescene(const shape_data& ioshape_) {
// Frame camera
auto camera_frame = [](float lens, float aspect,
float film = 0.036) -> frame3f {
Expand All @@ -121,7 +121,7 @@ static scene_model make_shapescene(const scene_shape& ioshape_) {
};

// init scene
auto scene = scene_model{};
auto scene = scene_data{};

// rescale shape to unit
auto ioshape = ioshape_;
Expand All @@ -141,7 +141,7 @@ static scene_model make_shapescene(const scene_shape& ioshape_) {

// material
auto& shape_material = scene.materials.emplace_back();
shape_material.type = scene_material_type::glossy;
shape_material.type = material_type::glossy;
shape_material.color = {0.5, 1, 0.5};
shape_material.roughness = 0.2;

Expand All @@ -160,7 +160,7 @@ static scene_model make_shapescene(const scene_shape& ioshape_) {
int run_glview(const glview_params& params) {
// loading shape
auto ioerror = ""s;
auto shape = scene_shape{};
auto shape = shape_data{};
if (!load_shape(params.shape, shape, ioerror, true)) print_fatal(ioerror);

// create scene
Expand Down Expand Up @@ -195,7 +195,7 @@ int run_glpath(const glpath_params& params) {

#else

static scene_model make_pathscene(const scene_shape& ioshape_) {
static scene_data make_pathscene(const shape_data& ioshape_) {
// Frame camera
auto camera_frame = [](float lens, float aspect,
float film = 0.036) -> frame3f {
Expand All @@ -206,7 +206,7 @@ static scene_model make_pathscene(const scene_shape& ioshape_) {
};

// init scene
auto scene = scene_model{};
auto scene = scene_data{};

// rescale shape to unit
auto ioshape = ioshape_;
Expand All @@ -226,15 +226,15 @@ static scene_model make_pathscene(const scene_shape& ioshape_) {

// material
auto& shape_material = scene.materials.emplace_back();
shape_material.type = scene_material_type::glossy;
shape_material.type = material_type::glossy;
shape_material.color = {0.5, 1, 0.5};
shape_material.roughness = 0.2;
auto& points_material = scene.materials.emplace_back();
points_material.type = scene_material_type::glossy;
points_material.type = material_type::glossy;
points_material.color = {1, 0.5, 0.5};
points_material.roughness = 0.2;
auto& lines_material = scene.materials.emplace_back();
lines_material.type = scene_material_type::glossy;
lines_material.type = material_type::glossy;
lines_material.color = {0.5, 0.5, 1};
lines_material.roughness = 0.2;

Expand All @@ -261,7 +261,7 @@ static scene_model make_pathscene(const scene_shape& ioshape_) {
int run_glpath(const glpath_params& params) {
// loading shape
auto ioerror = ""s;
auto ioshape = scene_shape{};
auto ioshape = shape_data{};
if (!load_shape(params.shape, ioshape, ioerror, true)) print_fatal(ioerror);
if (!ioshape.quads.empty()) {
ioshape.triangles = quads_to_triangles(ioshape.quads);
Expand Down Expand Up @@ -372,7 +372,7 @@ int run_glpathd(const glpathd_params& params) {

#else

static scene_model make_pathdscene(const scene_shape& ioshape) {
static scene_data make_pathdscene(const shape_data& ioshape) {
// Frame camera
auto camera_frame = [](float lens, float aspect,
float film = 0.036) -> frame3f {
Expand All @@ -383,7 +383,7 @@ static scene_model make_pathdscene(const scene_shape& ioshape) {
};

// init scene
auto scene = scene_model{};
auto scene = scene_data{};

// camera
auto& camera = scene.cameras.emplace_back();
Expand All @@ -395,26 +395,26 @@ static scene_model make_pathdscene(const scene_shape& ioshape) {

// material
auto& shape_material = scene.materials.emplace_back();
shape_material.type = scene_material_type::glossy;
shape_material.type = material_type::glossy;
shape_material.color = {0.5, 1, 0.5};
shape_material.roughness = 0.2;
auto& points_material = scene.materials.emplace_back();
points_material.type = scene_material_type::matte;
points_material.type = material_type::matte;
points_material.color = {1, 0.5, 0.5};
auto& lines1_material = scene.materials.emplace_back();
lines1_material.type = scene_material_type::matte;
lines1_material.type = material_type::matte;
lines1_material.color = {0.5, 0.5, 1};
auto& lines2_material = scene.materials.emplace_back();
lines2_material.type = scene_material_type::matte;
lines2_material.type = material_type::matte;
lines2_material.color = {1, 1, 0.5};
auto& lines3_material = scene.materials.emplace_back();
lines3_material.type = scene_material_type::matte;
lines3_material.type = material_type::matte;
lines3_material.color = {1, 0.5, 1};
auto& lines4_material = scene.materials.emplace_back();
lines4_material.type = scene_material_type::matte;
lines4_material.type = material_type::matte;
lines4_material.color = {0.5, 0.5, 0.5};
auto& edges_material = scene.materials.emplace_back();
edges_material.type = scene_material_type::matte;
edges_material.type = material_type::matte;
edges_material.color = {0, 0, 0};

// shapes
Expand Down Expand Up @@ -467,7 +467,7 @@ static scene_model make_pathdscene(const scene_shape& ioshape) {
int run_glpathd(const glpathd_params& params) {
// loading shape
auto ioerror = ""s;
auto ioshape = scene_shape{};
auto ioshape = shape_data{};
if (!load_shape(params.shape, ioshape, ioerror, true)) print_fatal(ioerror);
if (!ioshape.quads.empty()) {
ioshape.triangles = quads_to_triangles(ioshape.quads);
Expand Down Expand Up @@ -630,18 +630,18 @@ struct sculpt_state {
vector<vector<int>> adjacencies = {};
geodesic_solver solver = {};
// brush
scene_texture tex_image = {};
texture_data tex_image = {};
// stroke
vector<shape_point> stroke = {};
vec2f last_uv = {};
bool instroke = false;
// shape at the beginning of the stroke
scene_shape base_shape = {};
shape_data base_shape = {};
};

// Initialize all sculpting parameters.
sculpt_state make_sculpt_state(
const scene_shape& shape, const scene_texture& texture) {
const shape_data& shape, const texture_data& texture) {
auto state = sculpt_state{};
state.bvh = make_triangles_bvh(
shape.triangles, shape.positions, shape.radius);
Expand All @@ -656,7 +656,7 @@ sculpt_state make_sculpt_state(
return state;
}

scene_shape make_circle(
shape_data make_circle(
const vec3f& center, const mat3f& basis, float radius, int steps) {
// 4 initial vertices
auto lines = make_lines({1, 4});
Expand Down Expand Up @@ -703,8 +703,8 @@ scene_shape make_circle(
}

// To visualize mouse intersection on mesh
scene_shape make_cursor(const vec3f& position, const vec3f& normal,
float radius, float height = 0.05f) {
shape_data make_cursor(const vec3f& position, const vec3f& normal, float radius,
float height = 0.05f) {
auto basis = basis_fromz(normal);
auto cursor = make_circle(position, basis, radius, 32);
cursor.normals.clear();
Expand Down Expand Up @@ -931,7 +931,7 @@ bool gaussian_brush(vector<vec3f>& positions, const hash_grid& grid,

// Compute texture values through the parameterization
bool texture_brush(vector<vec3f>& positions, vector<vec2f>& texcoords,
const geodesic_solver& solver, const scene_texture& texture,
const geodesic_solver& solver, const texture_data& texture,
const vector<vec3i>& triangles, const vector<vec3f>& base_positions,
const vector<vec3f>& base_normals, const vector<shape_point>& stroke,
const sculpt_params& params) {
Expand Down Expand Up @@ -1087,7 +1087,7 @@ bool smooth_brush(vector<vec3f>& positions, const geodesic_solver& solver,
return true;
}

static scene_model make_sculptscene(const scene_shape& ioshape_) {
static scene_data make_sculptscene(const shape_data& ioshape_) {
// Frame camera
auto camera_frame = [](float lens, float aspect,
float film = 0.036) -> frame3f {
Expand All @@ -1098,7 +1098,7 @@ static scene_model make_sculptscene(const scene_shape& ioshape_) {
};

// init scene
auto scene = scene_model{};
auto scene = scene_data{};

// rescale shape to unit
auto ioshape = ioshape_;
Expand All @@ -1117,10 +1117,10 @@ static scene_model make_sculptscene(const scene_shape& ioshape_) {

// material
auto& shape_material = scene.materials.emplace_back();
shape_material.type = scene_material_type::matte;
shape_material.type = material_type::matte;
shape_material.color = {0.78f, 0.31f, 0.23f};
auto& cursor_material = scene.materials.emplace_back();
cursor_material.type = scene_material_type::matte;
cursor_material.type = material_type::matte;

// shapes
scene.shapes.emplace_back(ioshape);
Expand All @@ -1140,8 +1140,8 @@ static scene_model make_sculptscene(const scene_shape& ioshape_) {

// To make the stroke sampling (position, normal) following the mouse
static pair<vector<shape_point>, vec2f> sample_stroke(const shape_bvh& bvh,
const scene_shape& shape, const vec2f& last_uv, const vec2f& mouse_uv,
const scene_camera& camera, const sculpt_params& params) {
const shape_data& shape, const vec2f& last_uv, const vec2f& mouse_uv,
const camera_data& camera, const sculpt_params& params) {
// helper
auto intersect_shape = [&](const vec2f& uv) {
auto ray = camera_ray(
Expand Down Expand Up @@ -1174,8 +1174,8 @@ static pair<vector<shape_point>, vec2f> sample_stroke(const shape_bvh& bvh,
return {samples, cur_uv};
}

static pair<bool, bool> sculpt_update(sculpt_state& state, scene_shape& shape,
scene_shape& cursor, const scene_camera& camera, const vec2f& mouse_uv,
static pair<bool, bool> sculpt_update(sculpt_state& state, shape_data& shape,
shape_data& cursor, const camera_data& camera, const vec2f& mouse_uv,
bool mouse_pressed, const sculpt_params& params) {
auto updated_shape = false, updated_cursor = false;

Expand Down Expand Up @@ -1243,15 +1243,15 @@ static pair<bool, bool> sculpt_update(sculpt_state& state, scene_shape& shape,
int run_glsculpt(const glsculpt_params& params_) {
// loading shape
auto ioerror = ""s;
auto ioshape = scene_shape{};
auto ioshape = shape_data{};
if (!load_shape(params_.shape, ioshape, ioerror, true)) print_fatal(ioerror);
if (!ioshape.quads.empty()) {
ioshape.triangles = quads_to_triangles(ioshape.quads);
ioshape.quads.clear();
}

// loading texture
auto texture = scene_texture{};
auto texture = texture_data{};
if (!params_.texture.empty()) {
if (!load_texture(params_.texture, texture, ioerror)) print_fatal(ioerror);
}
Expand Down
10 changes: 5 additions & 5 deletions apps/yscene/yscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void add_command(const cli_command& cli, const string& name,
// convert images
int run_convert(const convert_params& params) {
// load scene
auto scene = scene_model{};
auto scene = scene_data{};
auto ioerror = ""s;
print_progress_begin("load scene");
if (!load_scene(params.scene, scene, ioerror)) print_fatal(ioerror);
Expand Down Expand Up @@ -119,7 +119,7 @@ void add_command(const cli_command& cli, const string& name,
// print info for scenes
int run_info(const info_params& params) {
// load scene
auto scene = scene_model{};
auto scene = scene_data{};
auto ioerror = ""s;
print_progress_begin("load scene");
if (!load_scene(params.scene, scene, ioerror)) print_fatal(ioerror);
Expand Down Expand Up @@ -186,7 +186,7 @@ int run_render(const render_params& params_) {
auto params = params_;

// scene loading
auto scene = scene_model{};
auto scene = scene_data{};
auto ioerror = string{};
print_progress_begin("load scene");
if (!load_scene(params.scene, scene, ioerror)) return print_fatal(ioerror);
Expand Down Expand Up @@ -311,7 +311,7 @@ int run_view(const view_params& params_) {
auto params = params_;

// load scene
auto scene = scene_model{};
auto scene = scene_data{};
auto ioerror = ""s;
print_progress_begin("load scene");
if (!load_scene(params.scene, scene, ioerror)) print_fatal(ioerror);
Expand Down Expand Up @@ -372,7 +372,7 @@ int run_glview(const glview_params& params_) {

// loading scene
auto ioerror = ""s;
auto scene = scene_model{};
auto scene = scene_data{};
print_progress_begin("load scene");
if (!load_scene(params.scene, scene, ioerror)) print_fatal(ioerror);
print_progress_end();
Expand Down
Loading