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

Scene data serialization #427

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[wip] sceneconverter: support also plugins that can't output a file.
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
commit 260dee1565b933cea1476af47ec47aa724f6549b
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