diff --git a/android/gltfio-android/CMakeLists.txt b/android/gltfio-android/CMakeLists.txt index 82f4da8398..e80cb2c3a4 100644 --- a/android/gltfio-android/CMakeLists.txt +++ b/android/gltfio-android/CMakeLists.txt @@ -26,8 +26,6 @@ add_library(gltfio-jni SHARED src/main/cpp/MaterialProvider.cpp src/main/cpp/ResourceLoader.cpp src/main/cpp/Gltfio.cpp - - ../common/CallbackUtils.cpp ../common/NioUtils.cpp ) diff --git a/android/gltfio-android/src/main/cpp/Gltfio.cpp b/android/gltfio-android/src/main/cpp/Gltfio.cpp index 82185b81bd..65dcb280e8 100644 --- a/android/gltfio-android/src/main/cpp/Gltfio.cpp +++ b/android/gltfio-android/src/main/cpp/Gltfio.cpp @@ -16,19 +16,11 @@ #include -#include "common/NioUtils.h" - -extern void registerCallbackUtils(JNIEnv*); -extern void registerNioUtils(JNIEnv*); - jint JNI_OnLoad(JavaVM* vm, void*) { JNIEnv* env; if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { return -1; } - registerCallbackUtils(env); - registerNioUtils(env); - return JNI_VERSION_1_6; } diff --git a/android/gltfio-android/src/main/cpp/ResourceLoader.cpp b/android/gltfio-android/src/main/cpp/ResourceLoader.cpp index c4e5f9ba5d..982bfc779b 100644 --- a/android/gltfio-android/src/main/cpp/ResourceLoader.cpp +++ b/android/gltfio-android/src/main/cpp/ResourceLoader.cpp @@ -37,7 +37,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_com_google_android_filament_gltfio_ResourceLoader_nCreateResourceLoader(JNIEnv*, jclass, jlong nativeEngine) { Engine* engine = (Engine*) nativeEngine; - return (jlong) new ResourceLoader({ engine, utils::Path(), true, true }); + return (jlong) new ResourceLoader({ engine, {}, true, true }); } extern "C" JNIEXPORT void JNICALL diff --git a/libs/gltfio/include/gltfio/ResourceLoader.h b/libs/gltfio/include/gltfio/ResourceLoader.h index 1b8beef109..f71ad68b19 100644 --- a/libs/gltfio/include/gltfio/ResourceLoader.h +++ b/libs/gltfio/include/gltfio/ResourceLoader.h @@ -21,7 +21,7 @@ #include -#include +#include namespace filament { class Engine; @@ -45,7 +45,7 @@ struct ResourceConfiguration { //! Optional path or URI that points to the base glTF file. This is used solely //! to resolve relative paths. - utils::Path gltfPath; + std::string gltfPath; //! If true, adjusts skinning weights to sum to 1. Well formed glTF files do not need this, //! but it is useful for robustness. diff --git a/libs/gltfio/src/FFilamentAsset.h b/libs/gltfio/src/FFilamentAsset.h index 93f1760415..0a1c5800db 100644 --- a/libs/gltfio/src/FFilamentAsset.h +++ b/libs/gltfio/src/FFilamentAsset.h @@ -42,7 +42,6 @@ #include -#include #include #include diff --git a/libs/gltfio/src/ResourceLoader.cpp b/libs/gltfio/src/ResourceLoader.cpp index 584fa0a28a..30572540ed 100644 --- a/libs/gltfio/src/ResourceLoader.cpp +++ b/libs/gltfio/src/ResourceLoader.cpp @@ -41,6 +41,13 @@ #include +#if defined(__EMSCRIPTEN__) || defined(ANDROID) +#define USE_FILESYSTEM 0 +#else +#define USE_FILESYSTEM 1 +#include +#endif + using namespace filament; using namespace filament::math; using namespace utils; @@ -195,7 +202,7 @@ bool ResourceLoader::loadResources(FFilamentAsset* asset, bool async) { // looks inside a cache of externally-supplied data blobs, rather than loading from the // filesystem. - #if defined(STBI_NO_STDIO) + #if !USE_FILESYSTEM if (gltf->buffers_count && !gltf->buffers[0].data && !gltf->buffers[0].uri && gltf->bin) { if (gltf->bin_size < gltf->buffers[0].size) { @@ -395,13 +402,13 @@ void ResourceLoader::Impl::decodeSingleTexture() { } // Otherwise load it from the file system if this platform supports it. - #if defined(STBI_NO_STDIO) + #if !USE_FILESYSTEM slog.e << "Unable to load texture: " << uri << io::endl; entry->completed = true; mNumDecoderTasksFinished++; return; #else - utils::Path fullpath = this->mConfig.gltfPath.getParent() + uri; + utils::Path fullpath = utils::Path(this->mConfig.gltfPath).getParent() + uri; entry->texels = stbi_load(fullpath.c_str(), &w, &h, &c, 4); return; #endif @@ -430,7 +437,6 @@ void ResourceLoader::Impl::uploadPendingTextures() { void ResourceLoader::Impl::addTextureCacheEntry(const TextureBinding& tb) { TextureCacheEntry* entry = nullptr; - const Path directory = mConfig.gltfPath.getParent(); // Check if the texture binding uses BufferView data (i.e. it does not have a URI). if (tb.data) { @@ -464,10 +470,10 @@ void ResourceLoader::Impl::addTextureCacheEntry(const TextureBinding& tb) { &entry->height, &entry->numComponents); return; } - #if defined(STBI_NO_STDIO) + #if !USE_FILESYSTEM slog.e << "Unable to load texture: " << tb.uri << io::endl; #else - utils::Path fullpath = directory + tb.uri; + utils::Path fullpath = utils::Path(mConfig.gltfPath).getParent() + tb.uri; stbi_info(fullpath.c_str(), &entry->width, &entry->height, &entry->numComponents); #endif } @@ -579,11 +585,11 @@ bool ResourceLoader::Impl::createTextures(bool async) { } // Otherwise load it from the file system if this platform supports it. - #if defined(STBI_NO_STDIO) + #if !USE_FILESYSTEM slog.e << "Unable to load texture: " << uri << io::endl; return false; #else - utils::Path fullpath = this->mConfig.gltfPath.getParent() + uri; + utils::Path fullpath = utils::Path(this->mConfig.gltfPath).getParent() + uri; utils::JobSystem::Job* decode = utils::jobs::createJob(*js, parent, [=] { int width, height, comp; entry->texels = stbi_load(fullpath.c_str(), &width, &height, &comp, 4);