feat(meshopt): add typed enums and improve naming logic
Introduce SimplifyOptions and SimplifyVertexOptions enums for mesh simplification, replacing magic numbers with type-safe flags. Update MeshOptApi with strongly-typed wrapper methods. Refactor MeshletUtility to use new enums and nullable delegates, and fix stride calculation for pointer arithmetic. Rename NamingConventions.GetMethodName to GetName, update name removal logic to use "$TBare", and add ALL_CAPS style for constants. Update config files to match new naming conventions and add ALL_CAPS constant rule for meshopt. Refactor BindingParser and related classes to support constant member kind. Apply minor bug fixes and code style improvements throughout.
This commit is contained in:
90
src/ThridParty/Ghost.MeshOptimizer/MeshOptApi.cs
Normal file
90
src/ThridParty/Ghost.MeshOptimizer/MeshOptApi.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
namespace Ghost.MeshOptimizer;
|
||||
|
||||
[Flags]
|
||||
public enum SimplifyOptions : uint
|
||||
{
|
||||
LockBorder = 1 << 0,
|
||||
Sparse = 1 << 1,
|
||||
ErrorAbsolute = 1 << 2,
|
||||
Prune = 1 << 3,
|
||||
Regularize = 1 << 4,
|
||||
Permissive = 1 << 5
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SimplifyVertexOptions : byte
|
||||
{
|
||||
Lock = 1 << 0,
|
||||
Protect = 1 << 1
|
||||
}
|
||||
|
||||
public unsafe partial struct MeshOptApi
|
||||
{
|
||||
public const int VERSION = Api.MESHOPTIMIZER_VERSION;
|
||||
|
||||
/// <summary>
|
||||
/// From: <see cref="Api.meshopt_simplify(uint*, uint*, nuint, float*, nuint, nuint, nuint, float, uint, float*)" />
|
||||
/// </summary>
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
public static nuint Simplify(uint* destination, uint* indices, nuint index_count, float* vertex_positions, nuint vertex_count, nuint vertex_positions_stride, nuint target_index_count, float target_error, SimplifyOptions options, float* result_error)
|
||||
{
|
||||
return Api.meshopt_simplify(
|
||||
destination,
|
||||
indices,
|
||||
index_count,
|
||||
vertex_positions,
|
||||
vertex_count,
|
||||
vertex_positions_stride,
|
||||
target_index_count,
|
||||
target_error,
|
||||
(uint)options,
|
||||
result_error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From: <see cref="Api.meshopt_simplifyWithAttributes(uint*, uint*, nuint, float*, nuint, nuint, float*, nuint, float*, nuint, byte*, nuint, float, uint, float*)" />
|
||||
/// </summary>
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
public static nuint SimplifyWithAttributes(uint* destination, uint* indices, nuint index_count, float* vertex_positions, nuint vertex_count, nuint vertex_positions_stride, float* vertex_attributes, nuint vertex_attributes_stride, float* attribute_weights, nuint attribute_count, byte* vertex_lock, nuint target_index_count, float target_error, SimplifyOptions options, float* result_error)
|
||||
{
|
||||
return Api.meshopt_simplifyWithAttributes(
|
||||
destination,
|
||||
indices,
|
||||
index_count,
|
||||
vertex_positions,
|
||||
vertex_count,
|
||||
vertex_positions_stride,
|
||||
vertex_attributes,
|
||||
vertex_attributes_stride,
|
||||
attribute_weights,
|
||||
attribute_count,
|
||||
vertex_lock,
|
||||
target_index_count,
|
||||
target_error,
|
||||
(uint)options,
|
||||
result_error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// From: <see cref="Api.meshopt_simplifyWithUpdate(uint*, nuint, float*, nuint, nuint, float*, nuint, float*, nuint, byte*, nuint, float, uint, float*)" />
|
||||
/// </summary>
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
public static nuint SimplifyWithUpdate(uint* indices, nuint index_count, float* vertex_positions, nuint vertex_count, nuint vertex_positions_stride, float* vertex_attributes, nuint vertex_attributes_stride, float* attribute_weights, nuint attribute_count, byte* vertex_lock, nuint target_index_count, float target_error, SimplifyOptions options, float* result_error)
|
||||
{
|
||||
return Api.meshopt_simplifyWithUpdate(
|
||||
indices,
|
||||
index_count,
|
||||
vertex_positions,
|
||||
vertex_count,
|
||||
vertex_positions_stride,
|
||||
vertex_attributes,
|
||||
vertex_attributes_stride,
|
||||
attribute_weights,
|
||||
attribute_count,
|
||||
vertex_lock,
|
||||
target_index_count,
|
||||
target_error,
|
||||
(uint)options,
|
||||
result_error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user