8#include <QtCore/QVector>
9#include <QtQuick3DUtils/private/qssgdataref_p.h>
10#include <QtQuick3DUtils/private/qssglightmapuvgenerator_p.h>
12#include "meshoptimizer.h"
621 const quint32 leftover = (align > 0) ? offset % align : 0;
623 return offset + (align - leftover);
786 const char *
name =
nullptr;
854 const char *
name =
nullptr;
877 *
error =
QObject::
tr(
"Warning: Invalid target attribute semantic: %1")
884 *
error =
QObject::
tr(
"Warning: Invalid target attribute semantic: %1")
891 if (
stride == 4 *
sizeof(
float)) {
924 qWarning(
"There is existing data, but mesh file header is invalid; cannot save");
1038 qWarning(
"Lightmap UV unwrapping encountered a Mesh with 0 vertex stride, this cannot happen");
1042 qWarning(
"Lightmap UV unwrapping encountered a Mesh without index data, this cannot happen");
1053 qWarning(
"Lightmap UV unwrapping encountered a Mesh non-float3 position data, this cannot happen");
1059 qWarning(
"Lightmap UV unwrapping encountered a Mesh non-float3 normal data, this cannot happen");
1065 qWarning(
"Lightmap UV unwrapping encountered a Mesh non-float2 UV0 data, this cannot happen");
1073 qWarning(
"Lightmap UV unwrapping encountered a Mesh without vertex positions, this cannot happen");
1136 qWarning(
"Index buffer size mismatch after lightmap UV unwrapping");
1143 qWarning(
"Index buffer size mismatch after lightmap UV unwrapping");
1259size_t simplifyMesh(
unsigned int *destination,
const unsigned int *indices, size_t indexCount,
const float *vertexPositions, size_t vertexCount, size_t vertexPositionsStride, size_t targetIndexCount,
float targetError,
unsigned int options,
float *resultError)
1261 return meshopt_simplify(destination, indices, indexCount, vertexPositions, vertexCount, vertexPositionsStride, targetIndexCount, targetError, options, resultError);
1264float simplifyScale(
const float *vertexPositions, size_t vertexCount, size_t vertexPositionsStride)
1266 return meshopt_simplifyScale(vertexPositions, vertexCount, vertexPositionsStride);
1269void optimizeVertexCache(
unsigned int *destination,
const unsigned int *indices, size_t indexCount, size_t vertexCount)
1271 meshopt_optimizeVertexCache(destination, indices, indexCount, vertexCount);
1275 const unsigned int *indices,
1281 Q_ASSERT(streamCount > 0 && streamCount <= maxVertexStreams);
1282 QVarLengthArray<meshopt_Stream, 16> meshoptStreams;
1283 for (size_t i = 0; i < streamCount; ++i)
1284 meshoptStreams.append({ streams[i].data, streams[i].elementSize, streams[i].stride });
1285 return meshopt_generateVertexRemapMulti(destination, indices, indexCount, vertexCount,
1286 meshoptStreams.constData(), streamCount);
1290 const void *vertices,
1293 const unsigned int *remap)
1295 meshopt_remapVertexBuffer(destination, vertices, vertexCount, vertexSize, remap);
1299 const unsigned int *indices,
1301 const unsigned int *remap)
1303 meshopt_remapIndexBuffer(destination, indices, indexCount, remap);
float simplifyScale(const float *vertexPositions, size_t vertexCount, size_t vertexPositionsStride)
static const size_t MESH_STRUCT_SIZE
void remapVertexBuffer(void *destination, const void *vertices, size_t vertexCount, size_t vertexSize, const unsigned int *remap)
static const size_t SUBSET_STRUCT_SIZE_V3_V4
static const size_t VERTEX_BUFFER_ENTRY_STRUCT_SIZE
static const size_t MULTI_ENTRY_STRUCT_SIZE
static const size_t SUBSET_STRUCT_SIZE_V6
size_t simplifyMesh(unsigned int *destination, const unsigned int *indices, size_t indexCount, const float *vertexPositions, size_t vertexCount, size_t vertexPositionsStride, size_t targetIndexCount, float targetError, unsigned int options, float *resultError)
static const size_t MULTI_HEADER_STRUCT_SIZE
size_t generateVertexRemap(unsigned int *destination, const unsigned int *indices, size_t indexCount, size_t vertexCount, const MeshVertexStream *streams, size_t streamCount)
static const size_t LOD_STRUCT_SIZE
void optimizeVertexCache(unsigned int *destination, const unsigned int *indices, size_t indexCount, size_t vertexCount)
static const size_t MESH_HEADER_STRUCT_SIZE
static const size_t SUBSET_STRUCT_SIZE_V5
static quint32 getAlignedOffset(quint32 offset, quint32 align)
void remapIndexBuffer(unsigned int *destination, const unsigned int *indices, size_t indexCount, const unsigned int *remap)