Introduce removeEntities API / fix leak in ModelViewer (!)

For testing purposes, sample-gltf-viewer reloads the model when the
user double-taps the screen. This operation was causing a buildup of
blank entities in the Scene, because we were merely destroying the
components, not removing them from the Scene.
This commit is contained in:
Philip Rideout
2020-07-21 16:25:48 -07:00
parent ecbdeb9e6d
commit 0da20cccdc
11 changed files with 64 additions and 6 deletions

View File

@@ -62,6 +62,15 @@ Java_com_google_android_filament_Scene_nRemove(JNIEnv *env, jclass type, jlong n
scene->remove((Entity&) entity);
}
extern "C" JNIEXPORT void JNICALL
Java_com_google_android_filament_Scene_nRemoveEntities(JNIEnv *env, jclass type, jlong nativeScene,
jintArray entities) {
Scene* scene = (Scene*) nativeScene;
Entity* nativeEntities = (Entity*) env->GetIntArrayElements(entities, nullptr);
scene->removeEntities(nativeEntities, env->GetArrayLength(entities));
env->ReleaseIntArrayElements(entities, (jint*) nativeEntities, JNI_ABORT);
}
extern "C" JNIEXPORT jint JNICALL
Java_com_google_android_filament_Scene_nGetRenderableCount(JNIEnv *env, jclass type,
jlong nativeScene) {