Skip to content

Commit

Permalink
MSVC can't handle VLAs
Browse files Browse the repository at this point in the history
  • Loading branch information
kadir014 committed Jan 4, 2024
1 parent ea93d7b commit 1ef3a4a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion include/novaphysics/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]);
Expand Down

0 comments on commit 1ef3a4a

Please sign in to comment.