Files
sbox-public/engine/Sandbox.Engine/Resources/Model/Model.VertexData.cs
Antoine Pilote 5cbff413b4 Clutter culling (#5108)
Adds GPU culling
Fixed collision not working for painted instances
LOD is selected on the GPU now

Improvements on our benchmark: 32ms down to 8ms in some cases
2026-07-01 12:22:54 -07:00

54 lines
1.3 KiB
C#

using NativeEngine;
namespace Sandbox;
public partial class Model
{
/// <summary>
/// Experimental!
/// </summary>
public unsafe Vertex[] GetVertices()
{
int numVertices = MeshGlue.GetModelNumVertices( native );
if ( numVertices == 0 )
return null;
var vertices = new Vertex[numVertices];
fixed ( Vertex* vmem = &vertices[0] )
{
MeshGlue.GetModelVertices( native, (IntPtr)vmem, (uint)numVertices );
}
return vertices;
}
/// <summary>
/// Experimental!
/// </summary>
public unsafe uint[] GetIndices()
{
int numIndices = MeshGlue.GetModelNumIndices( native );
if ( numIndices == 0 )
return null;
var indices = new uint[numIndices];
fixed ( uint* vmem = &indices[0] )
{
MeshGlue.GetModelIndices( native, (IntPtr)vmem, (uint)numIndices );
}
return indices;
}
public int GetIndexCount( int drawcall ) => MeshGlue.GetModelIndexCount( native, drawcall );
public int GetIndexStart( int drawcall ) => MeshGlue.GetModelIndexStart( native, drawcall );
public int GetBaseVertex( int drawcall ) => MeshGlue.GetModelBaseVertex( native, drawcall );
/// <summary>
/// Index count of the mesh drawn at the given LOD.
/// </summary>
public int GetIndexCountForLod( int lod ) => MeshGlue.GetModelLodIndexCount( native, lod );
}