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

Common utils are shared between files #1019

Merged
merged 16 commits into from
Aug 18, 2020
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
"ciso646": "cpp",
"climits": "cpp",
"ctgmath": "cpp",
"cstdbool": "cpp"
"cstdbool": "cpp",
"ranges": "cpp"
},
"json.schemas": [
{
Expand Down
2 changes: 1 addition & 1 deletion apps/ysceneitrace/ysceneitrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ T1* get_element(
for (auto pos = 0; pos < ioelements.size(); pos++) {
if (ioelements[pos] == ioelement) return elements[pos];
}
throw std::runtime_error("element not found");
throw std::runtime_error{"element not found"};
}

void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) {
Expand Down
2 changes: 1 addition & 1 deletion apps/ysceneview/ysceneview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ T1* get_element(
for (auto pos = 0; pos < ioelements.size(); pos++) {
if (ioelements[pos] == ioelement) return elements[pos];
}
throw std::runtime_error("element not found");
throw std::runtime_error{"element not found"};
}

// draw with shading
Expand Down
2 changes: 1 addition & 1 deletion apps/yshapeproc/yshapeproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ int main(int argc, const char* argv[]) {
// convert data
if (trianglesonly) {
if (!shape.quadspos.empty())
throw std::runtime_error("cannot convert facevarying data to triangles");
print_fatal("cannot convert facevarying data to triangles");
if (!shape.quads.empty()) {
shape.triangles = quads_to_triangles(shape.quads);
shape.quads = {};
Expand Down
21 changes: 11 additions & 10 deletions libs/yocto/yocto_bvh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,21 @@ static RTCDevice bvh_embree_device() {
device = rtcNewDevice("");
rtcSetDeviceErrorFunction(
device,
[](void* ctx, RTCError code, const char* str) {
[](void* ctx, RTCError code, const char* message) {
auto str = string{message};
switch (code) {
case RTC_ERROR_UNKNOWN:
throw std::runtime_error("RTC_ERROR_UNKNOWN: "s + str);
throw std::runtime_error("RTC_ERROR_UNKNOWN: " + str);
case RTC_ERROR_INVALID_ARGUMENT:
throw std::runtime_error("RTC_ERROR_INVALID_ARGUMENT: "s + str);
throw std::runtime_error("RTC_ERROR_INVALID_ARGUMENT: " + str);
case RTC_ERROR_INVALID_OPERATION:
throw std::runtime_error("RTC_ERROR_INVALID_OPERATION: "s + str);
throw std::runtime_error("RTC_ERROR_INVALID_OPERATION: " + str);
case RTC_ERROR_OUT_OF_MEMORY:
throw std::runtime_error("RTC_ERROR_OUT_OF_MEMORY: "s + str);
throw std::runtime_error("RTC_ERROR_OUT_OF_MEMORY: " + str);
case RTC_ERROR_UNSUPPORTED_CPU:
throw std::runtime_error("RTC_ERROR_UNSUPPORTED_CPU: "s + str);
throw std::runtime_error("RTC_ERROR_UNSUPPORTED_CPU: " + str);
case RTC_ERROR_CANCELLED:
throw std::runtime_error("RTC_ERROR_CANCELLED: "s + str);
throw std::runtime_error("RTC_ERROR_CANCELLED: " + str);
default: throw std::runtime_error("invalid error code");
}
},
Expand Down Expand Up @@ -317,9 +318,9 @@ static pair<int, int> split_sah(vector<int>& primitives,

// if we were not able to split, just break the primitives in half
if (mid == start || mid == end) {
throw std::runtime_error("bad bvh split");
split_axis = 0;
mid = (start + end) / 2;
throw std::runtime_error("bad bvh split");
}

return {mid, split_axis};
Expand Down Expand Up @@ -356,9 +357,9 @@ static pair<int, int> split_balanced(vector<int>& primitives,

// if we were not able to split, just break the primitives in half
if (mid == start || mid == end) {
throw std::runtime_error("bad bvh split");
axis = 0;
mid = (start + end) / 2;
throw std::runtime_error("bad bvh split");
}

return {mid, axis};
Expand Down Expand Up @@ -395,9 +396,9 @@ static pair<int, int> split_middle(vector<int>& primitives,

// if we were not able to split, just break the primitives in half
if (mid == start || mid == end) {
throw std::runtime_error("bad bvh split");
axis = 0;
mid = (start + end) / 2;
throw std::runtime_error("bad bvh split");
}

return {mid, axis};
Expand Down
Loading