Watch
2
0
Fork
You've already forked raylib-cs
0

Improved XML comments for clarity and consistency in Model.cs and Mesh.cs, updated method and variable names for better readability, and adjusted logic in span creation methods.

This commit is contained in:
Meatcorps 2026-05-23 13:31:54 +02:00
commit d45ea89a4b
2 changed files with 50 additions and 14 deletions

View file

@ -189,22 +189,22 @@ public unsafe struct Mesh
public int BoneCount;
/// <summary>
/// Vertex bone ids, up to 4 bones influence by vertex (skinning)
/// Vertex bone indices, up to 4 bones influence by vertex (skinning) (shader-location = 6)
/// </summary>
public byte* boneIndices = default;
public byte* BoneIndices = default;
/// <summary>
/// Vertex bone weight, up to 4 bones influence by vertex (skinning)
/// Vertex bone weight, up to 4 bones influence by vertex (skinning) (shader-location = 7)
/// </summary>
public float* BoneWeights = default;
/// <summary>
/// Animated vertex positions after bones transformations, CPU skinning
/// Animated vertex positions (after bones transformations)
/// </summary>
public float* AnimVertices = default;
/// <summary>
/// Animated normals after bones transformations, CPU skinning
/// Animated normals (after bones transformations)
/// </summary>
public float* AnimNormals = default;
@ -218,7 +218,7 @@ public unsafe struct Mesh
public uint VaoId = default;
/// <summary>
/// OpenGL Vertex Buffer Objects id (default vertex data, uint[])
/// OpenGL Vertex Buffer Objects id (default vertex data)
/// </summary>
public uint* VboId = default;

View file

@ -20,6 +20,9 @@ public unsafe struct BoneInfo
/// </summary>
public int Parent;
/// <summary>
/// Bone name as string
/// </summary>
public string NameToString()
{
fixed (sbyte* name = Name)
@ -48,16 +51,20 @@ public unsafe struct ModelSkeleton
/// <summary>
/// Bones base transformation (Transform[])
/// </summary>
public Transform* ModelAnimPose;
public Transform* BindPose;
public Span<Transform> ModelAnimPoseAsSpan()
public Span<Transform> BindPoseAsSpan()
{
return new Span<Transform>(ModelAnimPose, BoneCount);
if (BindPose == null || BoneCount <= 0)
{
return Span<Transform>.Empty;
}
return new Span<Transform>(BindPose, BoneCount);
}
public Span<BoneInfo> BonesAsSpan()
{
if (Bones == null || BoneCount <= 0)
{
return Span<BoneInfo>.Empty;
@ -69,7 +76,7 @@ public unsafe struct ModelSkeleton
// Note:
// Anim pose, an array of Transform[]
// typedef Transform *ModelAnimPose; It's just an pointer array.
// typedef Transform *ModelAnimPose; It's just a pointer array.
/// <summary>
/// Model type
@ -122,26 +129,48 @@ public unsafe struct Model
/// </summary>
public Matrix4x4* BoneMatrices;
/// <summary>
/// Bones animated transformation matrices as span. Based on Skeleton.BoneCount length
/// </summary>
public Span<Matrix4x4> BoneMatricesAsSpan()
{
if (BoneMatrices == null || Skeleton.BoneCount <= 0)
{
return Span<Matrix4x4>.Empty;
}
return new Span<Matrix4x4>(BoneMatrices, Skeleton.BoneCount);
}
/// <summary>
/// Current animation pose as span. Based on Skeleton.BoneCount length
/// </summary>
public Span<Transform> CurrentPoseAsSpan()
{
if (CurrentPose == null || Skeleton.BoneCount <= 0)
{
return Span<Transform>.Empty;
}
return new Span<Transform>(CurrentPose, Skeleton.BoneCount);
}
/// <summary>
/// Mesh material number as span. Based on MaterialCount length
/// </summary>
public Span<int> MeshMaterialAsSpan()
{
if (MeshMaterial == null || MeshCount <= 0)
if (MeshMaterial == null || MaterialCount <= 0)
{
return Span<int>.Empty;
}
return new Span<int>(MeshMaterial, MeshCount);
return new Span<int>(MeshMaterial, MaterialCount);
}
/// <summary>
/// Meshes as span. based on MeshCount length
/// </summary>
public Span<Mesh> MeshesAsSpan()
{
if (Meshes == null || MeshCount <= 0)
@ -170,7 +199,7 @@ public unsafe struct ModelAnimation
public readonly int BoneCount;
/// <summary>
/// Number of animation frames
/// Number of animation key frames
/// </summary>
public readonly int KeyFrameCount;
@ -179,6 +208,10 @@ public unsafe struct ModelAnimation
/// </summary>
public Transform** KeyframePoses;
/// <summary>
/// Animation sequence keyframe poses as span. Based on KeyFrameCount length
/// </summary>
public Span<Transform> GetKeyFramePoseAsSpan(int frame)
{
if (KeyframePoses == null || frame < 0 || frame >= KeyFrameCount)
@ -196,6 +229,9 @@ public unsafe struct ModelAnimation
return new Span<Transform>(KeyframePoses[frame], KeyFrameCount);
}
/// <summary>
/// Animation name as string
/// </summary>
public string NameToString()
{
fixed (sbyte* name = Name)