Bounding box for animated thin instances are not updating

Repro: https://playground.babylonjs.com/#T19S0U#1

Did I missed a breaking change or is this wai? I have not stepped thru the old versions to isolate as the pgs are not loading for me atm. In my local dev, v9.6.2 is also showing the same so I guess that’s a clue.

edit: updated pg cos I missed the crucial mesh.thinInstanceRefreshBoundingInfo(true); :wink:

cc @Evgeni_Popov

On it, but waiting for the Playground to be updated with:

This has been implemented in PR Fix thin-instance bounds for baked vertex animation by Popov72 · Pull Request #18512 · BabylonJS/Babylon.js · GitHub.

It wasn’t really a bug/regression: applying baked vertex animation when refreshing thin-instance bounding info simply wasn’t implemented yet.

The new behavior is opt-in, for example with thinInstanceRefreshBoundingInfo(true, false, false, true), to avoid changing existing behavior. Note that enabling it can be taxing on performance because the bounding box is recalculated on the CPU; if the animation changes every frame, accurate bounds require refreshing every frame.

The snapshot is looking good: :+1: Babylon.js Playground

hmm, if so, then bounding boxes for normal instances with vat would also not be implemented?
Repro: https://playground.babylonjs.com/#CP2RN9#328

Yes, regular InstancedMesh is the same kind of case.

With the PR, the opt-in path for regular instances is through the refreshBoundingInfo options object. refreshBoundingInfo(true) only uses the old boolean signature (applySkeleton), so it won’t apply VAT. For your PG, the call should be something like:

creep.refreshBoundingInfo({
    applyBakedVertexAnimation: true,
    bakedVertexAnimationSettings: creep.instancedBuffers.bakedVertexAnimationSettingsInstanced,
});

The explicit bakedVertexAnimationSettings part matters when each instance has its own VAT settings in instancedBuffers. If you rely on the manager’s global animationParameters, then only applyBakedVertexAnimation: true is needed.

Same performance caveat applies: this recomputes the bounds on the CPU, so if manager.time changes every frame and you need accurate bounds every frame, this refresh should also happen every frame.

Small correction to my previous snippet: the equivalent of the old refreshBoundingInfo(true) call should carry that boolean through the options object, and for this per-instance refresh it is better not to update the source mesh positions cache.

For the PG, the call should be:

creep.refreshBoundingInfo({
    applySkeleton: true,
    applyBakedVertexAnimation: true,
    bakedVertexAnimationSettings: creep.instancedBuffers.bakedVertexAnimationSettingsInstanced,
    updatePositionsArray: false,
});

bakedVertexAnimationSettings is the options field name; in this case its value comes from the instance’s bakedVertexAnimationSettingsInstanced instanced buffer. If the mesh uses the manager’s global animation parameters instead of per-instance VAT settings, that override can be omitted.

Tested with v9.10.1, its working for me now! Marking as solved, tyvm! :saluting_face:

Got it! These need to be in the doc, pure gold! :slight_smile: