gltfio: allow zero-instance assets.

This is a feature request from Google. It allows users to "preload" an
asset, ie you can now create all VertexBuffer objects, Texture objects,
etc, without actually creating any entities or renderable components.

In the past we used TransformManager to help out with computing the big
asset-level bounding box, but now we use `gltf_node_transform_world()`
because entities might not yet exist.

One minor side effect is that `FilamentAsset::getBoundingBox()` now
returns the AABB that was determined at load time, and does not account
for instances. As a result, our `gltf_instances` sample app looks
slightly different but this is expected.
This commit is contained in:
Philip Rideout
2022-09-13 16:42:31 -07:00
parent ad6a5eb4e1
commit c4abe4f46a
9 changed files with 88 additions and 32 deletions

View File

@@ -331,6 +331,11 @@ bool ResourceLoader::loadResources(FFilamentAsset* asset, bool async) {
}
asset->mResourcesLoaded = true;
// At this point, any entities that are created in the future (i.e. dynamically added instances)
// will not need the progressive feature to be enabled. This simplifies the dependency graph and
// prevents it from growing.
asset->mDependencyGraph.disableProgressiveReveal();
// Clear our texture caches. Previous calls to loadResources may have populated these, but the
// Texture objects could have since been destroyed.
pImpl->mBufferTextureCache.clear();