MaterialInstance now has an optional name.

When no name is provided during instance creation, it does NOT inherit
the name of its parent material. This is because instances should be
lightweight and users can already do instance->getMaterial()->getName().

In a subsequent PR, this feature will be exercised and tested via the
gltfio AssetLoader.

Fixes #2485.
This commit is contained in:
Philip Rideout
2020-05-06 09:06:37 -07:00
parent 3c42ace496
commit c3c8293862
15 changed files with 80 additions and 13 deletions

View File

@@ -47,6 +47,16 @@ Java_com_google_android_filament_Material_nCreateInstance(JNIEnv*, jclass,
return (jlong) material->createInstance();
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_google_android_filament_Material_nCreateInstanceWithName(JNIEnv* env, jclass,
jlong nativeMaterial, jstring name_) {
Material* material = (Material*) nativeMaterial;
const char *name = env->GetStringUTFChars(name_, 0);
jlong instance = (jlong) material->createInstance(name);
env->ReleaseStringUTFChars(name_, name);
return instance;
}
extern "C"
JNIEXPORT jstring JNICALL
Java_com_google_android_filament_Material_nGetName(JNIEnv* env, jclass, jlong nativeMaterial) {