diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 33bc710510..10561cad85 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -16,6 +16,7 @@ A new header is inserted each time a *tag* is created. - materials: `getNormalizedViewportCoord()` now returns the logical (i.e. user) viewport normalized position and keeps z reversed [⚠️ **Recompile Materials**] - backend: workaround Adreno shader compiler bug (#6355) [⚠️ **Recompile Materials**] +- gltfio: expose joint inverse bind matrices via method on FilamentInstance - geometry: change computing tangent basis from normal vector to use Frisvad's method - filamesh: add error when uv coords size does not match num of vertices. (#6351) diff --git a/libs/gltfio/include/gltfio/FilamentInstance.h b/libs/gltfio/include/gltfio/FilamentInstance.h index 3e5da38ba6..0419963987 100644 --- a/libs/gltfio/include/gltfio/FilamentInstance.h +++ b/libs/gltfio/include/gltfio/FilamentInstance.h @@ -126,6 +126,13 @@ public: */ void detachSkin(size_t skinIndex, utils::Entity target) noexcept; + /** + * Gets inverse bind matrices for all joints at the given skin index. + * + * See getJointCountAt for determining the number of matrices returned (i.e. the number of joints). + */ + math::mat4f const* getInverseBindMatricesAt(size_t skinIndex) const; + /** * Resets the AABB on all renderables by manually computing the bounding box. * diff --git a/libs/gltfio/src/FFilamentInstance.h b/libs/gltfio/src/FFilamentInstance.h index 61425daffa..666ba3d11b 100644 --- a/libs/gltfio/src/FFilamentInstance.h +++ b/libs/gltfio/src/FFilamentInstance.h @@ -117,6 +117,8 @@ struct FFilamentInstance : public FilamentInstance { const utils::Entity* getJointsAt(size_t skinIndex) const noexcept; void attachSkin(size_t skinIndex, utils::Entity target) noexcept; void detachSkin(size_t skinIndex, utils::Entity target) noexcept; + math::mat4f const* getInverseBindMatricesAt(size_t skinIndex) const; + void recomputeBoundingBoxes(); }; diff --git a/libs/gltfio/src/FilamentInstance.cpp b/libs/gltfio/src/FilamentInstance.cpp index 6457df42e6..bee3118b1a 100644 --- a/libs/gltfio/src/FilamentInstance.cpp +++ b/libs/gltfio/src/FilamentInstance.cpp @@ -90,6 +90,12 @@ void FFilamentInstance::detachSkin(size_t skinIndex, Entity target) noexcept { mSkins[skinIndex].targets.erase(target); } +mat4f const* FFilamentInstance::getInverseBindMatricesAt(size_t skinIndex) const { + assert_invariant(mOwner); + ASSERT_PRECONDITION(skinIndex < mOwner->mSkins.size(), "skinIndex must be less than the number of skins in this instance."); + return mOwner->mSkins[skinIndex].inverseBindMatrices.data(); +} + void FFilamentInstance::recomputeBoundingBoxes() { ASSERT_PRECONDITION(mOwner->mSourceAsset, "Do not call releaseSourceData before recomputeBoundingBoxes"); @@ -415,6 +421,10 @@ void FilamentInstance::detachSkin(size_t skinIndex, Entity target) noexcept { return downcast(this)->detachSkin(skinIndex, target); } +math::mat4f const* FilamentInstance::getInverseBindMatricesAt(size_t skinIndex) const { + return downcast(this)->getInverseBindMatricesAt(skinIndex); +} + void FilamentInstance::recomputeBoundingBoxes() { return downcast(this)->recomputeBoundingBoxes(); }