XII Release 0.1.0
Loading...
Searching...
No Matches
xiiMeshResourceDescriptor Class Reference

#include <MeshResource.h>

Public Member Functions

xiiMeshBufferResourceDescriptor & GetMeshBufferDescriptor ()
 Returns a reference to the mesh buffer resource descriptor contained within this mesh resource descriptor.
const xiiMeshBufferResourceDescriptor & GetMeshBufferDescriptor () const
 Returns a reference to the mesh buffer resource descriptor contained within this mesh resource descriptor.
const xiiMeshBufferResourceHandle & GetExistingMeshBuffer () const
 Returns a handle to an existing mesh buffer resource that can be used for this mesh resource, or an invalid handle if no existing mesh buffer can be used.
xiiArrayPtr< const xiiString > GetMaterials () const
 Returns a reference to the array of material paths contained within this mesh resource descriptor.
xiiArrayPtr< const xiiMeshSection > GetSubMeshes () const
 Returns a reference to the array of sections contained within this mesh resource descriptor.
xiiArrayPtr< xiiMeshLOD > GetLODs ()
 Returns a reference to the array of LODs contained within this mesh resource descriptor.
xiiArrayPtr< const xiiMeshLOD > GetLODs () const
const xiiBoundingBoxSphere & GetBounds () const
 Returns the bounding volume for this mesh resource, used for culling and LOD selection.
 xiiMeshResourceDescriptor ()
 Default constructor, initializes an empty mesh resource descriptor.
void Clear ()
 Clears all data from the descriptor, resetting it to an empty state.
void UseExistingMeshBuffer (const xiiMeshBufferResourceHandle &hBuffer)
 Specifies that the mesh buffer for this mesh resource should be created from the given descriptor, instead of using an existing mesh buffer resource.
xiiUInt32 AddMaterialSlot (xiiStringView sPathToMaterial)
 Adds a new material slot to the mesh resource descriptor with the given path, and returns the index of the new material slot.
void SetMaterial (xiiUInt32 uiMaterialIndex, xiiStringView sPathToMaterial)
xiiMeshSection & AddSection (xiiUInt32 uiPrimitiveCount, xiiUInt32 uiFirstPrimitive, xiiUInt32 uiMaterialIndex, xiiUInt32 uiLodIndex=0U)
void AddSubMesh (xiiUInt32 uiPrimitiveCount, xiiUInt32 uiFirstPrimitive, xiiUInt32 uiMaterialIndex)
xiiMeshLOD & AddLOD (float fScreenSize, float fMaxDistance=0.0f)
void CollapseSubMeshes ()
 Collapses all sub-meshes (sections at LOD 0) into a single section, used to optimize meshes that have multiple small sections.
void ComputeBounds ()
 Computes the bounding volume for the mesh resource based on the vertex data in the mesh buffer descriptor, used for culling and LOD selection.
xiiResult BuildMeshlets (xiiUInt32 uiMaxVertices=64U, xiiUInt32 uiMaxPrimitives=124U)
void SetBounds (const xiiBoundingBoxSphere &bounds)
 Sets the bounding volume for this mesh resource, used for culling and LOD selection.
void Save (xiiStreamWriter &inout_stream) const
xiiResult Save (xiiStringView sFile) const
xiiResult Load (xiiStreamReader &inout_stream)
xiiResult Load (xiiStringView sFile)

Public Attributes

xiiBitflags< xiiMeshResourceUsageFlags > m_UsageFlags = xiiMeshResourceUsageFlags::Default
 Usage flags for this mesh resource, used to specify intended usage patterns and GPU feature support.
xiiEnum< xiiMeshLodSelectionMode > m_LodMode = xiiMeshLodSelectionMode::ScreenSize
 LOD selection mode for this mesh resource.
xiiUInt32 m_uiStreamingGroup = 0U
 Streaming group index for this mesh resource, used to group meshes for streaming purposes.
xiiUInt32 m_uiMaxResidentLod = 0U
 Maximum resident LOD index for this mesh resource, used to control how many LODs are kept in memory when streaming.
xiiUInt32 m_uiRuntimeHash = 0U
 Runtime hash for this mesh resource, used for quick comparisons and lookups at runtime.
xiiSkeletonResourceHandle m_hDefaultSkeleton
 Handle to the default skeleton resource for this mesh, used for skeletal animation when no specific skeleton is assigned.
xiiHashTable< xiiHashedString, xiiMeshBoneData > m_Bones
 Hash table mapping bone names to bone data for this mesh, used for skeletal animation.
xiiDynamicArray< xiiMeshMorphTarget > m_MorphTargets
 Array of morph targets for this mesh, used for shape animation.
float m_fMaxBoneVertexOffset = 0.0f
 Maximum vertex offset caused by bone influences in this mesh, used for bounding volume calculations and culling of skinned meshes.

Detailed Description

Authoring and streaming descriptor for xiiMeshResource.

The descriptor is intentionally GPU-first, that is, sections and LODs are defined in primitive/meshlet ranges, and material slots are handles/paths. The mesh buffer descriptor contains the packed vertex/index/meshlet payload that is uploaded to GAL buffers by xiiMeshBufferResource.

Member Function Documentation

◆ AddLOD()

xiiMeshLOD & xiiMeshResourceDescriptor::AddLOD ( float fScreenSize,
float fMaxDistance = 0.0f )

Adds a new LOD to the mesh resource descriptor with the given properties, and returns a reference to the new LOD.

Parameters
fScreenSizeScreen size threshold for this LOD, used for LOD selection when m_LodMode is xiiMeshLodSelectionMode::ScreenSize.
fMaxDistanceMaximum distance for this LOD, used for LOD selection.
Returns
Reference to the newly added LOD, which can be further modified (e.g., by adding sections to it).

◆ AddSection()

xiiMeshSection & xiiMeshResourceDescriptor::AddSection ( xiiUInt32 uiPrimitiveCount,
xiiUInt32 uiFirstPrimitive,
xiiUInt32 uiMaterialIndex,
xiiUInt32 uiLodIndex = 0U )

Adds a new section to the mesh resource descriptor with the given properties, and returns a reference to the new section.

Parameters
uiPrimitiveCountNumber of primitives in this section, used for rendering and culling.
uiFirstPrimitiveIndex of the first primitive in this section, used for rendering and culling.
uiMaterialIndexIndex into the mesh's material array for the material used by this section, used for rendering.
uiLodIndexIndex of the LOD to which this section belongs. If the specified LOD does not exist, it will be created. If uiLodIndex is greater than 0, the section will be added to the specified LOD; otherwise, it will be added as a sub-mesh (section at LOD 0).

◆ AddSubMesh()

void xiiMeshResourceDescriptor::AddSubMesh ( xiiUInt32 uiPrimitiveCount,
xiiUInt32 uiFirstPrimitive,
xiiUInt32 uiMaterialIndex )

Adds a new sub-mesh (section at LOD 0) to the mesh resource descriptor with the given properties.

Parameters
uiPrimitiveCountNumber of primitives in this sub-mesh, used for rendering and culling.
uiFirstPrimitiveIndex of the first primitive in this sub-mesh, used for rendering and culling.
uiMaterialIndexIndex into the mesh's material array for the material used by this sub-mesh, used for rendering.

◆ BuildMeshlets()

xiiResult xiiMeshResourceDescriptor::BuildMeshlets ( xiiUInt32 uiMaxVertices = 64U,
xiiUInt32 uiMaxPrimitives = 124U )

Builds meshlets for the mesh resource based on the sections and LODs defined in the descriptor, used for rendering with mesh shaders.

Parameters
uiMaxVerticesMaximum number of vertices per meshlet, used to control the size of meshlets for rendering.
uiMaxPrimitivesMaximum number of primitives per meshlet, used to control the size of meshlets for rendering. Clusters each section independently and stores contiguous LOD ranges. Returns failure for invalid section topology or geometry, clearing generated ranges and MeshShaderReady. Shared GPU buffers retain their supplied ranges; point/line meshes succeed without clusters.

◆ SetMaterial()

void xiiMeshResourceDescriptor::SetMaterial ( xiiUInt32 uiMaterialIndex,
xiiStringView sPathToMaterial )

Sets the material path for the material slot at the given index.

Parameters
uiMaterialIndexIndex of the material slot to set, must be less than the number of material slots in the descriptor.
sPathToMaterialPath to the material to set for this material slot.

The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/GraphicsCore/Meshes/MeshResource.h
  • /home/runner/work/XII/XII/Source/Engine/GraphicsCore/Meshes/Implementation/MeshResourceDescriptor.cpp