From 1ef3a4a8587a778e37e537bead568b6abcd01e0b Mon Sep 17 00:00:00 2001 From: Kadir Aksoy <46996028+kadir014@users.noreply.github.com> Date: Thu, 4 Jan 2024 23:49:19 +0300 Subject: [PATCH] MSVC can't handle VLAs --- include/novaphysics/math.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/include/novaphysics/math.h b/include/novaphysics/math.h index d2da7d4..d5bc6c6 100644 --- a/include/novaphysics/math.h +++ b/include/novaphysics/math.h @@ -487,7 +487,16 @@ static inline nvArray *nv_generate_convex_hull(nvArray *points) { pivot = NV_TO_VEC2(points->data[0]); _convex_hull_pivot = pivot; - nvVector2 tmp_points[points->size]; + #ifdef NV_COMPILER_MSVC + + nvVector2 *tmp_points = malloc(sizeof(nvVector2) * points->size); + + #else + + nvVector2 tmp_points[points->size]; + + #endif + for (size_t i = 0; i < points->size; i++) { nvVector2 v = NV_TO_VEC2(points->data[i]); tmp_points[i] = v; @@ -501,6 +510,12 @@ static inline nvArray *nv_generate_convex_hull(nvArray *points) { v->y = tmp_points[i].y; } + #ifdef NV_COMPILER_MSVC + + free(tmp_points); + + #endif + nvVector2 *hull = malloc(sizeof(nvVector2) * n); size_t hull_size = 3; hull[0] = NV_TO_VEC2(points->data[0]);