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

Support 3D Tile I3dm legacy tile format #854

Merged
merged 39 commits into from
May 29, 2024
Merged

Support 3D Tile I3dm legacy tile format #854

merged 39 commits into from
May 29, 2024

Conversation

timoore
Copy link
Contributor

@timoore timoore commented Apr 8, 2024

Initial commit for discussion. Some implementation remains, such as implementation of the ENU rotation option.

I3dm strains the GltfConverters interface because it can require a "sub read" of external content: the instanced glb file can be specified by a URI. I created a "ConverterSubprocessor" subclass (pretty bad name) to pass, the async system asset Accessor, base URI, etc. GltfConverters::convert returns a complete model, not a future, so I do a wait() on the accessor future that returns the .glb file. I don't know if that's bad form or if there's a better alternative.

This addresses #458.

This allows the developer to override them usefully in situations
where they need to be set e.g., make a debug library masquerade as
release.

Also allow CESIUM_DEBUG_PREFIX to be empty.
This is all very ad hoc and there will be more extensions that will
have to be handled in the future. This function is currently only used
by Cmpt parsing code, but one could imagine it being generally useful.
Initial commit of the main body of new code. A lot was taken or
inspired from PntsToGltfConverter, which should now be refactored to
use the new common functions.

ENU rotations are not supported yet.
@csciguy8
Copy link
Contributor

csciguy8 commented Apr 8, 2024

Haven't dug in real deep yet, but noticed there are no new unit tests .

Might be nice to add a few, especially if you know of typical use cases, or cases that should fail for some reason.

@kring
Copy link
Member

kring commented Apr 10, 2024

GltfConverters::convert returns a complete model, not a future, so I do a wait() on the accessor future that returns the .glb file. I don't know if that's bad form or if there's a better alternative.

Yeah adding a wait is pretty bad. In Unreal, for example, that'll block up Unreal's task graph on a network request, which in extreme cases could completely pause rendering.

Based on a quick look, I don't think it will be too big a change to make GltfConverters::convert return a Future. If it is, though, another possibility is to convert the i3dm to glTF synchronously and include references to the external resources in that glTF (using a private extension if needed). Then do the async portion later. If you happen to be able to hook into the existing GltfReader::resolveExternalData, the extra async step will just happen automatically. If not, you'll need to add another processing step near where resolveExternalData is located in order to do this extra async work.

@csciguy8
Copy link
Contributor

GltfConverters::convert returns a complete model, not a future, so I do a wait() on the accessor future that returns the .glb file. I don't know if that's bad form or if there's a better alternative.

Agree with @kring , hidden waits aren't great when trying to improve performance.

Will also chime in that hidden IAssetAccessor::gets can become problematic too, especially when trying to manage simultaneous connections to a server, or decouple their execution from other futures that are just CPU processing work. This is the bulk of the work in this Staged Loading PR, and it's not a trivial refactor.

@timoore
Copy link
Contributor Author

timoore commented Apr 12, 2024

GltfConverters::convert returns a complete model, not a future, so I do a wait() on the accessor future that returns the .glb file. I don't know if that's bad form or if there's a better alternative.

Agree with @kring , hidden waits aren't great when trying to improve performance.

I'm rewriting the converter code to return a future.

Will also chime in that hidden IAssetAccessor::gets can become problematic too, especially when trying to manage simultaneous connections to a server, or decouple their execution from other futures that are just CPU processing work. This is the bulk of the work in this Staged Loading PR, and it's not a trivial refactor.

What makes an IAssetAccessor::get call hidden? Or, put another way, what's the alternative when another get() needs to be made in the while processing the content of a previous read? I guess I should look at #779 to see what you're doing there.

@csciguy8
Copy link
Contributor

What makes an IAssetAccessor::get call hidden? Or, put another way, what's the alternative when another get() needs to be made in the while processing the content of a previous read? I guess I should look at #779 to see what you're doing there.

That's a fair question. In #779, a good example of the approach is here in ImplicitOctreeLoader

  • The caller would typically call ::loadTileContent, which returns a future, and somewhere in the chain is a IAssetAccessor::get
  • This PR reworks the approach to have the caller use ::getLoadWork, which returns the needed request and the CPU processing work separately
  • This pain is in the rework of the code in the .cpp, and not break anything

Admittedly, this is "a" solution to separating asset request work from other work. This PR hasn't been reviewed or merged, so there may be a better solution still.

A simple function for computing a perpendicular vector.
@j9liu j9liu self-requested a review May 9, 2024 14:19
Copy link
Contributor

@j9liu j9liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timoore I did a first pass through everything, and so far it's looking good! I definitely want to look more closely at the tile loading changes / actual matrix math, when I have some more uninterrupted time.

I tried to cut down on bikeshedding, but most of my comments ended up being about clarity. 😅 It can get confusing when both I3DM instances and ext_mesh_gpu_instancing are operating in the same file. So I apologize in advance for the quantity and nitpickiness, feel free to push back if something is off

CesiumGltf/include/CesiumGltf/Model.h Outdated Show resolved Hide resolved
CesiumGltf/include/CesiumGltf/AccessorUtility.h Outdated Show resolved Hide resolved
Cesium3DTilesContent/src/I3dmToGltfConverter.cpp Outdated Show resolved Hide resolved
Cesium3DTilesContent/src/I3dmToGltfConverter.cpp Outdated Show resolved Hide resolved
Cesium3DTilesContent/src/I3dmToGltfConverter.cpp Outdated Show resolved Hide resolved
@j9liu
Copy link
Contributor

j9liu commented May 20, 2024

@timoore haven't forgotten about this PR, I'll plan to take another look tomorrow 🙏

Copy link
Contributor

@j9liu j9liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timoore Thanks for addressing my previous feedback, and for your patience with the second review.

I haven't verified the math yet in Unreal, but compared with the notes in #458 , the computation looks good. And I assume that Kevin already did some testing. 😄

CesiumUtility/include/CesiumUtility/Math.h Outdated Show resolved Hide resolved
CesiumUtility/include/CesiumUtility/Math.h Outdated Show resolved Hide resolved
CesiumUtility/test/TestMath.cpp Show resolved Hide resolved
Cesium3DTilesSelection/src/ImplicitOctreeLoader.cpp Outdated Show resolved Hide resolved
Cesium3DTilesContent/src/I3dmToGltfConverter.cpp Outdated Show resolved Hide resolved
Cesium3DTilesContent/src/I3dmToGltfConverter.cpp Outdated Show resolved Hide resolved
Cesium3DTilesContent/src/I3dmToGltfConverter.cpp Outdated Show resolved Hide resolved
Cesium3DTilesContent/src/I3dmToGltfConverter.cpp Outdated Show resolved Hide resolved
@timoore timoore requested a review from j9liu May 28, 2024 16:20
@j9liu
Copy link
Contributor

j9liu commented May 29, 2024

Thanks for addressing all the feedback @timoore ! Sorry I didn't see this earlier, you're welcome to @ me after you push changes to get my attention 😄

Merging now!

@j9liu j9liu merged commit e1ed4db into main May 29, 2024
19 checks passed
@j9liu j9liu deleted the i3dm-2024 branch May 29, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants