diff --git a/src/utils/memory.c b/src/utils/memory.c index 9fb26ce..669bfe8 100644 --- a/src/utils/memory.c +++ b/src/utils/memory.c @@ -57,6 +57,23 @@ acMeshSet(const AcReal value, AcMesh* mesh) return AC_SUCCESS; } +static AcReal +randf(void) +{ + return (AcReal)rand() / (AcReal)RAND_MAX; +} + +AcResult +acMeshRandomize(AcMesh* mesh) +{ + const int n = acVertexBufferSize(mesh->info); + for (int w = 0; w < NUM_VTXBUF_HANDLES; ++w) + for (int i = 0; i < n; ++i) + mesh->vertex_buffer[w][i] = randf(); + + return AC_SUCCESS; +} + AcResult acMeshClear(AcMesh* mesh) { diff --git a/src/utils/memory.h b/src/utils/memory.h index 5300c48..f955476 100644 --- a/src/utils/memory.h +++ b/src/utils/memory.h @@ -37,6 +37,8 @@ AcResult acMeshDestroy(AcMesh* mesh); AcResult acMeshSet(const AcReal value, AcMesh* mesh); +AcResult acMeshRandomize(AcMesh* mesh); + AcResult acMeshClear(AcMesh* mesh); #ifdef __cplusplus