Skip to content

Commit

Permalink
Cleanups static analyzer checks (#1335)
Browse files Browse the repository at this point in the history
  • Loading branch information
xelatihy authored Jan 19, 2022
1 parent c5650f2 commit cb63edf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
8 changes: 5 additions & 3 deletions libs/yocto/yocto_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4163,7 +4163,7 @@ static vector<float> funnel_double(
auto a = points[i].pos;
auto b = points[i + 1].pos;
for (auto k = points[i].face; k < points[i + 1].face; k++) {
auto portal = portals[k];
auto& portal = portals[k];
auto s = intersect_segments_double(a, b, portal.first, portal.second);
report_floating_point(s);
auto p = clamp(s, 0.0, 1.0);
Expand Down Expand Up @@ -5166,6 +5166,7 @@ static pair<bool, spline_polygon> handle_boundary(
adjacencies, control_points[1], control_points[2],
control_points[3], true);
} break;

case 1: {
new_ones[0] = geodesic_lerp(solver, triangles, positions, adjacencies,
control_points[0], control_points[1], 0.5);
Expand All @@ -5178,6 +5179,7 @@ static pair<bool, spline_polygon> handle_boundary(
control_points[2], control_points[3], 0.5);

} break;

case 2: {
new_ones[0] = geodesic_lerp(solver, triangles, positions, adjacencies,
control_points[0], control_points[1], 0.25);
Expand All @@ -5189,7 +5191,6 @@ static pair<bool, spline_polygon> handle_boundary(
new_ones[3] = lane_riesenfeld_regular(solver, triangles, positions,
adjacencies, control_points[1], control_points[2],
control_points[3]);

} break;

case 3: {
Expand All @@ -5203,8 +5204,9 @@ static pair<bool, spline_polygon> handle_boundary(
control_points[3]);
new_ones[3] = geodesic_lerp(solver, triangles, positions, adjacencies,
control_points[2], control_points[3], 0.5);

} break;

default: break;
}
} else {
if (new_ones_entries.back() == pow((float)2, (float)k) + 2) {
Expand Down
2 changes: 1 addition & 1 deletion libs/yocto/yocto_pbrtio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ static bool load_pbrt(const string& filename, pbrt_model& pbrt, string& error,
ctx.stack.back().active_transform_start = true;
ctx.stack.back().active_transform_end = true;
} else {
std::out_of_range{"invalid command"};
throw std::out_of_range{"invalid command"};
}
} else if (cmd == "Transform") {
auto xf = array<float, 16>{};
Expand Down
2 changes: 2 additions & 0 deletions libs/yocto/yocto_sceneio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,12 @@ bool load_image(const string& filename, image_data& image, string& error) {

// conversion helpers
auto from_linear = [](const float* pixels, int width, int height) {
if (pixels == nullptr) return vector<vec4f>{};
return vector<vec4f>{
(vec4f*)pixels, (vec4f*)pixels + (size_t)width * (size_t)height};
};
auto from_srgb = [](const byte* pixels, int width, int height) {
if (pixels == nullptr) return vector<vec4f>{};
auto pixelsf = vector<vec4f>((size_t)width * (size_t)height);
for (auto idx : range(pixelsf.size())) {
pixelsf[idx] = byte_to_float(((vec4b*)pixels)[idx]);
Expand Down
6 changes: 6 additions & 0 deletions libs/yocto/yocto_shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1716,19 +1716,25 @@ vector<vec3f> align_vertices(
for (auto& p : positions) bounds = merge(bounds, p);
auto offset = vec3f{0, 0, 0};
switch (alignment.x) {
case 0: break;
case 1: offset.x = bounds.min.x; break;
case 2: offset.x = (bounds.min.x + bounds.max.x) / 2; break;
case 3: offset.x = bounds.max.x; break;
default: throw std::invalid_argument{"invalid alignment"};
}
switch (alignment.y) {
case 0: break;
case 1: offset.y = bounds.min.y; break;
case 2: offset.y = (bounds.min.y + bounds.max.y) / 2; break;
case 3: offset.y = bounds.max.y; break;
default: throw std::invalid_argument{"invalid alignment"};
}
switch (alignment.z) {
case 0: break;
case 1: offset.z = bounds.min.z; break;
case 2: offset.z = (bounds.min.z + bounds.max.z) / 2; break;
case 3: offset.z = bounds.max.z; break;
default: throw std::invalid_argument{"invalid alignment"};
}
auto aligned = positions;
for (auto& p : aligned) p -= offset;
Expand Down
2 changes: 1 addition & 1 deletion libs/yocto/yocto_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ static trace_result trace_furnace(const scene_data& scene, const trace_bvh& bvh,

// prepare shading point
auto outgoing = -ray.d;
auto instance = scene.instances[intersection.instance];
auto& instance = scene.instances[intersection.instance];
auto element = intersection.element;
auto uv = intersection.uv;
auto position = eval_position(scene, instance, element, uv);
Expand Down

0 comments on commit cb63edf

Please sign in to comment.