From 3518ffa3f6c4897810b0b9d67981e4d073caa5ab Mon Sep 17 00:00:00 2001
From: Nickolas McDonald <43690021+n77y@users.noreply.github.com>
Date: Sat, 9 Sep 2023 12:38:00 -0400
Subject: [PATCH] remove MeshExtentions class
---
Raylib-cs/types/Mesh.cs | 107 ++++++++++++++++++++++++++++++
Raylib-cs/types/MeshExtensions.cs | 90 -------------------------
2 files changed, 107 insertions(+), 90 deletions(-)
delete mode 100644 Raylib-cs/types/MeshExtensions.cs
diff --git a/Raylib-cs/types/Mesh.cs b/Raylib-cs/types/Mesh.cs
index 6f6980d..f640db1 100644
--- a/Raylib-cs/types/Mesh.cs
+++ b/Raylib-cs/types/Mesh.cs
@@ -1,3 +1,4 @@
+using System;
using System.Runtime.InteropServices;
namespace Raylib_cs;
@@ -65,6 +66,112 @@ public unsafe partial struct Mesh
///
public ushort* Indices = default;
+ ///
+ /// Allocate
+ ///
+ public void AllocVertices()
+ {
+ Vertices = Raylib.New(3 * VertexCount);
+ }
+
+ ///
+ /// Allocate
+ ///
+ public void AllocTexCoords()
+ {
+ TexCoords = Raylib.New(2 * VertexCount);
+ }
+
+ ///
+ /// Allocate
+ ///
+ public void AllocTexCoords2()
+ {
+ TexCoords2 = Raylib.New(2 * VertexCount);
+ }
+
+ ///
+ /// Allocate
+ ///
+ public void AllocNormals()
+ {
+ Normals = Raylib.New(3 * VertexCount);
+ }
+
+ ///
+ /// Allocate
+ ///
+ public void AllocTangents()
+ {
+ Tangents = Raylib.New(4 * VertexCount);
+ }
+
+ ///
+ /// Allocate
+ ///
+ public void AllocColors()
+ {
+ Colors = Raylib.New(4 * VertexCount);
+ }
+
+ ///
+ /// Allocate
+ ///
+ public void AllocIndices()
+ {
+ Indices = Raylib.New(3 * TriangleCount);
+ }
+
+ ///
+ /// Access
+ ///
+ public readonly Span VerticesAs() where T : unmanaged
+ {
+ return new(Vertices, 3 * VertexCount * sizeof(float) / sizeof(T));
+ }
+
+ ///
+ /// Access
+ ///
+ public readonly Span TexCoordsAs() where T : unmanaged
+ {
+ return new(TexCoords, 2 * VertexCount * sizeof(float) / sizeof(T));
+ }
+
+ ///
+ /// Access
+ ///
+ public readonly Span TexCoords2As() where T : unmanaged
+ {
+ return new(TexCoords2, 2 * VertexCount * sizeof(float) / sizeof(T));
+ }
+
+ ///
+ /// Access
+ ///
+ public readonly Span NormalsAs() where T : unmanaged
+ {
+ return new(Normals, 3 * VertexCount * sizeof(float) / sizeof(T));
+ }
+
+ /// Access
+ public readonly Span TangentsAs() where T : unmanaged
+ {
+ return new(Tangents, 4 * VertexCount * sizeof(float) / sizeof(T));
+ }
+
+ /// Access
+ public readonly Span ColorsAs() where T : unmanaged
+ {
+ return new(Colors, 4 * VertexCount * sizeof(byte) / sizeof(T));
+ }
+
+ /// Access
+ public readonly Span IndicesAs() where T : unmanaged
+ {
+ return new(Indices, 3 * TriangleCount * sizeof(ushort) / sizeof(T));
+ }
+
#endregion
#region Animation vertex data
diff --git a/Raylib-cs/types/MeshExtensions.cs b/Raylib-cs/types/MeshExtensions.cs
deleted file mode 100644
index 964ce6e..0000000
--- a/Raylib-cs/types/MeshExtensions.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-
-namespace Raylib_cs;
-
-internal static unsafe class MeshExtensions
-{
- /// Allocate mesh vertices
- public static void AllocVertices(ref this Mesh mesh)
- {
- mesh.Vertices = Raylib.New(3 * mesh.VertexCount);
- }
-
- /// Allocate mesh texcoords
- public static void AllocTexcoords(ref this Mesh mesh)
- {
- mesh.TexCoords = Raylib.New(2 * mesh.VertexCount);
- }
-
- /// Allocate mesh texcoords2
- public static void AllocTexcoords2(ref this Mesh mesh)
- {
- mesh.TexCoords2 = Raylib.New(2 * mesh.VertexCount);
- }
-
- /// Allocate mesh normals
- public static void AllocNormals(ref this Mesh mesh)
- {
- mesh.Normals = Raylib.New(3 * mesh.VertexCount);
- }
-
- /// Allocate mesh tangents
- public static void AllocTangents(ref this Mesh mesh)
- {
- mesh.Tangents = Raylib.New(4 * mesh.VertexCount);
- }
-
- /// Allocate mesh colors
- public static void AllocColors(ref this Mesh mesh)
- {
- mesh.Colors = Raylib.New(4 * mesh.VertexCount);
- }
-
- /// Allocate mesh indices
- public static void AllocIndices(ref this Mesh mesh)
- {
- mesh.Indices = Raylib.New(3 * mesh.TriangleCount);
- }
-
- /// Access mesh vertices
- public static Span VerticesAs(this Mesh mesh) where T : unmanaged
- {
- return new(mesh.Vertices, 3 * mesh.VertexCount * sizeof(float) / sizeof(T));
- }
-
- /// Access mesh texcoords
- public static Span TexcoordsAs(this Mesh mesh) where T : unmanaged
- {
- return new(mesh.TexCoords, 2 * mesh.VertexCount * sizeof(float) / sizeof(T));
- }
-
- /// Access mesh texcoords2
- public static Span Texcoords2As(this Mesh mesh) where T : unmanaged
- {
- return new(mesh.TexCoords2, 2 * mesh.VertexCount * sizeof(float) / sizeof(T));
- }
-
- /// Access mesh normals
- public static Span NormalsAs(this Mesh mesh) where T : unmanaged
- {
- return new(mesh.Normals, 3 * mesh.VertexCount * sizeof(float) / sizeof(T));
- }
-
- /// Access mesh tangents
- public static Span TangentsAs(this Mesh mesh) where T : unmanaged
- {
- return new(mesh.Tangents, 4 * mesh.VertexCount * sizeof(float) / sizeof(T));
- }
-
- /// Access mesh colors
- public static Span ColorsAs(this Mesh mesh) where T : unmanaged
- {
- return new(mesh.Colors, 4 * mesh.VertexCount * sizeof(byte) / sizeof(T));
- }
-
- /// Access mesh indices
- public static Span IndicesAs(this Mesh mesh) where T : unmanaged
- {
- return new(mesh.Indices, 3 * mesh.TriangleCount * sizeof(ushort) / sizeof(T));
- }
-}