diff --git a/android/gltfio-android/src/main/cpp/FilamentAsset.cpp b/android/gltfio-android/src/main/cpp/FilamentAsset.cpp index e6302c5a5b..d121cb474b 100644 --- a/android/gltfio-android/src/main/cpp/FilamentAsset.cpp +++ b/android/gltfio-android/src/main/cpp/FilamentAsset.cpp @@ -208,17 +208,6 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetAnimator(JNIEnv* , jcl return (jlong) asset->getAnimator(); } -extern "C" JNIEXPORT void JNICALL -Java_com_google_android_filament_gltfio_FilamentAsset_nSetMorphWeights(JNIEnv* env, jclass, - jlong nativeAsset, int entityId, jfloatArray weights_) { - FilamentAsset* asset = (FilamentAsset*) nativeAsset; - Entity entity = Entity::import(entityId); - jfloat* weights = env->GetFloatArrayElements(weights_, NULL); - jsize count = env->GetArrayLength(weights_); - asset->setMorphWeights(entity, weights, count); - env->ReleaseFloatArrayElements(weights_, weights, 0); -} - extern "C" JNIEXPORT int JNICALL Java_com_google_android_filament_gltfio_FilamentAsset_nGetMorphTargetCount(JNIEnv* , jclass, jlong nativeAsset, int entityId) { diff --git a/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java b/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java index f048ac3344..e24a2134ab 100644 --- a/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java +++ b/android/gltfio-android/src/main/java/com/google/android/filament/gltfio/FilamentAsset.java @@ -216,13 +216,6 @@ public class FilamentAsset { return mAnimator; } - /** - * Updates the morphing weights in the given entity. - */ - public void setMorphWeights(@Entity int entity, @NonNull float[] weights) { - nSetMorphWeights(mNativeObject, entity, weights); - } - /** * Gets the number of morphing in the given entity. */ @@ -280,7 +273,6 @@ public class FilamentAsset { private static native String nGetName(long nativeAsset, int entity); private static native String nGetExtras(long nativeAsset, int entity); private static native long nGetAnimator(long nativeAsset); - private static native void nSetMorphWeights(long nativeAsset, int entity, float[] weights); private static native int nGetMorphTargetCount(long nativeAsset, int entity); private static native int nGetResourceUriCount(long nativeAsset); private static native void nGetResourceUris(long nativeAsset, String[] result); diff --git a/libs/gltfio/include/gltfio/FilamentAsset.h b/libs/gltfio/include/gltfio/FilamentAsset.h index 2b0a65863b..ba8a2586e2 100644 --- a/libs/gltfio/include/gltfio/FilamentAsset.h +++ b/libs/gltfio/include/gltfio/FilamentAsset.h @@ -203,11 +203,6 @@ public: */ Animator* getAnimator() noexcept; - /** - * Updates the morphing weights in the given entity. - */ - void setMorphWeights(utils::Entity entity, const float* weights, size_t count); - /** * Gets the number of morphing in the given entity. */ diff --git a/libs/gltfio/src/Animator.cpp b/libs/gltfio/src/Animator.cpp index 0102f4c682..c0f8db7fb4 100644 --- a/libs/gltfio/src/Animator.cpp +++ b/libs/gltfio/src/Animator.cpp @@ -461,7 +461,8 @@ void AnimatorImpl::applyAnimation(const Channel& channel, float t, size_t prevIn } } - morpher->setWeights(channel.targetEntity, weights.data(), weights.size()); + auto ci = renderableManager->getInstance(channel.targetEntity); + renderableManager->setMorphWeights(ci, weights.data(), weights.size()); return; } } diff --git a/libs/gltfio/src/FFilamentAsset.h b/libs/gltfio/src/FFilamentAsset.h index a4061fe524..5cfcf92201 100644 --- a/libs/gltfio/src/FFilamentAsset.h +++ b/libs/gltfio/src/FFilamentAsset.h @@ -192,8 +192,6 @@ struct FFilamentAsset : public FilamentAsset { Animator* getAnimator() noexcept; - void setMorphWeights(utils::Entity entity , const float* weights, size_t count) noexcept; - int getMorphTargetCount(utils::Entity entity) noexcept; utils::Entity getWireframe() noexcept; diff --git a/libs/gltfio/src/FilamentAsset.cpp b/libs/gltfio/src/FilamentAsset.cpp index 843a5aec2b..7e894043a6 100644 --- a/libs/gltfio/src/FilamentAsset.cpp +++ b/libs/gltfio/src/FilamentAsset.cpp @@ -97,12 +97,6 @@ Animator* FFilamentAsset::getAnimator() noexcept { return mAnimator; } -void FFilamentAsset::setMorphWeights(utils::Entity entity, const float* weights, size_t count) noexcept { - if (mResourcesLoaded) { - mMorpher->setWeights(entity, weights, count); - } -} - int FFilamentAsset::getMorphTargetCount(utils::Entity entity) noexcept { if (mResourcesLoaded) { return mMorpher->getTargetCount(entity); @@ -289,10 +283,6 @@ Animator* FilamentAsset::getAnimator() noexcept { return upcast(this)->getAnimator(); } -void FilamentAsset::setMorphWeights(utils::Entity entity, const float* weights, size_t count) { - return upcast(this)->setMorphWeights(entity, weights, count); -} - int FilamentAsset::getMorphTargetCount(utils::Entity entity) noexcept { return upcast(this)->getMorphTargetCount(entity); } diff --git a/libs/gltfio/src/MorphHelper.cpp b/libs/gltfio/src/MorphHelper.cpp index abad68525c..1dcab48a37 100644 --- a/libs/gltfio/src/MorphHelper.cpp +++ b/libs/gltfio/src/MorphHelper.cpp @@ -72,12 +72,6 @@ MorphHelper::~MorphHelper() { } } -void MorphHelper::setWeights(Entity entity, float const* weights, int count) noexcept { - auto& engine = *mAsset->mEngine; - auto& rcm = engine.getRenderableManager(); - rcm.setMorphWeights(rcm.getInstance(entity), weights, count); -} - int MorphHelper::getTargetCount(Entity entity) const noexcept { if (mMorphTable.count(entity)) { auto& primitive = mMorphTable.at(entity).primitives; diff --git a/libs/gltfio/src/MorphHelper.h b/libs/gltfio/src/MorphHelper.h index 45c51ba06f..3a49790f23 100644 --- a/libs/gltfio/src/MorphHelper.h +++ b/libs/gltfio/src/MorphHelper.h @@ -49,7 +49,6 @@ public: MorphHelper(FFilamentAsset* asset, FFilamentInstance* inst); ~MorphHelper(); - void setWeights(Entity entity, float const* weights, int count) noexcept; int getTargetCount(Entity entity) const noexcept; private: diff --git a/libs/viewer/src/SimpleViewer.cpp b/libs/viewer/src/SimpleViewer.cpp index a56f398c3c..02026b78b6 100644 --- a/libs/viewer/src/SimpleViewer.cpp +++ b/libs/viewer/src/SimpleViewer.cpp @@ -995,9 +995,11 @@ void SimpleViewer::updateUserInterface() { std::string label = ss.str(); ImGui::SliderFloat(label.data(), &mMorphWeights[i], 0.0f, 1.0); } + auto& rcm = mEngine->getRenderableManager(); + auto entities = mAsset->getEntities(); for (size_t i = 0, c = mAsset->getEntityCount(); i != c; ++i) { - mAsset->setMorphWeights(mAsset->getEntities()[i], - mMorphWeights.data(), mMorphWeights.size()); + auto ci = rcm.getInstance(entities[i]); + rcm.setMorphWeights(ci, mMorphWeights.data(), mMorphWeights.size()); } }