|
@@ -1,5 +1,5 @@
|
|
|
/**
|
|
/**
|
|
|
- * meshoptimizer - version 0.23
|
|
|
|
|
|
|
+ * meshoptimizer - version 0.25
|
|
|
*
|
|
*
|
|
|
* Copyright (C) 2016-2025, by Arseny Kapoulkine ([email protected])
|
|
* Copyright (C) 2016-2025, by Arseny Kapoulkine ([email protected])
|
|
|
* Report bugs and download new versions at https://github.com/zeux/meshoptimizer
|
|
* Report bugs and download new versions at https://github.com/zeux/meshoptimizer
|
|
@@ -12,7 +12,7 @@
|
|
|
#include <stddef.h>
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
/* Version macro; major * 1000 + minor * 10 + patch */
|
|
/* Version macro; major * 1000 + minor * 10 + patch */
|
|
|
-#define MESHOPTIMIZER_VERSION 230 /* 0.23 */
|
|
|
|
|
|
|
+#define MESHOPTIMIZER_VERSION 250 /* 0.25 */
|
|
|
|
|
|
|
|
/* If no API is defined, assume default */
|
|
/* If no API is defined, assume default */
|
|
|
#ifndef MESHOPTIMIZER_API
|
|
#ifndef MESHOPTIMIZER_API
|
|
@@ -75,7 +75,7 @@ MESHOPTIMIZER_API size_t meshopt_generateVertexRemap(unsigned int* destination,
|
|
|
MESHOPTIMIZER_API size_t meshopt_generateVertexRemapMulti(unsigned int* destination, const unsigned int* indices, size_t index_count, size_t vertex_count, const struct meshopt_Stream* streams, size_t stream_count);
|
|
MESHOPTIMIZER_API size_t meshopt_generateVertexRemapMulti(unsigned int* destination, const unsigned int* indices, size_t index_count, size_t vertex_count, const struct meshopt_Stream* streams, size_t stream_count);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Experimental: Generates a vertex remap table from the vertex buffer and an optional index buffer and returns number of unique vertices
|
|
|
|
|
|
|
+ * Generates a vertex remap table from the vertex buffer and an optional index buffer and returns number of unique vertices
|
|
|
* As a result, all vertices that are equivalent map to the same (new) location, with no gaps in the resulting sequence.
|
|
* As a result, all vertices that are equivalent map to the same (new) location, with no gaps in the resulting sequence.
|
|
|
* Equivalence is checked in two steps: vertex positions are compared for equality, and then the user-specified equality function is called (if provided).
|
|
* Equivalence is checked in two steps: vertex positions are compared for equality, and then the user-specified equality function is called (if provided).
|
|
|
* Resulting remap table maps old vertices to new vertices and can be used in meshopt_remapVertexBuffer/meshopt_remapIndexBuffer.
|
|
* Resulting remap table maps old vertices to new vertices and can be used in meshopt_remapVertexBuffer/meshopt_remapIndexBuffer.
|
|
@@ -85,7 +85,7 @@ MESHOPTIMIZER_API size_t meshopt_generateVertexRemapMulti(unsigned int* destinat
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
* callback can be NULL if no additional equality check is needed; otherwise, it should return 1 if vertices with specified indices are equivalent and 0 if they are not
|
|
* callback can be NULL if no additional equality check is needed; otherwise, it should return 1 if vertices with specified indices are equivalent and 0 if they are not
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_generateVertexRemapCustom(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, int (*callback)(void*, unsigned int, unsigned int), void* context);
|
|
|
|
|
|
|
+MESHOPTIMIZER_API size_t meshopt_generateVertexRemapCustom(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, int (*callback)(void*, unsigned int, unsigned int), void* context);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Generates vertex buffer from the source vertex buffer and remap table generated by meshopt_generateVertexRemap
|
|
* Generates vertex buffer from the source vertex buffer and remap table generated by meshopt_generateVertexRemap
|
|
@@ -124,6 +124,16 @@ MESHOPTIMIZER_API void meshopt_generateShadowIndexBuffer(unsigned int* destinati
|
|
|
*/
|
|
*/
|
|
|
MESHOPTIMIZER_API void meshopt_generateShadowIndexBufferMulti(unsigned int* destination, const unsigned int* indices, size_t index_count, size_t vertex_count, const struct meshopt_Stream* streams, size_t stream_count);
|
|
MESHOPTIMIZER_API void meshopt_generateShadowIndexBufferMulti(unsigned int* destination, const unsigned int* indices, size_t index_count, size_t vertex_count, const struct meshopt_Stream* streams, size_t stream_count);
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Experimental: Generates a remap table that maps all vertices with the same position to the same (existing) index.
|
|
|
|
|
+ * Similarly to meshopt_generateShadowIndexBuffer, this can be helpful to pre-process meshes for position-only rendering.
|
|
|
|
|
+ * This can also be used to implement algorithms that require positional-only connectivity, such as hierarchical simplification.
|
|
|
|
|
+ *
|
|
|
|
|
+ * destination must contain enough space for the resulting remap table (vertex_count elements)
|
|
|
|
|
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
|
|
+ */
|
|
|
|
|
+MESHOPTIMIZER_EXPERIMENTAL void meshopt_generatePositionRemap(unsigned int* destination, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Generate index buffer that can be used as a geometry shader input with triangle adjacency topology
|
|
* Generate index buffer that can be used as a geometry shader input with triangle adjacency topology
|
|
|
* Each triangle is converted into a 6-vertex patch with the following layout:
|
|
* Each triangle is converted into a 6-vertex patch with the following layout:
|
|
@@ -154,8 +164,8 @@ MESHOPTIMIZER_API void meshopt_generateAdjacencyIndexBuffer(unsigned int* destin
|
|
|
MESHOPTIMIZER_API void meshopt_generateTessellationIndexBuffer(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
MESHOPTIMIZER_API void meshopt_generateTessellationIndexBuffer(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Experimental: Generate index buffer that can be used for visibility buffer rendering and returns the size of the reorder table
|
|
|
|
|
- * Each triangle's provoking vertex index is equal to primitive id; this allows passing it to the fragment shader using nointerpolate attribute.
|
|
|
|
|
|
|
+ * Generate index buffer that can be used for visibility buffer rendering and returns the size of the reorder table
|
|
|
|
|
+ * Each triangle's provoking vertex index is equal to primitive id; this allows passing it to the fragment shader using flat/nointerpolation attribute.
|
|
|
* This is important for performance on hardware where primitive id can't be accessed efficiently in fragment shader.
|
|
* This is important for performance on hardware where primitive id can't be accessed efficiently in fragment shader.
|
|
|
* The reorder table stores the original vertex id for each vertex in the new index buffer, and should be used in the vertex shader to load vertex data.
|
|
* The reorder table stores the original vertex id for each vertex in the new index buffer, and should be used in the vertex shader to load vertex data.
|
|
|
* The provoking vertex is assumed to be the first vertex in the triangle; if this is not the case (OpenGL), rotate each triangle (abc -> bca) before rendering.
|
|
* The provoking vertex is assumed to be the first vertex in the triangle; if this is not the case (OpenGL), rotate each triangle (abc -> bca) before rendering.
|
|
@@ -164,7 +174,7 @@ MESHOPTIMIZER_API void meshopt_generateTessellationIndexBuffer(unsigned int* des
|
|
|
* destination must contain enough space for the resulting index buffer (index_count elements)
|
|
* destination must contain enough space for the resulting index buffer (index_count elements)
|
|
|
* reorder must contain enough space for the worst case reorder table (vertex_count + index_count/3 elements)
|
|
* reorder must contain enough space for the worst case reorder table (vertex_count + index_count/3 elements)
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_generateProvokingIndexBuffer(unsigned int* destination, unsigned int* reorder, const unsigned int* indices, size_t index_count, size_t vertex_count);
|
|
|
|
|
|
|
+MESHOPTIMIZER_API size_t meshopt_generateProvokingIndexBuffer(unsigned int* destination, unsigned int* reorder, const unsigned int* indices, size_t index_count, size_t vertex_count);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Vertex transform cache optimizer
|
|
* Vertex transform cache optimizer
|
|
@@ -241,7 +251,8 @@ MESHOPTIMIZER_API size_t meshopt_encodeIndexBuffer(unsigned char* buffer, size_t
|
|
|
MESHOPTIMIZER_API size_t meshopt_encodeIndexBufferBound(size_t index_count, size_t vertex_count);
|
|
MESHOPTIMIZER_API size_t meshopt_encodeIndexBufferBound(size_t index_count, size_t vertex_count);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Set index encoder format version
|
|
|
|
|
|
|
+ * Set index encoder format version (defaults to 1)
|
|
|
|
|
+ *
|
|
|
* version must specify the data format version to encode; valid values are 0 (decodable by all library versions) and 1 (decodable by 0.14+)
|
|
* version must specify the data format version to encode; valid values are 0 (decodable by all library versions) and 1 (decodable by 0.14+)
|
|
|
*/
|
|
*/
|
|
|
MESHOPTIMIZER_API void meshopt_encodeIndexVersion(int version);
|
|
MESHOPTIMIZER_API void meshopt_encodeIndexVersion(int version);
|
|
@@ -293,23 +304,27 @@ MESHOPTIMIZER_API int meshopt_decodeIndexSequence(void* destination, size_t inde
|
|
|
* For maximum efficiency the vertex buffer being encoded has to be quantized and optimized for locality of reference (cache/fetch) first.
|
|
* For maximum efficiency the vertex buffer being encoded has to be quantized and optimized for locality of reference (cache/fetch) first.
|
|
|
*
|
|
*
|
|
|
* buffer must contain enough space for the encoded vertex buffer (use meshopt_encodeVertexBufferBound to compute worst case size)
|
|
* buffer must contain enough space for the encoded vertex buffer (use meshopt_encodeVertexBufferBound to compute worst case size)
|
|
|
|
|
+ * vertex_size must be a multiple of 4 (and <= 256)
|
|
|
*/
|
|
*/
|
|
|
MESHOPTIMIZER_API size_t meshopt_encodeVertexBuffer(unsigned char* buffer, size_t buffer_size, const void* vertices, size_t vertex_count, size_t vertex_size);
|
|
MESHOPTIMIZER_API size_t meshopt_encodeVertexBuffer(unsigned char* buffer, size_t buffer_size, const void* vertices, size_t vertex_count, size_t vertex_size);
|
|
|
MESHOPTIMIZER_API size_t meshopt_encodeVertexBufferBound(size_t vertex_count, size_t vertex_size);
|
|
MESHOPTIMIZER_API size_t meshopt_encodeVertexBufferBound(size_t vertex_count, size_t vertex_size);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Experimental: Vertex buffer encoder
|
|
|
|
|
|
|
+ * Vertex buffer encoder
|
|
|
* Encodes vertex data just like meshopt_encodeVertexBuffer, but allows to override compression level.
|
|
* Encodes vertex data just like meshopt_encodeVertexBuffer, but allows to override compression level.
|
|
|
- * For compression level to take effect, the vertex encoding version must be set to 1 via meshopt_encodeVertexVersion.
|
|
|
|
|
|
|
+ * For compression level to take effect, the vertex encoding version must be set to 1.
|
|
|
* The default compression level implied by meshopt_encodeVertexBuffer is 2.
|
|
* The default compression level implied by meshopt_encodeVertexBuffer is 2.
|
|
|
*
|
|
*
|
|
|
|
|
+ * buffer must contain enough space for the encoded vertex buffer (use meshopt_encodeVertexBufferBound to compute worst case size)
|
|
|
|
|
+ * vertex_size must be a multiple of 4 (and <= 256)
|
|
|
* level should be in the range [0, 3] with 0 being the fastest and 3 being the slowest and producing the best compression ratio.
|
|
* level should be in the range [0, 3] with 0 being the fastest and 3 being the slowest and producing the best compression ratio.
|
|
|
* version should be -1 to use the default version (specified via meshopt_encodeVertexVersion), or 0/1 to override the version; per above, level won't take effect if version is 0.
|
|
* version should be -1 to use the default version (specified via meshopt_encodeVertexVersion), or 0/1 to override the version; per above, level won't take effect if version is 0.
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_encodeVertexBufferLevel(unsigned char* buffer, size_t buffer_size, const void* vertices, size_t vertex_count, size_t vertex_size, int level, int version);
|
|
|
|
|
|
|
+MESHOPTIMIZER_API size_t meshopt_encodeVertexBufferLevel(unsigned char* buffer, size_t buffer_size, const void* vertices, size_t vertex_count, size_t vertex_size, int level, int version);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Set vertex encoder format version
|
|
|
|
|
|
|
+ * Set vertex encoder format version (defaults to 1)
|
|
|
|
|
+ *
|
|
|
* version must specify the data format version to encode; valid values are 0 (decodable by all library versions) and 1 (decodable by 0.23+)
|
|
* version must specify the data format version to encode; valid values are 0 (decodable by all library versions) and 1 (decodable by 0.23+)
|
|
|
*/
|
|
*/
|
|
|
MESHOPTIMIZER_API void meshopt_encodeVertexVersion(int version);
|
|
MESHOPTIMIZER_API void meshopt_encodeVertexVersion(int version);
|
|
@@ -321,6 +336,7 @@ MESHOPTIMIZER_API void meshopt_encodeVertexVersion(int version);
|
|
|
* The decoder is safe to use for untrusted input, but it may produce garbage data.
|
|
* The decoder is safe to use for untrusted input, but it may produce garbage data.
|
|
|
*
|
|
*
|
|
|
* destination must contain enough space for the resulting vertex buffer (vertex_count * vertex_size bytes)
|
|
* destination must contain enough space for the resulting vertex buffer (vertex_count * vertex_size bytes)
|
|
|
|
|
+ * vertex_size must be a multiple of 4 (and <= 256)
|
|
|
*/
|
|
*/
|
|
|
MESHOPTIMIZER_API int meshopt_decodeVertexBuffer(void* destination, size_t vertex_count, size_t vertex_size, const unsigned char* buffer, size_t buffer_size);
|
|
MESHOPTIMIZER_API int meshopt_decodeVertexBuffer(void* destination, size_t vertex_count, size_t vertex_size, const unsigned char* buffer, size_t buffer_size);
|
|
|
|
|
|
|
@@ -343,10 +359,14 @@ MESHOPTIMIZER_API int meshopt_decodeVertexVersion(const unsigned char* buffer, s
|
|
|
*
|
|
*
|
|
|
* meshopt_decodeFilterExp decodes exponential encoding of floating-point data with 8-bit exponent and 24-bit integer mantissa as 2^E*M.
|
|
* meshopt_decodeFilterExp decodes exponential encoding of floating-point data with 8-bit exponent and 24-bit integer mantissa as 2^E*M.
|
|
|
* Each 32-bit component is decoded in isolation; stride must be divisible by 4.
|
|
* Each 32-bit component is decoded in isolation; stride must be divisible by 4.
|
|
|
|
|
+ *
|
|
|
|
|
+ * Experimental: meshopt_decodeFilterColor decodes YCoCg (+A) color encoding where RGB is converted to YCoCg space with variable bit quantization.
|
|
|
|
|
+ * Each component is stored as an 8-bit or 16-bit normalized integer; stride must be equal to 4 or 8.
|
|
|
*/
|
|
*/
|
|
|
MESHOPTIMIZER_API void meshopt_decodeFilterOct(void* buffer, size_t count, size_t stride);
|
|
MESHOPTIMIZER_API void meshopt_decodeFilterOct(void* buffer, size_t count, size_t stride);
|
|
|
MESHOPTIMIZER_API void meshopt_decodeFilterQuat(void* buffer, size_t count, size_t stride);
|
|
MESHOPTIMIZER_API void meshopt_decodeFilterQuat(void* buffer, size_t count, size_t stride);
|
|
|
MESHOPTIMIZER_API void meshopt_decodeFilterExp(void* buffer, size_t count, size_t stride);
|
|
MESHOPTIMIZER_API void meshopt_decodeFilterExp(void* buffer, size_t count, size_t stride);
|
|
|
|
|
+MESHOPTIMIZER_EXPERIMENTAL void meshopt_decodeFilterColor(void* buffer, size_t count, size_t stride);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Vertex buffer filter encoders
|
|
* Vertex buffer filter encoders
|
|
@@ -363,6 +383,10 @@ MESHOPTIMIZER_API void meshopt_decodeFilterExp(void* buffer, size_t count, size_
|
|
|
* meshopt_encodeFilterExp encodes arbitrary (finite) floating-point data with 8-bit exponent and K-bit integer mantissa (1 <= K <= 24).
|
|
* meshopt_encodeFilterExp encodes arbitrary (finite) floating-point data with 8-bit exponent and K-bit integer mantissa (1 <= K <= 24).
|
|
|
* Exponent can be shared between all components of a given vector as defined by stride or all values of a given component; stride must be divisible by 4.
|
|
* Exponent can be shared between all components of a given vector as defined by stride or all values of a given component; stride must be divisible by 4.
|
|
|
* Input data must contain stride/4 floats for every vector (count*stride/4 total).
|
|
* Input data must contain stride/4 floats for every vector (count*stride/4 total).
|
|
|
|
|
+ *
|
|
|
|
|
+ * Experimental: meshopt_encodeFilterColor encodes RGBA color data by converting RGB to YCoCg color space with variable bit quantization.
|
|
|
|
|
+ * Each component is stored as an 8-bit or 16-bit integer; stride must be equal to 4 or 8.
|
|
|
|
|
+ * Input data must contain 4 floats for every color (count*4 total).
|
|
|
*/
|
|
*/
|
|
|
enum meshopt_EncodeExpMode
|
|
enum meshopt_EncodeExpMode
|
|
|
{
|
|
{
|
|
@@ -379,6 +403,7 @@ enum meshopt_EncodeExpMode
|
|
|
MESHOPTIMIZER_API void meshopt_encodeFilterOct(void* destination, size_t count, size_t stride, int bits, const float* data);
|
|
MESHOPTIMIZER_API void meshopt_encodeFilterOct(void* destination, size_t count, size_t stride, int bits, const float* data);
|
|
|
MESHOPTIMIZER_API void meshopt_encodeFilterQuat(void* destination, size_t count, size_t stride, int bits, const float* data);
|
|
MESHOPTIMIZER_API void meshopt_encodeFilterQuat(void* destination, size_t count, size_t stride, int bits, const float* data);
|
|
|
MESHOPTIMIZER_API void meshopt_encodeFilterExp(void* destination, size_t count, size_t stride, int bits, const float* data, enum meshopt_EncodeExpMode mode);
|
|
MESHOPTIMIZER_API void meshopt_encodeFilterExp(void* destination, size_t count, size_t stride, int bits, const float* data, enum meshopt_EncodeExpMode mode);
|
|
|
|
|
+MESHOPTIMIZER_EXPERIMENTAL void meshopt_encodeFilterColor(void* destination, size_t count, size_t stride, int bits, const float* data);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Simplification options
|
|
* Simplification options
|
|
@@ -391,18 +416,34 @@ enum
|
|
|
meshopt_SimplifySparse = 1 << 1,
|
|
meshopt_SimplifySparse = 1 << 1,
|
|
|
/* Treat error limit and resulting error as absolute instead of relative to mesh extents. */
|
|
/* Treat error limit and resulting error as absolute instead of relative to mesh extents. */
|
|
|
meshopt_SimplifyErrorAbsolute = 1 << 2,
|
|
meshopt_SimplifyErrorAbsolute = 1 << 2,
|
|
|
- /* Experimental: remove disconnected parts of the mesh during simplification incrementally, regardless of the topological restrictions inside components. */
|
|
|
|
|
|
|
+ /* Remove disconnected parts of the mesh during simplification incrementally, regardless of the topological restrictions inside components. */
|
|
|
meshopt_SimplifyPrune = 1 << 3,
|
|
meshopt_SimplifyPrune = 1 << 3,
|
|
|
|
|
+ /* Experimental: Produce more regular triangle sizes and shapes during simplification, at some cost to geometric quality. */
|
|
|
|
|
+ meshopt_SimplifyRegularize = 1 << 4,
|
|
|
|
|
+ /* Experimental: Allow collapses across attribute discontinuities, except for vertices that are tagged with meshopt_SimplifyVertex_Protect in vertex_lock. */
|
|
|
|
|
+ meshopt_SimplifyPermissive = 1 << 5,
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Experimental: Simplification vertex flags/locks, for use in `vertex_lock` arrays in simplification APIs
|
|
|
|
|
+ */
|
|
|
|
|
+enum
|
|
|
|
|
+{
|
|
|
|
|
+ /* Do not move this vertex. */
|
|
|
|
|
+ meshopt_SimplifyVertex_Lock = 1 << 0,
|
|
|
|
|
+ /* Protect attribute discontinuity at this vertex; must be used together with meshopt_SimplifyPermissive option. */
|
|
|
|
|
+ meshopt_SimplifyVertex_Protect = 1 << 1,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Mesh simplifier
|
|
* Mesh simplifier
|
|
|
* Reduces the number of triangles in the mesh, attempting to preserve mesh appearance as much as possible
|
|
* Reduces the number of triangles in the mesh, attempting to preserve mesh appearance as much as possible
|
|
|
* The algorithm tries to preserve mesh topology and can stop short of the target goal based on topology constraints or target error.
|
|
* The algorithm tries to preserve mesh topology and can stop short of the target goal based on topology constraints or target error.
|
|
|
- * If not all attributes from the input mesh are required, it's recommended to reindex the mesh without them prior to simplification.
|
|
|
|
|
|
|
+ * If not all attributes from the input mesh are needed, it's recommended to reindex the mesh without them prior to simplification.
|
|
|
* Returns the number of indices after simplification, with destination containing new index data
|
|
* Returns the number of indices after simplification, with destination containing new index data
|
|
|
|
|
+ *
|
|
|
* The resulting index buffer references vertices from the original vertex buffer.
|
|
* The resulting index buffer references vertices from the original vertex buffer.
|
|
|
- * If the original vertex data isn't required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
|
|
|
|
|
|
|
+ * If the original vertex data isn't needed, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
|
|
|
*
|
|
*
|
|
|
* destination must contain enough space for the target index buffer, worst case is index_count elements (*not* target_index_count)!
|
|
* destination must contain enough space for the target index buffer, worst case is index_count elements (*not* target_index_count)!
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
@@ -414,50 +455,86 @@ MESHOPTIMIZER_API size_t meshopt_simplify(unsigned int* destination, const unsig
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Mesh simplifier with attribute metric
|
|
* Mesh simplifier with attribute metric
|
|
|
- * The algorithm enhances meshopt_simplify by incorporating attribute values into the error metric used to prioritize simplification order; see meshopt_simplify documentation for details.
|
|
|
|
|
- * Note that the number of attributes affects memory requirements and running time; this algorithm requires ~1.5x more memory and time compared to meshopt_simplify when using 4 scalar attributes.
|
|
|
|
|
|
|
+ * Reduces the number of triangles in the mesh, attempting to preserve mesh appearance as much as possible.
|
|
|
|
|
+ * Similar to meshopt_simplify, but incorporates attribute values into the error metric used to prioritize simplification order.
|
|
|
|
|
+ * The algorithm tries to preserve mesh topology and can stop short of the target goal based on topology constraints or target error.
|
|
|
|
|
+ * If not all attributes from the input mesh are needed, it's recommended to reindex the mesh without them prior to simplification.
|
|
|
|
|
+ * Returns the number of indices after simplification, with destination containing new index data
|
|
|
|
|
+ *
|
|
|
|
|
+ * The resulting index buffer references vertices from the original vertex buffer.
|
|
|
|
|
+ * If the original vertex data isn't needed, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
|
|
|
|
|
+ * Note that the number of attributes with non-zero weights affects memory requirements and running time.
|
|
|
*
|
|
*
|
|
|
|
|
+ * destination must contain enough space for the target index buffer, worst case is index_count elements (*not* target_index_count)!
|
|
|
|
|
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
* vertex_attributes should have attribute_count floats for each vertex
|
|
* vertex_attributes should have attribute_count floats for each vertex
|
|
|
* attribute_weights should have attribute_count floats in total; the weights determine relative priority of attributes between each other and wrt position
|
|
* attribute_weights should have attribute_count floats in total; the weights determine relative priority of attributes between each other and wrt position
|
|
|
* attribute_count must be <= 32
|
|
* attribute_count must be <= 32
|
|
|
* vertex_lock can be NULL; when it's not NULL, it should have a value for each vertex; 1 denotes vertices that can't be moved
|
|
* vertex_lock can be NULL; when it's not NULL, it should have a value for each vertex; 1 denotes vertices that can't be moved
|
|
|
|
|
+ * target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation; value range [0..1]
|
|
|
|
|
+ * options must be a bitmask composed of meshopt_SimplifyX options; 0 is a safe default
|
|
|
|
|
+ * result_error can be NULL; when it's not NULL, it will contain the resulting (relative) error after simplification
|
|
|
*/
|
|
*/
|
|
|
MESHOPTIMIZER_API size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, const float* vertex_attributes, size_t vertex_attributes_stride, const float* attribute_weights, size_t attribute_count, const unsigned char* vertex_lock, size_t target_index_count, float target_error, unsigned int options, float* result_error);
|
|
MESHOPTIMIZER_API size_t meshopt_simplifyWithAttributes(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, const float* vertex_attributes, size_t vertex_attributes_stride, const float* attribute_weights, size_t attribute_count, const unsigned char* vertex_lock, size_t target_index_count, float target_error, unsigned int options, float* result_error);
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Experimental: Mesh simplifier with position/attribute update
|
|
|
|
|
+ * Reduces the number of triangles in the mesh, attempting to preserve mesh appearance as much as possible.
|
|
|
|
|
+ * Similar to meshopt_simplifyWithAttributes, but destructively updates positions and attribute values for optimal appearance.
|
|
|
|
|
+ * The algorithm tries to preserve mesh topology and can stop short of the target goal based on topology constraints or target error.
|
|
|
|
|
+ * If not all attributes from the input mesh are needed, it's recommended to reindex the mesh without them prior to simplification.
|
|
|
|
|
+ * Returns the number of indices after simplification, indices are destructively updated with new index data
|
|
|
|
|
+ *
|
|
|
|
|
+ * The updated index buffer references vertices from the original vertex buffer, however the vertex positions and attributes are updated in-place.
|
|
|
|
|
+ * Creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended; if the original vertex data is needed, it should be copied before simplification.
|
|
|
|
|
+ * Note that the number of attributes with non-zero weights affects memory requirements and running time. Attributes with zero weights are not updated.
|
|
|
|
|
+ *
|
|
|
|
|
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
|
|
+ * vertex_attributes should have attribute_count floats for each vertex
|
|
|
|
|
+ * attribute_weights should have attribute_count floats in total; the weights determine relative priority of attributes between each other and wrt position
|
|
|
|
|
+ * attribute_count must be <= 32
|
|
|
|
|
+ * vertex_lock can be NULL; when it's not NULL, it should have a value for each vertex; 1 denotes vertices that can't be moved
|
|
|
|
|
+ * target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation; value range [0..1]
|
|
|
|
|
+ * options must be a bitmask composed of meshopt_SimplifyX options; 0 is a safe default
|
|
|
|
|
+ * result_error can be NULL; when it's not NULL, it will contain the resulting (relative) error after simplification
|
|
|
|
|
+ */
|
|
|
|
|
+MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifyWithUpdate(unsigned int* indices, size_t index_count, float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, float* vertex_attributes, size_t vertex_attributes_stride, const float* attribute_weights, size_t attribute_count, const unsigned char* vertex_lock, size_t target_index_count, float target_error, unsigned int options, float* result_error);
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Experimental: Mesh simplifier (sloppy)
|
|
* Experimental: Mesh simplifier (sloppy)
|
|
|
* Reduces the number of triangles in the mesh, sacrificing mesh appearance for simplification performance
|
|
* Reduces the number of triangles in the mesh, sacrificing mesh appearance for simplification performance
|
|
|
* The algorithm doesn't preserve mesh topology but can stop short of the target goal based on target error.
|
|
* The algorithm doesn't preserve mesh topology but can stop short of the target goal based on target error.
|
|
|
* Returns the number of indices after simplification, with destination containing new index data
|
|
* Returns the number of indices after simplification, with destination containing new index data
|
|
|
* The resulting index buffer references vertices from the original vertex buffer.
|
|
* The resulting index buffer references vertices from the original vertex buffer.
|
|
|
- * If the original vertex data isn't required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
|
|
|
|
|
|
|
+ * If the original vertex data isn't needed, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
|
|
|
*
|
|
*
|
|
|
* destination must contain enough space for the target index buffer, worst case is index_count elements (*not* target_index_count)!
|
|
* destination must contain enough space for the target index buffer, worst case is index_count elements (*not* target_index_count)!
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
|
|
+ * vertex_lock can be NULL; when it's not NULL, it should have a value for each vertex; vertices that can't be moved should set 1 consistently for all indices with the same position
|
|
|
* target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation; value range [0..1]
|
|
* target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation; value range [0..1]
|
|
|
* result_error can be NULL; when it's not NULL, it will contain the resulting (relative) error after simplification
|
|
* result_error can be NULL; when it's not NULL, it will contain the resulting (relative) error after simplification
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifySloppy(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error);
|
|
|
|
|
|
|
+MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifySloppy(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, const unsigned char* vertex_lock, size_t target_index_count, float target_error, float* result_error);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Experimental: Mesh simplifier (pruner)
|
|
|
|
|
|
|
+ * Mesh simplifier (pruner)
|
|
|
* Reduces the number of triangles in the mesh by removing small isolated parts of the mesh
|
|
* Reduces the number of triangles in the mesh by removing small isolated parts of the mesh
|
|
|
* Returns the number of indices after simplification, with destination containing new index data
|
|
* Returns the number of indices after simplification, with destination containing new index data
|
|
|
* The resulting index buffer references vertices from the original vertex buffer.
|
|
* The resulting index buffer references vertices from the original vertex buffer.
|
|
|
- * If the original vertex data isn't required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
|
|
|
|
|
|
|
+ * If the original vertex data isn't needed, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
|
|
|
*
|
|
*
|
|
|
* destination must contain enough space for the target index buffer, worst case is index_count elements
|
|
* destination must contain enough space for the target index buffer, worst case is index_count elements
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
* target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation; value range [0..1]
|
|
* target_error represents the error relative to mesh extents that can be tolerated, e.g. 0.01 = 1% deformation; value range [0..1]
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_simplifyPrune(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, float target_error);
|
|
|
|
|
|
|
+MESHOPTIMIZER_API size_t meshopt_simplifyPrune(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, float target_error);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Point cloud simplifier
|
|
* Point cloud simplifier
|
|
|
* Reduces the number of points in the cloud to reach the given target
|
|
* Reduces the number of points in the cloud to reach the given target
|
|
|
* Returns the number of points after simplification, with destination containing new index data
|
|
* Returns the number of points after simplification, with destination containing new index data
|
|
|
* The resulting index buffer references vertices from the original vertex buffer.
|
|
* The resulting index buffer references vertices from the original vertex buffer.
|
|
|
- * If the original vertex data isn't required, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
|
|
|
|
|
|
|
+ * If the original vertex data isn't needed, creating a compact vertex buffer using meshopt_optimizeVertexFetch is recommended.
|
|
|
*
|
|
*
|
|
|
* destination must contain enough space for the target index buffer (target_vertex_count elements)
|
|
* destination must contain enough space for the target index buffer (target_vertex_count elements)
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
@@ -548,12 +625,12 @@ struct meshopt_CoverageStatistics
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Experimental: Coverage analyzer
|
|
|
|
|
|
|
+ * Coverage analyzer
|
|
|
* Returns coverage statistics (ratio of viewport pixels covered from each axis) using a software rasterizer
|
|
* Returns coverage statistics (ratio of viewport pixels covered from each axis) using a software rasterizer
|
|
|
*
|
|
*
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL struct meshopt_CoverageStatistics meshopt_analyzeCoverage(const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
|
|
|
|
|
+MESHOPTIMIZER_API struct meshopt_CoverageStatistics meshopt_analyzeCoverage(const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Meshlet is a small mesh cluster (subset) that consists of:
|
|
* Meshlet is a small mesh cluster (subset) that consists of:
|
|
@@ -582,10 +659,10 @@ struct meshopt_Meshlet
|
|
|
* When using buildMeshletsScan, for maximum efficiency the index buffer being converted has to be optimized for vertex cache first.
|
|
* When using buildMeshletsScan, for maximum efficiency the index buffer being converted has to be optimized for vertex cache first.
|
|
|
*
|
|
*
|
|
|
* meshlets must contain enough space for all meshlets, worst case size can be computed with meshopt_buildMeshletsBound
|
|
* meshlets must contain enough space for all meshlets, worst case size can be computed with meshopt_buildMeshletsBound
|
|
|
- * meshlet_vertices must contain enough space for all meshlets, worst case size is equal to max_meshlets * max_vertices
|
|
|
|
|
- * meshlet_triangles must contain enough space for all meshlets, worst case size is equal to max_meshlets * max_triangles * 3
|
|
|
|
|
|
|
+ * meshlet_vertices must contain enough space for all meshlets, worst case is index_count elements (*not* vertex_count!)
|
|
|
|
|
+ * meshlet_triangles must contain enough space for all meshlets, worst case is index_count elements
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
- * max_vertices and max_triangles must not exceed implementation limits (max_vertices <= 256, max_triangles <= 512; max_triangles must be divisible by 4)
|
|
|
|
|
|
|
+ * max_vertices and max_triangles must not exceed implementation limits (max_vertices <= 256, max_triangles <= 512)
|
|
|
* cone_weight should be set to 0 when cone culling is not used, and a value between 0 and 1 otherwise to balance between cluster size and cone culling efficiency
|
|
* cone_weight should be set to 0 when cone culling is not used, and a value between 0 and 1 otherwise to balance between cluster size and cone culling efficiency
|
|
|
*/
|
|
*/
|
|
|
MESHOPTIMIZER_API size_t meshopt_buildMeshlets(struct meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t max_triangles, float cone_weight);
|
|
MESHOPTIMIZER_API size_t meshopt_buildMeshlets(struct meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t max_triangles, float cone_weight);
|
|
@@ -596,14 +673,13 @@ MESHOPTIMIZER_API size_t meshopt_buildMeshletsBound(size_t index_count, size_t m
|
|
|
* Experimental: Meshlet builder with flexible cluster sizes
|
|
* Experimental: Meshlet builder with flexible cluster sizes
|
|
|
* Splits the mesh into a set of meshlets, similarly to meshopt_buildMeshlets, but allows to specify minimum and maximum number of triangles per meshlet.
|
|
* Splits the mesh into a set of meshlets, similarly to meshopt_buildMeshlets, but allows to specify minimum and maximum number of triangles per meshlet.
|
|
|
* Clusters between min and max triangle counts are split when the cluster size would have exceeded the expected cluster size by more than split_factor.
|
|
* Clusters between min and max triangle counts are split when the cluster size would have exceeded the expected cluster size by more than split_factor.
|
|
|
- * Additionally, allows to switch to axis aligned clusters by setting cone_weight to a negative value.
|
|
|
|
|
*
|
|
*
|
|
|
- * meshlets must contain enough space for all meshlets, worst case size can be computed with meshopt_buildMeshletsBound using min_triangles (not max!)
|
|
|
|
|
- * meshlet_vertices must contain enough space for all meshlets, worst case size is equal to max_meshlets * max_vertices
|
|
|
|
|
- * meshlet_triangles must contain enough space for all meshlets, worst case size is equal to max_meshlets * max_triangles * 3
|
|
|
|
|
|
|
+ * meshlets must contain enough space for all meshlets, worst case size can be computed with meshopt_buildMeshletsBound using min_triangles (*not* max!)
|
|
|
|
|
+ * meshlet_vertices must contain enough space for all meshlets, worst case is index_count elements (*not* vertex_count!)
|
|
|
|
|
+ * meshlet_triangles must contain enough space for all meshlets, worst case is index_count elements
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
- * max_vertices, min_triangles and max_triangles must not exceed implementation limits (max_vertices <= 256, max_triangles <= 512; min_triangles <= max_triangles; both min_triangles and max_triangles must be divisible by 4)
|
|
|
|
|
- * cone_weight should be set to 0 when cone culling is not used, and a value between 0 and 1 otherwise to balance between cluster size and cone culling efficiency; additionally, cone_weight can be set to a negative value to prioritize axis aligned clusters (for raytracing) instead
|
|
|
|
|
|
|
+ * max_vertices, min_triangles and max_triangles must not exceed implementation limits (max_vertices <= 256, max_triangles <= 512; min_triangles <= max_triangles)
|
|
|
|
|
+ * cone_weight should be set to 0 when cone culling is not used, and a value between 0 and 1 otherwise to balance between cluster size and cone culling efficiency
|
|
|
* split_factor should be set to a non-negative value; when greater than 0, clusters that have large bounds may be split unless they are under the min_triangles threshold
|
|
* split_factor should be set to a non-negative value; when greater than 0, clusters that have large bounds may be split unless they are under the min_triangles threshold
|
|
|
*/
|
|
*/
|
|
|
MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_buildMeshletsFlex(struct meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float cone_weight, float split_factor);
|
|
MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_buildMeshletsFlex(struct meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float cone_weight, float split_factor);
|
|
@@ -612,14 +688,14 @@ MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_buildMeshletsFlex(struct meshopt_Meshl
|
|
|
* Experimental: Meshlet builder that produces clusters optimized for raytracing
|
|
* Experimental: Meshlet builder that produces clusters optimized for raytracing
|
|
|
* Splits the mesh into a set of meshlets, similarly to meshopt_buildMeshlets, but optimizes cluster subdivision for raytracing and allows to specify minimum and maximum number of triangles per meshlet.
|
|
* Splits the mesh into a set of meshlets, similarly to meshopt_buildMeshlets, but optimizes cluster subdivision for raytracing and allows to specify minimum and maximum number of triangles per meshlet.
|
|
|
*
|
|
*
|
|
|
- * meshlets must contain enough space for all meshlets, worst case size can be computed with meshopt_buildMeshletsBound using min_triangles (not max!)
|
|
|
|
|
- * meshlet_vertices must contain enough space for all meshlets, worst case size is equal to max_meshlets * max_vertices
|
|
|
|
|
- * meshlet_triangles must contain enough space for all meshlets, worst case size is equal to max_meshlets * max_triangles * 3
|
|
|
|
|
|
|
+ * meshlets must contain enough space for all meshlets, worst case size can be computed with meshopt_buildMeshletsBound using min_triangles (*not* max!)
|
|
|
|
|
+ * meshlet_vertices must contain enough space for all meshlets, worst case is index_count elements (*not* vertex_count!)
|
|
|
|
|
+ * meshlet_triangles must contain enough space for all meshlets, worst case is index_count elements
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
- * max_vertices, min_triangles and max_triangles must not exceed implementation limits (max_vertices <= 256, max_triangles <= 512; min_triangles <= max_triangles; both min_triangles and max_triangles must be divisible by 4)
|
|
|
|
|
|
|
+ * max_vertices, min_triangles and max_triangles must not exceed implementation limits (max_vertices <= 256, max_triangles <= 512; min_triangles <= max_triangles)
|
|
|
* fill_weight allows to prioritize clusters that are closer to maximum size at some cost to SAH quality; 0.5 is a safe default
|
|
* fill_weight allows to prioritize clusters that are closer to maximum size at some cost to SAH quality; 0.5 is a safe default
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_buildMeshletsSplit(struct meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float fill_weight);
|
|
|
|
|
|
|
+MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_buildMeshletsSpatial(struct meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float fill_weight);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Meshlet optimizer
|
|
* Meshlet optimizer
|
|
@@ -674,26 +750,26 @@ MESHOPTIMIZER_API struct meshopt_Bounds meshopt_computeClusterBounds(const unsig
|
|
|
MESHOPTIMIZER_API struct meshopt_Bounds meshopt_computeMeshletBounds(const unsigned int* meshlet_vertices, const unsigned char* meshlet_triangles, size_t triangle_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
MESHOPTIMIZER_API struct meshopt_Bounds meshopt_computeMeshletBounds(const unsigned int* meshlet_vertices, const unsigned char* meshlet_triangles, size_t triangle_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Experimental: Sphere bounds generator
|
|
|
|
|
|
|
+ * Sphere bounds generator
|
|
|
* Creates bounding sphere around a set of points or a set of spheres; returns the center and radius of the sphere, with other fields of the result set to 0.
|
|
* Creates bounding sphere around a set of points or a set of spheres; returns the center and radius of the sphere, with other fields of the result set to 0.
|
|
|
*
|
|
*
|
|
|
* positions should have float3 position in the first 12 bytes of each element
|
|
* positions should have float3 position in the first 12 bytes of each element
|
|
|
* radii can be NULL; when it's not NULL, it should have a non-negative float radius in the first 4 bytes of each element
|
|
* radii can be NULL; when it's not NULL, it should have a non-negative float radius in the first 4 bytes of each element
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL struct meshopt_Bounds meshopt_computeSphereBounds(const float* positions, size_t count, size_t positions_stride, const float* radii, size_t radii_stride);
|
|
|
|
|
|
|
+MESHOPTIMIZER_API struct meshopt_Bounds meshopt_computeSphereBounds(const float* positions, size_t count, size_t positions_stride, const float* radii, size_t radii_stride);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Experimental: Cluster partitioner
|
|
|
|
|
|
|
+ * Cluster partitioner
|
|
|
* Partitions clusters into groups of similar size, prioritizing grouping clusters that share vertices or are close to each other.
|
|
* Partitions clusters into groups of similar size, prioritizing grouping clusters that share vertices or are close to each other.
|
|
|
*
|
|
*
|
|
|
- * destination must contain enough space for the resulting partiotion data (cluster_count elements)
|
|
|
|
|
|
|
+ * destination must contain enough space for the resulting partition data (cluster_count elements)
|
|
|
* destination[i] will contain the partition id for cluster i, with the total number of partitions returned by the function
|
|
* destination[i] will contain the partition id for cluster i, with the total number of partitions returned by the function
|
|
|
* cluster_indices should have the vertex indices referenced by each cluster, stored sequentially
|
|
* cluster_indices should have the vertex indices referenced by each cluster, stored sequentially
|
|
|
* cluster_index_counts should have the number of indices in each cluster; sum of all cluster_index_counts must be equal to total_index_count
|
|
* cluster_index_counts should have the number of indices in each cluster; sum of all cluster_index_counts must be equal to total_index_count
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex (or can be NULL if not used)
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex (or can be NULL if not used)
|
|
|
* target_partition_size is a target size for each partition, in clusters; the resulting partitions may be smaller or larger
|
|
* target_partition_size is a target size for each partition, in clusters; the resulting partitions may be smaller or larger
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_partitionClusters(unsigned int* destination, const unsigned int* cluster_indices, size_t total_index_count, const unsigned int* cluster_index_counts, size_t cluster_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_partition_size);
|
|
|
|
|
|
|
+MESHOPTIMIZER_API size_t meshopt_partitionClusters(unsigned int* destination, const unsigned int* cluster_indices, size_t total_index_count, const unsigned int* cluster_index_counts, size_t cluster_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_partition_size);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Spatial sorter
|
|
* Spatial sorter
|
|
@@ -706,13 +782,23 @@ MESHOPTIMIZER_EXPERIMENTAL size_t meshopt_partitionClusters(unsigned int* destin
|
|
|
MESHOPTIMIZER_API void meshopt_spatialSortRemap(unsigned int* destination, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
MESHOPTIMIZER_API void meshopt_spatialSortRemap(unsigned int* destination, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Experimental: Spatial sorter
|
|
|
|
|
|
|
+ * Spatial sorter
|
|
|
* Reorders triangles for spatial locality, and generates a new index buffer. The resulting index buffer can be used with other functions like optimizeVertexCache.
|
|
* Reorders triangles for spatial locality, and generates a new index buffer. The resulting index buffer can be used with other functions like optimizeVertexCache.
|
|
|
*
|
|
*
|
|
|
* destination must contain enough space for the resulting index buffer (index_count elements)
|
|
* destination must contain enough space for the resulting index buffer (index_count elements)
|
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
* vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
*/
|
|
*/
|
|
|
-MESHOPTIMIZER_EXPERIMENTAL void meshopt_spatialSortTriangles(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
|
|
|
|
|
+MESHOPTIMIZER_API void meshopt_spatialSortTriangles(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Spatial clusterizer
|
|
|
|
|
+ * Reorders points into clusters optimized for spatial locality, and generates a new index buffer.
|
|
|
|
|
+ * Ensures the output can be split into cluster_size chunks where each chunk has good positional locality. Only the last chunk will be smaller than cluster_size.
|
|
|
|
|
+ *
|
|
|
|
|
+ * destination must contain enough space for the resulting index buffer (vertex_count elements)
|
|
|
|
|
+ * vertex_positions should have float3 position in the first 12 bytes of each vertex
|
|
|
|
|
+ */
|
|
|
|
|
+MESHOPTIMIZER_API void meshopt_spatialClusterPoints(unsigned int* destination, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t cluster_size);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Quantize a float into half-precision (as defined by IEEE-754 fp16) floating point value
|
|
* Quantize a float into half-precision (as defined by IEEE-754 fp16) floating point value
|
|
@@ -813,13 +899,18 @@ template <typename T>
|
|
|
inline size_t meshopt_encodeIndexSequence(unsigned char* buffer, size_t buffer_size, const T* indices, size_t index_count);
|
|
inline size_t meshopt_encodeIndexSequence(unsigned char* buffer, size_t buffer_size, const T* indices, size_t index_count);
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
inline int meshopt_decodeIndexSequence(T* destination, size_t index_count, const unsigned char* buffer, size_t buffer_size);
|
|
inline int meshopt_decodeIndexSequence(T* destination, size_t index_count, const unsigned char* buffer, size_t buffer_size);
|
|
|
|
|
+inline size_t meshopt_encodeVertexBufferLevel(unsigned char* buffer, size_t buffer_size, const void* vertices, size_t vertex_count, size_t vertex_size, int level);
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
inline size_t meshopt_simplify(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options = 0, float* result_error = NULL);
|
|
inline size_t meshopt_simplify(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options = 0, float* result_error = NULL);
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
inline size_t meshopt_simplifyWithAttributes(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, const float* vertex_attributes, size_t vertex_attributes_stride, const float* attribute_weights, size_t attribute_count, const unsigned char* vertex_lock, size_t target_index_count, float target_error, unsigned int options = 0, float* result_error = NULL);
|
|
inline size_t meshopt_simplifyWithAttributes(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, const float* vertex_attributes, size_t vertex_attributes_stride, const float* attribute_weights, size_t attribute_count, const unsigned char* vertex_lock, size_t target_index_count, float target_error, unsigned int options = 0, float* result_error = NULL);
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
|
|
+inline size_t meshopt_simplifyWithUpdate(T* indices, size_t index_count, float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, float* vertex_attributes, size_t vertex_attributes_stride, const float* attribute_weights, size_t attribute_count, const unsigned char* vertex_lock, size_t target_index_count, float target_error, unsigned int options = 0, float* result_error = NULL);
|
|
|
|
|
+template <typename T>
|
|
|
inline size_t meshopt_simplifySloppy(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error = NULL);
|
|
inline size_t meshopt_simplifySloppy(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error = NULL);
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
|
|
+inline size_t meshopt_simplifyPrune(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, float target_error);
|
|
|
|
|
+template <typename T>
|
|
|
inline size_t meshopt_stripify(T* destination, const T* indices, size_t index_count, size_t vertex_count, T restart_index);
|
|
inline size_t meshopt_stripify(T* destination, const T* indices, size_t index_count, size_t vertex_count, T restart_index);
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
inline size_t meshopt_unstripify(T* destination, const T* indices, size_t index_count, T restart_index);
|
|
inline size_t meshopt_unstripify(T* destination, const T* indices, size_t index_count, T restart_index);
|
|
@@ -838,7 +929,7 @@ inline size_t meshopt_buildMeshletsScan(meshopt_Meshlet* meshlets, unsigned int*
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
inline size_t meshopt_buildMeshletsFlex(meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float cone_weight, float split_factor);
|
|
inline size_t meshopt_buildMeshletsFlex(meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float cone_weight, float split_factor);
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
-inline size_t meshopt_buildMeshletsSplit(meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float fill_weight);
|
|
|
|
|
|
|
+inline size_t meshopt_buildMeshletsSpatial(meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float fill_weight);
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
inline meshopt_Bounds meshopt_computeClusterBounds(const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
inline meshopt_Bounds meshopt_computeClusterBounds(const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride);
|
|
|
template <typename T>
|
|
template <typename T>
|
|
@@ -877,14 +968,21 @@ inline int meshopt_quantizeSnorm(float v, int N)
|
|
|
class meshopt_Allocator
|
|
class meshopt_Allocator
|
|
|
{
|
|
{
|
|
|
public:
|
|
public:
|
|
|
- template <typename T>
|
|
|
|
|
- struct StorageT
|
|
|
|
|
|
|
+ struct Storage
|
|
|
{
|
|
{
|
|
|
- static void* (MESHOPTIMIZER_ALLOC_CALLCONV* allocate)(size_t);
|
|
|
|
|
- static void (MESHOPTIMIZER_ALLOC_CALLCONV* deallocate)(void*);
|
|
|
|
|
|
|
+ void* (MESHOPTIMIZER_ALLOC_CALLCONV* allocate)(size_t);
|
|
|
|
|
+ void (MESHOPTIMIZER_ALLOC_CALLCONV* deallocate)(void*);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- typedef StorageT<void> Storage;
|
|
|
|
|
|
|
+#ifdef MESHOPTIMIZER_ALLOC_EXPORT
|
|
|
|
|
+ MESHOPTIMIZER_API static Storage& storage();
|
|
|
|
|
+#else
|
|
|
|
|
+ static Storage& storage()
|
|
|
|
|
+ {
|
|
|
|
|
+ static Storage s = {::operator new, ::operator delete };
|
|
|
|
|
+ return s;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
meshopt_Allocator()
|
|
meshopt_Allocator()
|
|
|
: blocks()
|
|
: blocks()
|
|
@@ -895,14 +993,14 @@ public:
|
|
|
~meshopt_Allocator()
|
|
~meshopt_Allocator()
|
|
|
{
|
|
{
|
|
|
for (size_t i = count; i > 0; --i)
|
|
for (size_t i = count; i > 0; --i)
|
|
|
- Storage::deallocate(blocks[i - 1]);
|
|
|
|
|
|
|
+ storage().deallocate(blocks[i - 1]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
T* allocate(size_t size)
|
|
T* allocate(size_t size)
|
|
|
{
|
|
{
|
|
|
assert(count < sizeof(blocks) / sizeof(blocks[0]));
|
|
assert(count < sizeof(blocks) / sizeof(blocks[0]));
|
|
|
- T* result = static_cast<T*>(Storage::allocate(size > size_t(-1) / sizeof(T) ? size_t(-1) : size * sizeof(T)));
|
|
|
|
|
|
|
+ T* result = static_cast<T*>(storage().allocate(size > size_t(-1) / sizeof(T) ? size_t(-1) : size * sizeof(T)));
|
|
|
blocks[count++] = result;
|
|
blocks[count++] = result;
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
@@ -910,7 +1008,7 @@ public:
|
|
|
void deallocate(void* ptr)
|
|
void deallocate(void* ptr)
|
|
|
{
|
|
{
|
|
|
assert(count > 0 && blocks[count - 1] == ptr);
|
|
assert(count > 0 && blocks[count - 1] == ptr);
|
|
|
- Storage::deallocate(ptr);
|
|
|
|
|
|
|
+ storage().deallocate(ptr);
|
|
|
count--;
|
|
count--;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -918,12 +1016,6 @@ private:
|
|
|
void* blocks[24];
|
|
void* blocks[24];
|
|
|
size_t count;
|
|
size_t count;
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
-// This makes sure that allocate/deallocate are lazily generated in translation units that need them and are deduplicated by the linker
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-void* (MESHOPTIMIZER_ALLOC_CALLCONV* meshopt_Allocator::StorageT<T>::allocate)(size_t) = operator new;
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-void (MESHOPTIMIZER_ALLOC_CALLCONV* meshopt_Allocator::StorageT<T>::deallocate)(void*) = operator delete;
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
/* Inline implementation for C++ templated wrappers */
|
|
/* Inline implementation for C++ templated wrappers */
|
|
@@ -945,7 +1037,7 @@ struct meshopt_IndexAdapter<T, false>
|
|
|
{
|
|
{
|
|
|
size_t size = count > size_t(-1) / sizeof(unsigned int) ? size_t(-1) : count * sizeof(unsigned int);
|
|
size_t size = count > size_t(-1) / sizeof(unsigned int) ? size_t(-1) : count * sizeof(unsigned int);
|
|
|
|
|
|
|
|
- data = static_cast<unsigned int*>(meshopt_Allocator::Storage::allocate(size));
|
|
|
|
|
|
|
+ data = static_cast<unsigned int*>(meshopt_Allocator::storage().allocate(size));
|
|
|
|
|
|
|
|
if (input)
|
|
if (input)
|
|
|
{
|
|
{
|
|
@@ -962,7 +1054,7 @@ struct meshopt_IndexAdapter<T, false>
|
|
|
result[i] = T(data[i]);
|
|
result[i] = T(data[i]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- meshopt_Allocator::Storage::deallocate(data);
|
|
|
|
|
|
|
+ meshopt_Allocator::storage().deallocate(data);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -1161,6 +1253,11 @@ inline int meshopt_decodeIndexSequence(T* destination, size_t index_count, const
|
|
|
return meshopt_decodeIndexSequence(destination, index_count, sizeof(T), buffer, buffer_size);
|
|
return meshopt_decodeIndexSequence(destination, index_count, sizeof(T), buffer, buffer_size);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+inline size_t meshopt_encodeVertexBufferLevel(unsigned char* buffer, size_t buffer_size, const void* vertices, size_t vertex_count, size_t vertex_size, int level)
|
|
|
|
|
+{
|
|
|
|
|
+ return meshopt_encodeVertexBufferLevel(buffer, buffer_size, vertices, vertex_count, vertex_size, level, -1);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
inline size_t meshopt_simplify(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options, float* result_error)
|
|
inline size_t meshopt_simplify(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options, float* result_error)
|
|
|
{
|
|
{
|
|
@@ -1179,13 +1276,30 @@ inline size_t meshopt_simplifyWithAttributes(T* destination, const T* indices, s
|
|
|
return meshopt_simplifyWithAttributes(out.data, in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, vertex_attributes, vertex_attributes_stride, attribute_weights, attribute_count, vertex_lock, target_index_count, target_error, options, result_error);
|
|
return meshopt_simplifyWithAttributes(out.data, in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, vertex_attributes, vertex_attributes_stride, attribute_weights, attribute_count, vertex_lock, target_index_count, target_error, options, result_error);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+template <typename T>
|
|
|
|
|
+inline size_t meshopt_simplifyWithUpdate(T* indices, size_t index_count, float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, float* vertex_attributes, size_t vertex_attributes_stride, const float* attribute_weights, size_t attribute_count, const unsigned char* vertex_lock, size_t target_index_count, float target_error, unsigned int options, float* result_error)
|
|
|
|
|
+{
|
|
|
|
|
+ meshopt_IndexAdapter<T> inout(indices, indices, index_count);
|
|
|
|
|
+
|
|
|
|
|
+ return meshopt_simplifyWithUpdate(inout.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, vertex_attributes, vertex_attributes_stride, attribute_weights, attribute_count, vertex_lock, target_index_count, target_error, options, result_error);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
inline size_t meshopt_simplifySloppy(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error)
|
|
inline size_t meshopt_simplifySloppy(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* result_error)
|
|
|
{
|
|
{
|
|
|
meshopt_IndexAdapter<T> in(NULL, indices, index_count);
|
|
meshopt_IndexAdapter<T> in(NULL, indices, index_count);
|
|
|
meshopt_IndexAdapter<T> out(destination, NULL, index_count);
|
|
meshopt_IndexAdapter<T> out(destination, NULL, index_count);
|
|
|
|
|
|
|
|
- return meshopt_simplifySloppy(out.data, in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, target_index_count, target_error, result_error);
|
|
|
|
|
|
|
+ return meshopt_simplifySloppy(out.data, in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, NULL, target_index_count, target_error, result_error);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+template <typename T>
|
|
|
|
|
+inline size_t meshopt_simplifyPrune(T* destination, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, float target_error)
|
|
|
|
|
+{
|
|
|
|
|
+ meshopt_IndexAdapter<T> in(NULL, indices, index_count);
|
|
|
|
|
+ meshopt_IndexAdapter<T> out(destination, NULL, index_count);
|
|
|
|
|
+
|
|
|
|
|
+ return meshopt_simplifyPrune(out.data, in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, target_error);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
template <typename T>
|
|
@@ -1263,11 +1377,11 @@ inline size_t meshopt_buildMeshletsFlex(meshopt_Meshlet* meshlets, unsigned int*
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
template <typename T>
|
|
|
-inline size_t meshopt_buildMeshletsSplit(meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float fill_weight)
|
|
|
|
|
|
|
+inline size_t meshopt_buildMeshletsSpatial(meshopt_Meshlet* meshlets, unsigned int* meshlet_vertices, unsigned char* meshlet_triangles, const T* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t max_vertices, size_t min_triangles, size_t max_triangles, float fill_weight)
|
|
|
{
|
|
{
|
|
|
meshopt_IndexAdapter<T> in(NULL, indices, index_count);
|
|
meshopt_IndexAdapter<T> in(NULL, indices, index_count);
|
|
|
|
|
|
|
|
- return meshopt_buildMeshletsSplit(meshlets, meshlet_vertices, meshlet_triangles, in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, max_vertices, min_triangles, max_triangles, fill_weight);
|
|
|
|
|
|
|
+ return meshopt_buildMeshletsSpatial(meshlets, meshlet_vertices, meshlet_triangles, in.data, index_count, vertex_positions, vertex_count, vertex_positions_stride, max_vertices, min_triangles, max_triangles, fill_weight);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
template <typename T>
|