diff --git a/libs/yocto/yocto_scene.cpp b/libs/yocto/yocto_scene.cpp index 5ba4f8d5d..c4735e691 100644 --- a/libs/yocto/yocto_scene.cpp +++ b/libs/yocto/yocto_scene.cpp @@ -472,7 +472,7 @@ vector> sample_shape( namespace yocto { // Interpolate vertex data -vec3f eval_position(const fvshape_data& shape, int element, vec2f uv) { +vec3f fvshape_position(const fvshape_data& shape, int element, vec2f uv) { if (!shape.quadspos.empty()) { auto& quad = shape.quadspos[element]; return interpolate_quad(shape.positions[quad.x], shape.positions[quad.y], @@ -482,8 +482,8 @@ vec3f eval_position(const fvshape_data& shape, int element, vec2f uv) { } } -vec3f eval_normal(const fvshape_data& shape, int element, vec2f uv) { - if (shape.normals.empty()) return eval_element_normal(shape, element); +vec3f fvshape_normal(const fvshape_data& shape, int element, vec2f uv) { + if (shape.normals.empty()) return fvshape_element_normal(shape, element); if (!shape.quadspos.empty()) { auto& quad = shape.quadsnorm[element]; return normalize( @@ -494,7 +494,7 @@ vec3f eval_normal(const fvshape_data& shape, int element, vec2f uv) { } } -vec2f eval_texcoord(const fvshape_data& shape, int element, vec2f uv) { +vec2f fvshape_texcoord(const fvshape_data& shape, int element, vec2f uv) { if (shape.texcoords.empty()) return uv; if (!shape.quadspos.empty()) { auto& quad = shape.quadstexcoord[element]; @@ -506,7 +506,7 @@ vec2f eval_texcoord(const fvshape_data& shape, int element, vec2f uv) { } // Evaluate element normals -vec3f eval_element_normal(const fvshape_data& shape, int element) { +vec3f fvshape_element_normal(const fvshape_data& shape, int element) { if (!shape.quadspos.empty()) { auto& quad = shape.quadspos[element]; return quad_normal(shape.positions[quad.x], shape.positions[quad.y], @@ -517,20 +517,13 @@ vec3f eval_element_normal(const fvshape_data& shape, int element) { } // Compute per-vertex normals/tangents for lines/triangles/quads. -vector compute_normals(const fvshape_data& shape) { +vector fvshape_normals(const fvshape_data& shape) { if (!shape.quadspos.empty()) { return quads_normals(shape.quadspos, shape.positions); } else { return vector(shape.positions.size(), {0, 0, 1}); } } -void compute_normals(vector& normals, const fvshape_data& shape) { - if (!shape.quadspos.empty()) { - quads_normals(normals, shape.quadspos, shape.positions); - } else { - normals.assign(shape.positions.size(), {0, 0, 1}); - } -} // Convert face varying data to single primitives. Returns the quads indices // and filled vectors for pos, norm and texcoord. @@ -650,7 +643,7 @@ fvshape_data remove_normals(const fvshape_data& shape) { fvshape_data add_normals(const fvshape_data& shape) { auto transformed = shape; transformed.quadsnorm = transformed.quadspos; - transformed.normals = compute_normals(shape); + transformed.normals = fvshape_normals(shape); return transformed; } diff --git a/libs/yocto/yocto_scene.h b/libs/yocto/yocto_scene.h index 7aeb41aa6..7ee0c49ff 100644 --- a/libs/yocto/yocto_scene.h +++ b/libs/yocto/yocto_scene.h @@ -344,16 +344,15 @@ vector> sample_shape( namespace yocto { // Interpolate vertex data -vec3f eval_position(const fvshape_data& shape, int element, vec2f uv); -vec3f eval_normal(const fvshape_data& shape, int element, vec2f uv); -vec2f eval_texcoord(const shape_data& shape, int element, vec2f uv); +vec3f fvshape_position(const fvshape_data& shape, int element, vec2f uv); +vec3f fvshape_normal(const fvshape_data& shape, int element, vec2f uv); +vec2f fvshape_texcoord(const shape_data& shape, int element, vec2f uv); // Evaluate element normals -vec3f eval_element_normal(const fvshape_data& shape, int element); +vec3f fvshape_element_normal(const fvshape_data& shape, int element); // Compute per-vertex normals/tangents for lines/triangles/quads. -vector compute_normals(const fvshape_data& shape); -void compute_normals(vector& normals, const fvshape_data& shape); +vector fvshape_normals(const fvshape_data& shape); // Conversions shape_data fvshape_to_shape(