gltf_baker: improve error reporting.

This commit is contained in:
Philip Rideout
2019-05-15 09:06:49 -07:00
parent cbfb364c41
commit affc947ce0
3 changed files with 34 additions and 3 deletions

View File

@@ -1149,6 +1149,13 @@ const cgltf_data* Pipeline::parameterize(const cgltf_data* sourceAsset) {
utils::slog.i << "Packing charts..." << utils::io::endl;
xatlas::PackCharts(atlas);
if (atlas->atlasCount == 0) {
// When this occurs, try building in the debug configuration (xatlas has many asserts).
utils::slog.e << "Error: unable to generate atlas, mesh is not clean." << utils::io::endl;
xatlas::Destroy(atlas);
return nullptr;
}
utils::slog.i << "Produced "
<< atlas->atlasCount << " atlases, "
<< atlas->chartCount << " charts, "

View File

@@ -270,6 +270,10 @@ static void renderTileToGbuffer(EmbreeContext* context, PixelRectangle rect) {
RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE, 0, position, 3);
rtcInterpolate0(geo, rayhit.hit.primID, rayhit.hit.u, rayhit.hit.v,
RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE, 1, normal, 3);
// AO won't be computed until the second pass, but we show an instant preview of
// the chart shapes by setting a placeholder value in the AO map.
image.getPixelRef(col, row)[0] = 0.5f;
}
}
}

View File

@@ -84,6 +84,7 @@ struct App {
std::atomic<bool> requestOverlayUpdate;
std::atomic<bool> requestStatePop;
gltfio::AssetPipeline* pipeline;
std::string messageBoxText;
};
struct OverlayVertex {
@@ -333,19 +334,23 @@ static void prepAsset(App& app) {
gltfio::AssetPipeline::AssetHandle asset = pipeline.load(app.filename);
if (!asset) {
std::cerr << "Unable to read " << app.filename << std::endl;
exit(1);
app.state = LOADED;
return;
}
asset = pipeline.flatten(asset);
if (!asset) {
std::cerr << "Unable to flatten " << app.filename << std::endl;
exit(1);
app.state = LOADED;
return;
}
asset = pipeline.parameterize(asset);
if (!asset) {
std::cerr << "Unable to parameterize " << app.filename << std::endl;
exit(1);
app.state = LOADED;
app.messageBoxText = "Unable to parameterize mesh, check terminal output for details.";
return;
}
const utils::Path folder = app.filename.getAbsolutePath().getParent();
@@ -537,6 +542,21 @@ int main(int argc, char** argv) {
if (app.renderedImage) {
ImGui::Checkbox("Show embree result", &app.showOverlay);
}
if (!app.messageBoxText.empty()) {
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {10, 10} );
ImGui::OpenPopup("MessageBox");
if (ImGui::BeginPopupModal("MessageBox", nullptr,
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar)) {
ImGui::TextUnformatted(app.messageBoxText.c_str());
if (ImGui::Button("OK", ImVec2(120,0))) {
app.messageBoxText.clear();
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
ImGui::PopStyleVar();
}
});
// Leave FXAA enabled but we also enable MSAA for a nice result. The wireframe looks