Skip to content

Commit

Permalink
[wip] sceneconverter: support also plugins that can't output a file.
Browse files Browse the repository at this point in the history
Those will simply produce serialized blobs on output.

TODO: make this more generic? like, if I specify a *.ply at the end, it
uses some other converter after that?
  • Loading branch information
mosra committed Apr 30, 2020
1 parent 0bd053d commit 528bbeb
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/Magnum/Trade/sceneconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,36 @@ key=true; configuration subgroups are delimited with /.)")

std::chrono::high_resolution_clock::duration conversionTime;

/* Save output file */
{
/* Save output file directly, if it supports that */
if(converter->features() & Trade::SceneConverterFeature::ConvertMeshToFile) {
Duration d{conversionTime};
if(!converter->convertToFile(args.value("output"), *mesh)) {
Error{} << "Cannot save file" << args.value("output");
return 5;
}

/* Otherwise convert the meshdata and then save as a blob */
} else if(converter->features() & (Trade::SceneConverterFeature::ConvertMesh|Trade::SceneConverterFeature::ConvertMeshInPlace)) {
if(converter->features() & Trade::SceneConverterFeature::ConvertMesh) {
Duration d{conversionTime};
if(!(mesh = converter->convert(*mesh))) {
Error{} << "Cannot convert the mesh";
return 5;
}
} else if(converter->features() & Trade::SceneConverterFeature::ConvertMeshInPlace) {
Duration d{conversionTime};
if(!converter->convertInPlace(*mesh)) {
Error{} << "Cannot convert the mesh in-place";
return 5;
}
} else CORRADE_INTERNAL_ASSERT_UNREACHABLE();

Containers::Array<char, Utility::Directory::MapDeleter> out = Utility::Directory::mapWrite(args.value("output"), mesh->serializedSize());
if(!out) {
Error{} << "Cannot save file" << args.value("output");
return 6;
}
mesh->serializeInto(out);
}

if(args.isSet("profile")) {
Expand Down

0 comments on commit 528bbeb

Please sign in to comment.