Added a function for randomizing vertex buffers (useful for testing)

This commit is contained in:
jpekkila
2019-10-15 16:13:11 +03:00
parent 37171689c8
commit 4ae9c74d9d
2 changed files with 19 additions and 0 deletions

View File

@@ -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)
{

View File

@@ -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