소스 검색

Merge pull request #656 from noshbar/vs2017-fix

Physac.h fix for variable array size declaration.
Ray 7 년 전
부모
커밋
b8b8e6ab7d
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      src/physac.h

+ 3 - 1
src/physac.h

@@ -606,7 +606,7 @@ PHYSACDEF void PhysicsShatter(PhysicsBody body, Vector2 position, float force)
             {
                 int count = vertexData.vertexCount;
                 Vector2 bodyPos = body->position;
-                Vector2 vertices[count];
+                Vector2 *vertices = (Vector2*)malloc(sizeof(Vector2) * count);
                 Mat2 trans = body->shape.transform;
                 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
                     PhysicsAddForce(newBody, forceDirection);
                 }
+
+                free(vertices);
             }
         }
     }