Sfoglia il codice sorgente

Physac.h fix for variable array size declaration.

Generating the projects using CMake, targeting VS2017, results in an error when compiling.
This is due to physac.h trying to make a 'vertices' array of size 'int count', making it const does not work, either.

This changes the static declaration to a malloc/free combo.

Tested using the physics-demo.
pull/656/head
noshbar 7 anni fa
parent
commit
7f7f3b7cd5
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. +3
    -1
      src/physac.h

+ 3
- 1
src/physac.h Vedi File

@ -606,7 +606,7 @@ PHYSACDEF void PhysicsShatter(PhysicsBody body, Vector2 position, float force)
{ {
int count = vertexData.vertexCount; int count = vertexData.vertexCount;
Vector2 bodyPos = body->position; Vector2 bodyPos = body->position;
Vector2 n">vertices[count];
Vector2 o">*vertices = (Vector2*)malloc(sizeof(Vector2) * count);
Mat2 trans = body->shape.transform; Mat2 trans = body->shape.transform;
for (int i = 0; i < count; i++) vertices[i] = vertexData.positions[i]; for (int i = 0; i < count; i++) vertices[i] = vertexData.positions[i];
@ -698,6 +698,8 @@ PHYSACDEF void PhysicsShatter(PhysicsBody body, Vector2 position, float force)
// Apply force to new physics body // Apply force to new physics body
PhysicsAddForce(newBody, forceDirection); PhysicsAddForce(newBody, forceDirection);
} }
free(vertices);
} }
} }
} }

Caricamento…
Annulla
Salva