From 3e97ac5268a47d5625c7d166eb7dda0bbba14a4d Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Mon, 17 Jun 2019 12:01:54 -0700 Subject: [PATCH] Add Scene::getEntities to JNI. --- RELEASE_NOTES.md | 1 + android/filament-android/src/main/cpp/Scene.cpp | 9 +++++++++ .../src/main/java/com/google/android/filament/Scene.java | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 754cb8b0c2..30400c4393 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,6 +6,7 @@ A new header is inserted each time a *tag* is created. # Release notes +- Added `Scene.addEntities()` to the Java / Kotlin bindings. - Improved robustness in the tangents utility for meshes that have tangents *and* normals. - Introduced `RenderTarget` API that allows View to reference an offscreen render target. - Added `lucy_bloom` sample to demonstrate the new `RenderTarget` API. diff --git a/android/filament-android/src/main/cpp/Scene.cpp b/android/filament-android/src/main/cpp/Scene.cpp index 7cabac6ac4..8024120c28 100644 --- a/android/filament-android/src/main/cpp/Scene.cpp +++ b/android/filament-android/src/main/cpp/Scene.cpp @@ -44,6 +44,15 @@ Java_com_google_android_filament_Scene_nAddEntity(JNIEnv *env, jclass type, jlon scene->addEntity((Entity&) entity); } +extern "C" JNIEXPORT void JNICALL +Java_com_google_android_filament_Scene_nAddEntities(JNIEnv *env, jclass type, jlong nativeScene, + jintArray entities) { + Scene* scene = (Scene*) nativeScene; + Entity* nativeEntities = (Entity*) env->GetIntArrayElements(entities, nullptr); + scene->addEntities(nativeEntities, env->GetArrayLength(entities)); + env->ReleaseIntArrayElements(entities, (jint*) nativeEntities, JNI_ABORT); +} + extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_Scene_nRemove(JNIEnv *env, jclass type, jlong nativeScene, jint entity) { diff --git a/android/filament-android/src/main/java/com/google/android/filament/Scene.java b/android/filament-android/src/main/java/com/google/android/filament/Scene.java index 6652008b4a..551d7d10bc 100644 --- a/android/filament-android/src/main/java/com/google/android/filament/Scene.java +++ b/android/filament-android/src/main/java/com/google/android/filament/Scene.java @@ -52,6 +52,10 @@ public class Scene { nAddEntity(getNativeObject(), entity); } + public void addEntities(@Entity int[] entities) { + nAddEntities(getNativeObject(), entities); + } + public void removeEntity(@Entity int entity) { nRemove(getNativeObject(), entity); } @@ -85,6 +89,7 @@ public class Scene { private static native void nSetSkybox(long nativeScene, long nativeSkybox); private static native void nSetIndirectLight(long nativeScene, long nativeIndirectLight); private static native void nAddEntity(long nativeScene, int entity); + private static native void nAddEntities(long nativeScene, int[] entities); private static native void nRemove(long nativeScene, int entity); private static native int nGetRenderableCount(long nativeScene); private static native int nGetLightCount(long nativeScene);