xatlas: Sync with upstream ec707faea

ec707faeac
(cherry picked from commit 0b84b26b2e)
This commit is contained in:
Rémi Verschelde 2021-11-19 12:58:56 +01:00
parent 86ab8b2613
commit 322ff1f646
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 1298 additions and 846 deletions

View file

@ -542,12 +542,12 @@ File extracted from upstream release tarball:
## xatlas ## xatlas
- Upstream: https://github.com/jpcy/xatlas - Upstream: https://github.com/jpcy/xatlas
- Version: git (5571fc7ef0d06832947c0a935ccdcf083f7a9264, 2020) - Version: git (ec707faeac3b95e6b416076a9509718cce105b6a, 2021)
- License: MIT - License: MIT
Files extracted from upstream source: Files extracted from upstream source:
- `xatlas.{cpp,h}` - `source/xatlas/xatlas.{cpp,h}`
- `LICENSE` - `LICENSE`

File diff suppressed because it is too large Load diff

View file

@ -36,7 +36,8 @@ Copyright NVIDIA Corporation 2006 -- Ignacio Castano <icastano@nvidia.com>
namespace xatlas { namespace xatlas {
enum class ChartType { enum class ChartType
{
Planar, Planar,
Ortho, Ortho,
LSCM, LSCM,
@ -45,7 +46,8 @@ enum class ChartType {
}; };
// A group of connected faces, belonging to a single atlas. // A group of connected faces, belonging to a single atlas.
struct Chart { struct Chart
{
uint32_t *faceArray; uint32_t *faceArray;
uint32_t atlasIndex; // Sub-atlas index. uint32_t atlasIndex; // Sub-atlas index.
uint32_t faceCount; uint32_t faceCount;
@ -54,7 +56,8 @@ struct Chart {
}; };
// Output vertex. // Output vertex.
struct Vertex { struct Vertex
{
int32_t atlasIndex; // Sub-atlas index. -1 if the vertex doesn't exist in any atlas. int32_t atlasIndex; // Sub-atlas index. -1 if the vertex doesn't exist in any atlas.
int32_t chartIndex; // -1 if the vertex doesn't exist in any chart. int32_t chartIndex; // -1 if the vertex doesn't exist in any chart.
float uv[2]; // Not normalized - values are in Atlas width and height range. float uv[2]; // Not normalized - values are in Atlas width and height range.
@ -62,7 +65,8 @@ struct Vertex {
}; };
// Output mesh. // Output mesh.
struct Mesh { struct Mesh
{
Chart *chartArray; Chart *chartArray;
uint32_t *indexArray; uint32_t *indexArray;
Vertex *vertexArray; Vertex *vertexArray;
@ -77,7 +81,8 @@ static const uint32_t kImageIsBilinearBit = 0x40000000;
static const uint32_t kImageIsPaddingBit = 0x20000000; static const uint32_t kImageIsPaddingBit = 0x20000000;
// Empty on creation. Populated after charts are packed. // Empty on creation. Populated after charts are packed.
struct Atlas { struct Atlas
{
uint32_t *image; uint32_t *image;
Mesh *meshes; // The output meshes, corresponding to each AddMesh call. Mesh *meshes; // The output meshes, corresponding to each AddMesh call.
float *utilization; // Normalized atlas texel utilization array. E.g. a value of 0.8 means 20% empty space. atlasCount in length. float *utilization; // Normalized atlas texel utilization array. E.g. a value of 0.8 means 20% empty space. atlasCount in length.
@ -94,13 +99,15 @@ Atlas *Create();
void Destroy(Atlas *atlas); void Destroy(Atlas *atlas);
enum class IndexFormat { enum class IndexFormat
{
UInt16, UInt16,
UInt32 UInt32
}; };
// Input mesh declaration. // Input mesh declaration.
struct MeshDecl { struct MeshDecl
{
const void *vertexPositionData = nullptr; const void *vertexPositionData = nullptr;
const void *vertexNormalData = nullptr; // optional const void *vertexNormalData = nullptr; // optional
const void *vertexUvData = nullptr; // optional. The input UVs are provided as a hint to the chart generator. const void *vertexUvData = nullptr; // optional. The input UVs are provided as a hint to the chart generator.
@ -131,7 +138,8 @@ struct MeshDecl {
float epsilon = 1.192092896e-07F; float epsilon = 1.192092896e-07F;
}; };
enum class AddMeshError { enum class AddMeshError
{
Success, // No error. Success, // No error.
Error, // Unspecified error. Error, // Unspecified error.
IndexOutOfRange, // An index is >= MeshDecl vertexCount. IndexOutOfRange, // An index is >= MeshDecl vertexCount.
@ -145,7 +153,8 @@ AddMeshError AddMesh(Atlas *atlas, const MeshDecl &meshDecl, uint32_t meshCountH
// Wait for AddMesh async processing to finish. ComputeCharts / Generate call this internally. // Wait for AddMesh async processing to finish. ComputeCharts / Generate call this internally.
void AddMeshJoin(Atlas *atlas); void AddMeshJoin(Atlas *atlas);
struct UvMeshDecl { struct UvMeshDecl
{
const void *vertexUvData = nullptr; const void *vertexUvData = nullptr;
const void *indexData = nullptr; // optional const void *indexData = nullptr; // optional
const uint32_t *faceMaterialData = nullptr; // Optional. Overlapping UVs should be assigned a different material. Must be indexCount / 3 in length. const uint32_t *faceMaterialData = nullptr; // Optional. Overlapping UVs should be assigned a different material. Must be indexCount / 3 in length.
@ -161,7 +170,8 @@ AddMeshError AddUvMesh(Atlas *atlas, const UvMeshDecl &decl);
// Custom parameterization function. texcoords initial values are an orthogonal parameterization. // Custom parameterization function. texcoords initial values are an orthogonal parameterization.
typedef void (*ParameterizeFunc)(const float *positions, float *texcoords, uint32_t vertexCount, const uint32_t *indices, uint32_t indexCount); typedef void (*ParameterizeFunc)(const float *positions, float *texcoords, uint32_t vertexCount, const uint32_t *indices, uint32_t indexCount);
struct ChartOptions { struct ChartOptions
{
ParameterizeFunc paramFunc = nullptr; ParameterizeFunc paramFunc = nullptr;
float maxChartArea = 0.0f; // Don't grow charts to be larger than this. 0 means no limit. float maxChartArea = 0.0f; // Don't grow charts to be larger than this. 0 means no limit.
@ -184,7 +194,8 @@ struct ChartOptions {
// Call after all AddMesh calls. Can be called multiple times to recompute charts with different options. // Call after all AddMesh calls. Can be called multiple times to recompute charts with different options.
void ComputeCharts(Atlas *atlas, ChartOptions options = ChartOptions()); void ComputeCharts(Atlas *atlas, ChartOptions options = ChartOptions());
struct PackOptions { struct PackOptions
{
// Charts larger than this will be scaled down. 0 means no limit. // Charts larger than this will be scaled down. 0 means no limit.
uint32_t maxChartSize = 0; uint32_t maxChartSize = 0;
@ -227,7 +238,8 @@ void PackCharts(Atlas *atlas, PackOptions packOptions = PackOptions());
void Generate(Atlas *atlas, ChartOptions chartOptions = ChartOptions(), PackOptions packOptions = PackOptions()); void Generate(Atlas *atlas, ChartOptions chartOptions = ChartOptions(), PackOptions packOptions = PackOptions());
// Progress tracking. // Progress tracking.
enum class ProgressCategory { enum class ProgressCategory
{
AddMesh, AddMesh,
ComputeCharts, ComputeCharts,
PackCharts, PackCharts,