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:
@@ -457,7 +457,9 @@ void ViewerGui::updateRootTransform() {
|
||||
auto root = tcm.getInstance(mAsset->getRoot());
|
||||
filament::math::mat4f transform;
|
||||
if (mSettings.viewer.autoScaleEnabled) {
|
||||
transform = fitIntoUnitCube(mAsset->getInstance()->getBoundingBox(), 4);
|
||||
FilamentInstance* instance = mAsset->getInstance();
|
||||
Aabb aabb = instance ? instance->getBoundingBox() : mAsset->getBoundingBox();
|
||||
transform = fitIntoUnitCube(aabb, 4);
|
||||
}
|
||||
tcm.setTransform(root, transform);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user