docs: add XML summary comments to public Meshlet types and methods #3
@@ -2,9 +2,15 @@ using System.Numerics;
|
|||||||
|
|
||||||
namespace Ghost.Graphics.Meshlet;
|
namespace Ghost.Graphics.Meshlet;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the bounding sphere and simplification error for a LOD cluster.
|
||||||
|
/// </summary>
|
||||||
public struct ClodBounds
|
public struct ClodBounds
|
||||||
{
|
{
|
||||||
|
/// <summary> The center of the bounding sphere. </summary>
|
||||||
public Vector3 center;
|
public Vector3 center;
|
||||||
|
/// <summary> The radius of the bounding sphere. </summary>
|
||||||
public float radius;
|
public float radius;
|
||||||
|
/// <summary> The simplification error associated with this LOD level. </summary>
|
||||||
public float error;
|
public float error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,19 @@ internal struct Cluster
|
|||||||
public ClodBounds bounds;
|
public ClodBounds bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides methods to build a hierarchical Cluster LOD mesh.
|
||||||
|
/// </summary>
|
||||||
public unsafe static class ClodBuilder
|
public unsafe static class ClodBuilder
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Builds a cluster LOD hierarchy from the input mesh.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">The configuration parameters for the LOD building process.</param>
|
||||||
|
/// <param name="mesh">The input mesh data.</param>
|
||||||
|
/// <param name="outputContext">Optional context pointer passed to the output callback.</param>
|
||||||
|
/// <param name="outputCallback">Delegate invoked for each generated LOD group.</param>
|
||||||
|
/// <returns>The total count of generated clusters.</returns>
|
||||||
public static nuint Build(ClodConfig config, ClodMesh mesh, void* outputContext, ClodOutputDelegate outputCallback)
|
public static nuint Build(ClodConfig config, ClodMesh mesh, void* outputContext, ClodOutputDelegate outputCallback)
|
||||||
{
|
{
|
||||||
Debug.Assert(mesh.vertexAttributesStride % (nuint)sizeof(float) == 0, "vertexAttributesStride must be a multiple of sizeof(float)");
|
Debug.Assert(mesh.vertexAttributesStride % (nuint)sizeof(float) == 0, "vertexAttributesStride must be a multiple of sizeof(float)");
|
||||||
|
|||||||
@@ -1,37 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
namespace Ghost.Graphics.Meshlet;
|
namespace Ghost.Graphics.Meshlet;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration parameters for the cluster LOD generation pipeline.
|
||||||
|
/// </summary>
|
||||||
public struct ClodConfig
|
public struct ClodConfig
|
||||||
{
|
{
|
||||||
|
/// <summary> The maximum number of vertices per meshlet. </summary>
|
||||||
public nuint maxVertices;
|
public nuint maxVertices;
|
||||||
|
/// <summary> The minimum number of triangles per meshlet. </summary>
|
||||||
public nuint minTriangles;
|
public nuint minTriangles;
|
||||||
|
/// <summary> The maximum number of triangles per meshlet. </summary>
|
||||||
public nuint maxTriangles;
|
public nuint maxTriangles;
|
||||||
|
/// <summary> Whether to use spatial partitioning during meshlet building. </summary>
|
||||||
public bool partitionSpatial;
|
public bool partitionSpatial;
|
||||||
|
/// <summary> Whether to sort clusters after partitioning. </summary>
|
||||||
public bool partitionSort;
|
public bool partitionSort;
|
||||||
|
/// <summary> The target size for partitions. </summary>
|
||||||
public nuint partitionSize;
|
public nuint partitionSize;
|
||||||
|
/// <summary> Whether to cluster meshlets using spatial clustering. </summary>
|
||||||
public bool clusterSpatial;
|
public bool clusterSpatial;
|
||||||
|
/// <summary> Weight factor for cluster fill calculation. </summary>
|
||||||
public float clusterFillWeight;
|
public float clusterFillWeight;
|
||||||
|
/// <summary> Split factor for flexible clustering. </summary>
|
||||||
public float clusterSplitFactor;
|
public float clusterSplitFactor;
|
||||||
|
/// <summary> The simplification ratio to achieve per LOD level. </summary>
|
||||||
public float simplifyRatio;
|
public float simplifyRatio;
|
||||||
|
/// <summary> Threshold for stopping simplification. </summary>
|
||||||
public float simplifyThreshold;
|
public float simplifyThreshold;
|
||||||
|
/// <summary> Error factor used when merging previous LOD level errors. </summary>
|
||||||
public float simplifyErrorMergePrevious;
|
public float simplifyErrorMergePrevious;
|
||||||
|
/// <summary> Additive error factor when merging LOD levels. </summary>
|
||||||
public float simplifyErrorMergeAdditive;
|
public float simplifyErrorMergeAdditive;
|
||||||
|
/// <summary> Error factor for sloppy simplification. </summary>
|
||||||
public float simplifyErrorFactorSloppy;
|
public float simplifyErrorFactorSloppy;
|
||||||
|
/// <summary> Edge length limit error factor. </summary>
|
||||||
public float simplifyErrorEdgeLimit;
|
public float simplifyErrorEdgeLimit;
|
||||||
|
/// <summary> Whether to allow permissive simplification. </summary>
|
||||||
public bool simplifyPermissive;
|
public bool simplifyPermissive;
|
||||||
|
/// <summary> Whether to fallback to permissive simplification. </summary>
|
||||||
public bool simplifyFallbackPermissive;
|
public bool simplifyFallbackPermissive;
|
||||||
|
/// <summary> Whether to fallback to sloppy simplification. </summary>
|
||||||
public bool simplifyFallbackSloppy;
|
public bool simplifyFallbackSloppy;
|
||||||
|
/// <summary> Whether to regularize the mesh during simplification. </summary>
|
||||||
public bool simplifyRegularize;
|
public bool simplifyRegularize;
|
||||||
|
/// <summary> Whether to optimize cluster bounds. </summary>
|
||||||
public bool optimizeBounds;
|
public bool optimizeBounds;
|
||||||
|
/// <summary> Whether to optimize clusters post-build. </summary>
|
||||||
public bool optimizeClusters;
|
public bool optimizeClusters;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +1,63 @@
|
|||||||
using System;
|
|
||||||
using Ghost.MeshOptimizer;
|
|
||||||
using Misaki.HighPerformance.LowLevel.Collections;
|
|
||||||
using Misaki.HighPerformance.LowLevel;
|
|
||||||
using Misaki.HighPerformance.LowLevel.Buffer;
|
|
||||||
|
|
||||||
namespace Ghost.Graphics.Meshlet;
|
namespace Ghost.Graphics.Meshlet;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains input data for the Cluster LOD generation pipeline.
|
||||||
|
/// </summary>
|
||||||
public unsafe struct ClodMesh
|
public unsafe struct ClodMesh
|
||||||
{
|
{
|
||||||
|
/// <summary> Pointer to vertex position data (float array). </summary>
|
||||||
public float* vertexPositions;
|
public float* vertexPositions;
|
||||||
|
/// <summary> Number of vertices in the mesh. </summary>
|
||||||
public nuint vertexCount;
|
public nuint vertexCount;
|
||||||
|
/// <summary> Stride in bytes for vertex position data. </summary>
|
||||||
public nuint vertexPositionsStride;
|
public nuint vertexPositionsStride;
|
||||||
|
/// <summary> Pointer to vertex attribute data (float array). </summary>
|
||||||
public float* vertexAttributes;
|
public float* vertexAttributes;
|
||||||
|
/// <summary> Stride in bytes for vertex attribute data. </summary>
|
||||||
public nuint vertexAttributesStride;
|
public nuint vertexAttributesStride;
|
||||||
|
/// <summary> Pointer to attribute weights for simplification. </summary>
|
||||||
public float* attributeWeights;
|
public float* attributeWeights;
|
||||||
|
/// <summary> Number of vertex attributes. </summary>
|
||||||
public nuint attributeCount;
|
public nuint attributeCount;
|
||||||
|
/// <summary> Pointer to index data. </summary>
|
||||||
public uint* indices;
|
public uint* indices;
|
||||||
|
/// <summary> Number of indices in the mesh. </summary>
|
||||||
public nuint indexCount;
|
public nuint indexCount;
|
||||||
|
/// <summary> Pointer to per-vertex lock flags (1 byte per vertex). </summary>
|
||||||
public byte* vertexLock;
|
public byte* vertexLock;
|
||||||
|
/// <summary> Mask indicating which attributes are protected during simplification. </summary>
|
||||||
public uint attributeProtectMask;
|
public uint attributeProtectMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a group of clusters in the LOD hierarchy.
|
||||||
|
/// </summary>
|
||||||
public struct ClodGroup
|
public struct ClodGroup
|
||||||
{
|
{
|
||||||
|
/// <summary> LOD hierarchy depth of this group. </summary>
|
||||||
public int depth;
|
public int depth;
|
||||||
|
/// <summary> Bounding information for the simplified group. </summary>
|
||||||
public ClodBounds simplified;
|
public ClodBounds simplified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a cluster of meshlets in the LOD hierarchy.
|
||||||
|
/// </summary>
|
||||||
public unsafe struct ClodCluster
|
public unsafe struct ClodCluster
|
||||||
{
|
{
|
||||||
|
/// <summary> Refinement level of the cluster. </summary>
|
||||||
public int refined;
|
public int refined;
|
||||||
|
/// <summary> Bounding info for the cluster. </summary>
|
||||||
public ClodBounds bounds;
|
public ClodBounds bounds;
|
||||||
|
/// <summary> Pointer to indices for this cluster. </summary>
|
||||||
public uint* indices;
|
public uint* indices;
|
||||||
|
/// <summary> Number of indices. </summary>
|
||||||
public nuint indexCount;
|
public nuint indexCount;
|
||||||
|
/// <summary> Number of vertices in the cluster. </summary>
|
||||||
public nuint vertexCount;
|
public nuint vertexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate type for processing generated LOD groups.
|
||||||
|
/// </summary>
|
||||||
public unsafe delegate int ClodOutputDelegate(void* context, ClodGroup group, ClodCluster* clusters, nuint clusterCount);
|
public unsafe delegate int ClodOutputDelegate(void* context, ClodGroup group, ClodCluster* clusters, nuint clusterCount);
|
||||||
|
|||||||
Reference in New Issue
Block a user