فهرست منبع

Updated meshoptimizer.

Бранимир Караџић 6 سال پیش
والد
کامیت
8b4b9b1cc1

+ 6 - 6
3rdparty/meshoptimizer/CMakeLists.txt

@@ -5,7 +5,7 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.15)
     cmake_policy(SET CMP0092 NEW) # Enables clean /W4 override for MSVC
 endif()
 
-project(meshoptimizer VERSION 0.12 LANGUAGES CXX)
+project(meshoptimizer VERSION 0.13 LANGUAGES CXX)
 
 option(BUILD_DEMO "Build demo" OFF)
 option(BUILD_TOOLS "Build tools" OFF)
@@ -29,15 +29,15 @@ set(SOURCES
     src/vfetchoptimizer.cpp
 )
 
-add_library(meshoptimizer ${SOURCES})
-target_include_directories(meshoptimizer INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>")
-
 if(MSVC)
-    target_compile_options(meshoptimizer PRIVATE /W4 /WX)
+    add_compile_options(/W4 /WX)
 else()
-    target_compile_options(meshoptimizer PRIVATE -Wall -Wextra -Werror)
+    add_compile_options(-Wall -Wextra -Wshadow -Wno-missing-field-initializers -Werror)
 endif()
 
+add_library(meshoptimizer ${SOURCES})
+target_include_directories(meshoptimizer INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>")
+
 if(BUILD_SHARED_LIBS)
     set_target_properties(meshoptimizer PROPERTIES CXX_VISIBILITY_PRESET hidden)
     set_target_properties(meshoptimizer PROPERTIES VISIBILITY_INLINES_HIDDEN ON)

+ 4 - 2
3rdparty/meshoptimizer/README.md

@@ -13,10 +13,10 @@ The library provides a C and C++ interface for all algorithms; you can use it fr
 meshoptimizer is hosted on GitHub; you can download the latest release using git:
 
 ```
-git clone -b v0.12 https://github.com/zeux/meshoptimizer.git
+git clone -b v0.13 https://github.com/zeux/meshoptimizer.git
 ```
 
-Alternatively you can [download the .zip archive from GitHub](https://github.com/zeux/meshoptimizer/archive/v0.12.zip).
+Alternatively you can [download the .zip archive from GitHub](https://github.com/zeux/meshoptimizer/archive/v0.13.zip).
 
 ## Building
 
@@ -308,6 +308,8 @@ loader.setMeshoptDecoder(MeshoptDecoder);
 loader.load('pirate.glb', function (gltf) { scene.add(gltf.scene); });
 ```
 
+Additionally, gltfpack can compress textures using Basis Universal format, either storing .basis images directly (`-tb` flag, supported by three.js) or using KTX2 container (`-tc` flag, requires support for `KHR_image_ktx2`). Compression is performed using `basisu` executable.
+
 ## License
 
 This library is available to anybody free of charge, under the terms of MIT License (see LICENSE.md).

+ 2 - 2
3rdparty/meshoptimizer/demo/GLTFLoader.js

@@ -166,7 +166,7 @@ THREE.GLTFLoader = ( function () {
 
 			if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
 
-				if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.' ) );
+				if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) );
 				return;
 
 			}
@@ -456,7 +456,7 @@ THREE.GLTFLoader = ( function () {
 
 		} else if ( this.header.version < 2.0 ) {
 
-			throw new Error( 'THREE.GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.' );
+			throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' );
 
 		}
 

+ 1 - 1
3rdparty/meshoptimizer/demo/index.html

@@ -30,7 +30,7 @@
 		<a href="https://github.com/zeux/meshoptimizer" target="_blank" rel="noopener">meshoptimizer</a>
 		</div>
 
-		<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/109/three.min.js"></script>
+		<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
 
 		<script src="../js/meshopt_decoder.js"></script>
 		<script src="GLTFLoader.js"></script>

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
3rdparty/meshoptimizer/js/meshopt_decoder.js


+ 2 - 2
3rdparty/meshoptimizer/src/meshoptimizer.h

@@ -1,5 +1,5 @@
 /**
- * meshoptimizer - version 0.12
+ * meshoptimizer - version 0.13
  *
  * Copyright (C) 2016-2019, by Arseny Kapoulkine ([email protected])
  * Report bugs and download new versions at https://github.com/zeux/meshoptimizer
@@ -12,7 +12,7 @@
 #include <stddef.h>
 
 /* Version macro; major * 1000 + minor * 10 + patch */
-#define MESHOPTIMIZER_VERSION 120
+#define MESHOPTIMIZER_VERSION 130
 
 /* If no API is defined, assume default */
 #ifndef MESHOPTIMIZER_API

+ 2 - 2
3rdparty/meshoptimizer/tools/basistoktx.cpp

@@ -172,8 +172,8 @@ std::string basisToKtx(const std::string& basis, bool srgb)
 	// supercompression global data
 	ktxBasisGlobalHeader sgd_header = {};
 	sgd_header.globalFlags = basis_header.m_flags;
-	sgd_header.endpointCount = basis_header.m_total_endpoints;
-	sgd_header.selectorCount = basis_header.m_total_selectors;
+	sgd_header.endpointCount = uint16_t(basis_header.m_total_endpoints);
+	sgd_header.selectorCount = uint16_t(basis_header.m_total_selectors);
 	sgd_header.endpointsByteLength = basis_header.m_endpoint_cb_file_size;
 	sgd_header.selectorsByteLength = basis_header.m_selector_cb_file_size;
 	sgd_header.tablesByteLength = basis_header.m_tables_file_size;

+ 34 - 1
3rdparty/meshoptimizer/tools/gltfpack.cpp

@@ -36,6 +36,8 @@
 
 #ifdef _WIN32
 #include <io.h>
+#define popen _popen
+#define pclose _pclose
 #else
 #include <unistd.h>
 #endif
@@ -2712,7 +2714,7 @@ std::string inferMimeType(const char* path)
 
 	std::string extl = ext + 1;
 	for (size_t i = 0; i < extl.length(); ++i)
-		extl[i] = tolower(extl[i]);
+		extl[i] = char(tolower(extl[i]));
 
 	if (extl == "jpg")
 		return "image/jpeg";
@@ -2812,6 +2814,28 @@ struct TempFile
 	}
 };
 
+bool checkBasis()
+{
+	const char* basisu_path = getenv("BASISU_PATH");
+	std::string cmd = basisu_path ? basisu_path : "basisu";
+
+#ifdef _WIN32
+	cmd += " 2>nul";
+#else
+	cmd += " 2>/dev/null";
+#endif
+
+	FILE* pipe = popen(cmd.c_str(), "r");
+	if (!pipe)
+		return false;
+
+	char buf[15];
+	size_t read = fread(buf, 1, sizeof(buf), pipe);
+	pclose(pipe);
+
+	return read == sizeof(buf) && memcmp(buf, "Basis Universal", sizeof(buf)) == 0;
+}
+
 bool encodeBasis(const std::string& data, std::string& result, bool normal_map, bool srgb, int quality)
 {
 	TempFile temp_input(".raw");
@@ -4136,6 +4160,15 @@ int gltfpack(const char* input, const char* output, const Settings& settings)
 		return 2;
 	}
 
+	if (data->images_count && settings.texture_basis)
+	{
+		if (!checkBasis())
+		{
+			fprintf(stderr, "Error: basisu is not present in PATH or BASISU_PATH is not set\n");
+			return 3;
+		}
+	}
+
 	std::string json, bin, fallback;
 	process(data, input, output, meshes, settings, json, bin, fallback);
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است