Code Monkey home page Code Monkey logo

physac's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

physac's Issues

High CPU usage

Whenever I use Physac, the CPU goes up to 40% (and when i'm not calling InitPhysics() it goes back to normal). Any fix for this?

Knowing whether collisions have happened

(I found the closed issue from 2017, but this query is a little different)

I'm just using Physac by itself, with SDL 2. So far I have things that move and collide quite nicely.

While I understand collisions are internal to the engine, is there a strategy to know whether two things have collided? For example suppose I have a rocket moving across the screen and it hits a target, how can I tell the collision has happened so I can make some game logic run?

Position correction doesn't work as expected in Circle vs Polygon collision

Polygons and circles doesn't overlap between bodies of the same type. But as you can see in the attached screenshot, some circles overlaps with the rectangle (which is a polygon too) and doesn't correct its position during steps...

I think there is some bug in manifold penetration calculation, or maybe some condition which returns the function and doesn't let the program execute position correction instructions.

Review functions: SolveCircleToPolygon(), SolvePolygonToCircle(), CorrectPhysicsPolsitions()

physics_demo_bias

Where is PhysicsBody defined?

You have this line:

typedef struct PhysicsBodyData *PhysicsBody;

But where is PhysicsBody defined?
I am trying to do a rust port, should i just create a struct PhysicsBody or struct PhysicsBodyData?

isGrounded blinks on a ground

PhysicsBody -> isGrounded blinks when its on a ground.
I'm trying to link idle animation on body-> isGrouned, but it works not that I expected

You can see this behavior on gif:
ezgif-4-1bb7130c4a

Make Physac independent

Physac is currently dependent of raylib, so functions like DrawPhysicsBodies() and DrawPhysicsContacts() needs to be replaced by some functions to get relevant physics bodies data to make possible to any developer to create its own physics bodies drawing system (I use lines between vertices in my case).

Some of the functions needed are:

  • GetPhysicsBodiesCount() - Count to create a for loop and draw each created body.
  • GetPhysicsBody(int index) - Get each PhysicsBody struct data to access its shape (type, radius, vertices...).

With these functions, anybody can create its own physics body drawing system. But I want to add some other functions to simply it:

  • GetPhysicsVertices(int index) - Returns an array of all vertices final positions (body position + vertex position transformed) in case of PHYSICS_POLYGON, or an array of all vertices final positions to create a circle with 16 divisions (body position + vertex positions based on radius).

By the other hand, some raylib functions used in Physac needs to be reimplemented like GetRandomValue().

Physac naming and icon

Hi @victorfisac, just noticed Physac icon only includes 16x16, 32x32 and 48x48 versions, directly scaled from the 256x256 .png version provided and physac_icon object does not include .rc properties correctly (just check generated .exe files to see that).

Do you mind if I review icon design following the proposed line but more aligned with raylib iconography?

Perfectly elastic collisions

I'm trying to achieve perfectly elastic collisions by setting the restitution of the ball and the floor to 1 in the restitution example but the ball does not behave elastically. Each time it bounces less than the previous height. I'm wondering how else can I achieve the effect?

Heres the code, although it's a slight modification of the example:

#include "raylib.h"

#define PHYSAC_IMPLEMENTATION
#include "physac.h"

int main()
{
    // Initialization
    //--------------------------------------------------------------------------------------
    int screenWidth = 800;
    int screenHeight = 450;

    SetConfigFlags(FLAG_MSAA_4X_HINT);
    InitWindow(screenWidth, screenHeight, "[physac] - Restitution demo");

    // Physac logo drawing position
    int logoX = screenWidth - MeasureText("Physac", 30) - 10;
    int logoY = 15;

    // Initialize physics and default physics bodies
    InitPhysics();

    // Create floor rectangle physics body
    PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, screenWidth, 100, 10);
    floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
    floor->restitution = 1;

    // Create circles physics body
       PhysicsBody circleA = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.5f, screenHeight/2 }, 30, 10);
    circleA->restitution = 1.0f;
    
    SetTargetFPS(60);
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Update
        //----------------------------------------------------------------------------------
        // ...
        //----------------------------------------------------------------------------------

        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();

            ClearBackground(BLACK);

            DrawFPS(screenWidth - 90, screenHeight - 30);

            // Draw created physics bodies
            int bodiesCount = GetPhysicsBodiesCount();
            for (int i = 0; i < bodiesCount; i++)
            {
                PhysicsBody body = GetPhysicsBody(i);

                int vertexCount = GetPhysicsShapeVerticesCount(i);
                for (int j = 0; j < vertexCount; j++)
                {
                    // Get physics bodies shape vertices to draw lines
                    // Note: GetPhysicsShapeVertex() already calculates rotation transformations
                    Vector2 vertexA = GetPhysicsShapeVertex(body, j);

                    int jj = (((j + 1) < vertexCount) ? (j + 1) : 0);   // Get next vertex or first to close the shape
                    Vector2 vertexB = GetPhysicsShapeVertex(body, jj);

                    DrawLineV(vertexA, vertexB, GREEN);     // Draw a line between two vertex positions
                }
            }

            DrawText("Restitution amount", (screenWidth - MeasureText("Restitution amount", 30))/2, 75, 30, WHITE);
            DrawText("100%", circleA->position.x - MeasureText("100%", 20)/2, circleA->position.y - 7, 20, WHITE);

            DrawText("Physac", logoX, logoY, 30, WHITE);
            DrawText("Powered by", logoX + 50, logoY - 7, 10, WHITE);

        EndDrawing();
        //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------   
    ClosePhysics();       // Unitialize physics
    
    CloseWindow();        // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}

C99 compilation fails

Output

c99  -Wall -Wextra -Werror -O2  -pedantic -o main -lraylib -lglfw -lGL -lopenal -lm -lpthread -ldl main.c  
In file included from main.c:5:  
/usr/include/physac.h: In function ‘InitTimer’:  
/usr/include/physac.h:1905:21: error: storage size of ‘now’ isn’t known  
 1905 |     struct timespec now;  
      |                     ^~~  
/usr/include/physac.h:1906:23: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)  
 1906 |     if (clock_gettime(CLOCK_MONOTONIC, &now) == 0) frequency = 1000000000;  
      |                       ^~~~~~~~~~~~~~~  
/usr/include/physac.h:1906:23: note: each undeclared identifier is reported only once for  each function it appears in  
/usr/include/physac.h: In function ‘GetTimeCount’:  
/usr/include/physac.h:1929:21: error: storage size of ‘now’ isn’t known  
 1929 |     struct timespec now;  
      |                     ^~~  
/usr/include/physac.h:1930:19: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)  
 1930 |     clock_gettime(CLOCK_MONOTONIC, &now);  
      |                   ^~~~~~~~~~~~~~~  
make: *** [Makefile:7: main] Error 1

Shatter created physics bodies have a strange behaviour

When shattering a physics body, new little bodies are created with a portion of the shape (based on triangles) to simulate that the shape is broken in little parts.

When trying to shatter these new little parts using same force value, they gets a strange amount of force and direction (and sometimes torque) that it is not the expected. Maybe it happens because new physics bodies doesn't have its position at the barycenter of the triangle shape...

b78f035016dbdca3afb927b3a6485849

Physac functions conflict with Visual Studio WINAPI function names

OK, This issue/problem is weirdest issue i had...

Doing game template with C99 for Visual Studio 2019, I added physac.h with being standalone via defining PHYSAC_STANDALONE, But when building solution i get type conflict errors

Screenshot (369)

The problem with both functions GetCurrentTime and GetTimeCount, Anyway...
When i went to their definition, I found that both names used by Windows API functions via WinBase.h, As you see in the image below

Screenshot (370)

So yes, Windows API functions use these names, To solve this i renamed GetCurrentTime to CurrentTime and renamed GetTimeCount to TimeCount everywhere in physac.h

Do you have idea to solve this by checking for Windows platform or Windows API, Tell me...

Redefination errors when including in multiple files

In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:289:18: error: redefinition of 'pthread_t physicsThreadId'
 static pthread_t physicsThreadId;                           // Physics thread id
                  ^
In file included from main.cpp:6:0:
physac.h:289:18: note: 'pthread_t physicsThreadId' previously declared here
 static pthread_t physicsThreadId;                           // Physics thread id
                  ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:291:21: error: redefinition of 'unsigned int usedMemory'
 static unsigned int usedMemory = 0;                         // Total allocated dynamic memory
                     ^
In file included from main.cpp:6:0:
physac.h:291:21: note: 'unsigned int usedMemory' previously defined here
 static unsigned int usedMemory = 0;                         // Total allocated dynamic memory
                     ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:292:13: error: redefinition of 'bool physicsThreadEnabled'
 static bool physicsThreadEnabled = false;                   // Physics thread enabled state
             ^
In file included from main.cpp:6:0:
physac.h:292:13: note: 'bool physicsThreadEnabled' previously defined here
 static bool physicsThreadEnabled = false;                   // Physics thread enabled state
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:293:15: error: redefinition of 'double baseTime'
 static double baseTime = 0.0;                               // Offset time for MONOTONIC clock
               ^
In file included from main.cpp:6:0:
physac.h:293:15: note: 'double baseTime' previously defined here
 static double baseTime = 0.0;                               // Offset time for MONOTONIC clock
               ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:294:15: error: redefinition of 'double startTime'
 static double startTime = 0.0;                              // Start time in milliseconds
               ^
In file included from main.cpp:6:0:
physac.h:294:15: note: 'double startTime' previously defined here
 static double startTime = 0.0;                              // Start time in milliseconds
               ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:295:15: error: redefinition of 'double deltaTime'
 static double deltaTime = 1.0/60.0/10.0 * 1000;             // Delta time used for physics steps, in milliseconds
               ^
In file included from main.cpp:6:0:
physac.h:295:15: note: 'double deltaTime' previously defined here
 static double deltaTime = 1.0/60.0/10.0 * 1000;             // Delta time used for physics steps, in milliseconds
               ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:296:15: error: redefinition of 'double currentTime'
 static double currentTime = 0.0;                            // Current time in milliseconds
               ^
In file included from main.cpp:6:0:
physac.h:296:15: note: 'double currentTime' previously defined here
 static double currentTime = 0.0;                            // Current time in milliseconds
               ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:297:17: error: redefinition of 'uint64_t frequency'
 static uint64_t frequency = 0;                              // Hi-res clock frequency
                 ^
In file included from main.cpp:6:0:
physac.h:297:17: note: 'uint64_t frequency' previously defined here
 static uint64_t frequency = 0;                              // Hi-res clock frequency
                 ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:299:15: error: redefinition of 'double accumulator'
 static double accumulator = 0.0;                            // Physics time step delta time accumulator
               ^
In file included from main.cpp:6:0:
physac.h:299:15: note: 'double accumulator' previously defined here
 static double accumulator = 0.0;                            // Physics time step delta time accumulator
               ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:300:21: error: redefinition of 'unsigned int stepsCount'
 static unsigned int stepsCount = 0;                         // Total physics steps processed
                     ^
In file included from main.cpp:6:0:
physac.h:300:21: note: 'unsigned int stepsCount' previously defined here
 static unsigned int stepsCount = 0;                         // Total physics steps processed
                     ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:301:16: error: redefinition of 'Vector2 gravityForce'
 static Vector2 gravityForce = { 0.0f, 9.81f };              // Physics world gravity force
                ^
In file included from main.cpp:6:0:
physac.h:301:16: note: 'Vector2 gravityForce' previously defined here
 static Vector2 gravityForce = { 0.0f, 9.81f };              // Physics world gravity force
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:302:44: error: redefinition of 'PhysicsBodyData* bodies [64]'
 static PhysicsBody bodies[PHYSAC_MAX_BODIES];               // Physics bodies pointers array
                                            ^
In file included from main.cpp:6:0:
physac.h:302:20: note: 'PhysicsBodyData* bodies [64]' previously declared here
 static PhysicsBody bodies[PHYSAC_MAX_BODIES];               // Physics bodies pointers array
                    ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:303:21: error: redefinition of 'unsigned int physicsBodiesCount'
 static unsigned int physicsBodiesCount = 0;                 // Physics world current bodies counter
                     ^
In file included from main.cpp:6:0:
physac.h:303:21: note: 'unsigned int physicsBodiesCount' previously defined here
 static unsigned int physicsBodiesCount = 0;                 // Physics world current bodies counter
                     ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:304:53: error: redefinition of 'PhysicsManifoldData* contacts [4096]'
 static PhysicsManifold contacts[PHYSAC_MAX_MANIFOLDS];      // Physics bodies pointers array
                                                     ^
In file included from main.cpp:6:0:
physac.h:304:24: note: 'PhysicsManifoldData* contacts [4096]' previously declared here
 static PhysicsManifold contacts[PHYSAC_MAX_MANIFOLDS];      // Physics bodies pointers array
                        ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h:305:21: error: redefinition of 'unsigned int physicsManifoldsCount'
 static unsigned int physicsManifoldsCount = 0;              // Physics world current manifolds counter
                     ^
In file included from main.cpp:6:0:
physac.h:305:21: note: 'unsigned int physicsManifoldsCount' previously defined here
 static unsigned int physicsManifoldsCount = 0;              // Physics world current manifolds counter
                     ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void InitPhysics()':
Scenes/../physac.h:360:16: error: redefinition of 'void InitPhysics()'
 PHYSACDEF void InitPhysics(void)
                ^
In file included from main.cpp:6:0:
physac.h:360:16: note: 'void InitPhysics()' previously defined here
 PHYSACDEF void InitPhysics(void)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'bool IsPhysicsEnabled()':
Scenes/../physac.h:379:16: error: redefinition of 'bool IsPhysicsEnabled()'
 PHYSACDEF bool IsPhysicsEnabled(void)
                ^
In file included from main.cpp:6:0:
physac.h:379:16: note: 'bool IsPhysicsEnabled()' previously defined here
 PHYSACDEF bool IsPhysicsEnabled(void)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void SetPhysicsGravity(float, float)':
Scenes/../physac.h:385:16: error: redefinition of 'void SetPhysicsGravity(float, float)'
 PHYSACDEF void SetPhysicsGravity(float x, float y)
                ^
In file included from main.cpp:6:0:
physac.h:385:16: note: 'void SetPhysicsGravity(float, float)' previously defined here
 PHYSACDEF void SetPhysicsGravity(float x, float y)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'PhysicsBodyData* CreatePhysicsBodyCircle(Vector2, float, float)':
Scenes/../physac.h:392:23: error: redefinition of 'PhysicsBodyData* CreatePhysicsBodyCircle(Vector2, float, float)'
 PHYSACDEF PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density)
                       ^
In file included from main.cpp:6:0:
physac.h:392:23: note: 'PhysicsBodyData* CreatePhysicsBodyCircle(Vector2, float, float)' previously defined here
 PHYSACDEF PhysicsBody CreatePhysicsBodyCircle(Vector2 pos, float radius, float density)
                       ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'PhysicsBodyData* CreatePhysicsBodyRectangle(Vector2, float, float, float)':
Scenes/../physac.h:443:23: error: redefinition of 'PhysicsBodyData* CreatePhysicsBodyRectangle(Vector2, float, float, float)'
 PHYSACDEF PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density)
                       ^
In file included from main.cpp:6:0:
physac.h:443:23: note: 'PhysicsBodyData* CreatePhysicsBodyRectangle(Vector2, float, float, float)' previously defined here
 PHYSACDEF PhysicsBody CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density)
                       ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'PhysicsBodyData* CreatePhysicsBodyPolygon(Vector2, float, int, float)':
Scenes/../physac.h:531:23: error: redefinition of 'PhysicsBodyData* CreatePhysicsBodyPolygon(Vector2, float, int, float)'
 PHYSACDEF PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density)
                       ^
In file included from main.cpp:6:0:
physac.h:531:23: note: 'PhysicsBodyData* CreatePhysicsBodyPolygon(Vector2, float, int, float)' previously defined here
 PHYSACDEF PhysicsBody CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density)
                       ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void PhysicsAddForce(PhysicsBody, Vector2)':
Scenes/../physac.h:618:16: error: redefinition of 'void PhysicsAddForce(PhysicsBody, Vector2)'
 PHYSACDEF void PhysicsAddForce(PhysicsBody body, Vector2 force)
                ^
In file included from main.cpp:6:0:
physac.h:618:16: note: 'void PhysicsAddForce(PhysicsBody, Vector2)' previously defined here
 PHYSACDEF void PhysicsAddForce(PhysicsBody body, Vector2 force)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void PhysicsAddTorque(PhysicsBody, float)':
Scenes/../physac.h:625:16: error: redefinition of 'void PhysicsAddTorque(PhysicsBody, float)'
 PHYSACDEF void PhysicsAddTorque(PhysicsBody body, float amount)
                ^
In file included from main.cpp:6:0:
physac.h:625:16: note: 'void PhysicsAddTorque(PhysicsBody, float)' previously defined here
 PHYSACDEF void PhysicsAddTorque(PhysicsBody body, float amount)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void PhysicsShatter(PhysicsBody, Vector2, float)':
Scenes/../physac.h:632:16: error: redefinition of 'void PhysicsShatter(PhysicsBody, Vector2, float)'
 PHYSACDEF void PhysicsShatter(PhysicsBody body, Vector2 position, float force)
                ^
In file included from main.cpp:6:0:
physac.h:632:16: note: 'void PhysicsShatter(PhysicsBody, Vector2, float)' previously defined here
 PHYSACDEF void PhysicsShatter(PhysicsBody body, Vector2 position, float force)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'int GetPhysicsBodiesCount()':
Scenes/../physac.h:774:15: error: redefinition of 'int GetPhysicsBodiesCount()'
 PHYSACDEF int GetPhysicsBodiesCount(void)
               ^
In file included from main.cpp:6:0:
physac.h:774:15: note: 'int GetPhysicsBodiesCount()' previously defined here
 PHYSACDEF int GetPhysicsBodiesCount(void)
               ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'PhysicsBodyData* GetPhysicsBody(int)':
Scenes/../physac.h:780:23: error: redefinition of 'PhysicsBodyData* GetPhysicsBody(int)'
 PHYSACDEF PhysicsBody GetPhysicsBody(int index)
                       ^
In file included from main.cpp:6:0:
physac.h:780:23: note: 'PhysicsBodyData* GetPhysicsBody(int)' previously defined here
 PHYSACDEF PhysicsBody GetPhysicsBody(int index)
                       ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'int GetPhysicsShapeType(int)':
Scenes/../physac.h:800:15: error: redefinition of 'int GetPhysicsShapeType(int)'
 PHYSACDEF int GetPhysicsShapeType(int index)
               ^
In file included from main.cpp:6:0:
physac.h:800:15: note: 'int GetPhysicsShapeType(int)' previously defined here
 PHYSACDEF int GetPhysicsShapeType(int index)
               ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'int GetPhysicsShapeVerticesCount(int)':
Scenes/../physac.h:823:15: error: redefinition of 'int GetPhysicsShapeVerticesCount(int)'
 PHYSACDEF int GetPhysicsShapeVerticesCount(int index)
               ^
In file included from main.cpp:6:0:
physac.h:823:15: note: 'int GetPhysicsShapeVerticesCount(int)' previously defined here
 PHYSACDEF int GetPhysicsShapeVerticesCount(int index)
               ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'Vector2 GetPhysicsShapeVertex(PhysicsBody, int)':
Scenes/../physac.h:852:19: error: redefinition of 'Vector2 GetPhysicsShapeVertex(PhysicsBody, int)'
 PHYSACDEF Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex)
                   ^
In file included from main.cpp:6:0:
physac.h:852:19: note: 'Vector2 GetPhysicsShapeVertex(PhysicsBody, int)' previously defined here
 PHYSACDEF Vector2 GetPhysicsShapeVertex(PhysicsBody body, int vertex)
                   ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void SetPhysicsBodyRotation(PhysicsBody, float)':
Scenes/../physac.h:882:16: error: redefinition of 'void SetPhysicsBodyRotation(PhysicsBody, float)'
 PHYSACDEF void SetPhysicsBodyRotation(PhysicsBody body, float radians)
                ^
In file included from main.cpp:6:0:
physac.h:882:16: note: 'void SetPhysicsBodyRotation(PhysicsBody, float)' previously defined here
 PHYSACDEF void SetPhysicsBodyRotation(PhysicsBody body, float radians)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void DestroyPhysicsBody(PhysicsBody)':
Scenes/../physac.h:894:16: error: redefinition of 'void DestroyPhysicsBody(PhysicsBody)'
 PHYSACDEF void DestroyPhysicsBody(PhysicsBody body)
                ^
In file included from main.cpp:6:0:
physac.h:894:16: note: 'void DestroyPhysicsBody(PhysicsBody)' previously defined here
 PHYSACDEF void DestroyPhysicsBody(PhysicsBody body)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void ClosePhysics()':
Scenes/../physac.h:944:16: error: redefinition of 'void ClosePhysics()'
 PHYSACDEF void ClosePhysics(void)
                ^
In file included from main.cpp:6:0:
physac.h:944:16: note: 'void ClosePhysics()' previously defined here
 PHYSACDEF void ClosePhysics(void)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'int FindAvailableBodyIndex()':
Scenes/../physac.h:975:12: error: redefinition of 'int FindAvailableBodyIndex()'
 static int FindAvailableBodyIndex()
            ^
In file included from main.cpp:6:0:
physac.h:975:12: note: 'int FindAvailableBodyIndex()' previously defined here
 static int FindAvailableBodyIndex()
            ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'PolygonData CreateRandomPolygon(float, int)':
Scenes/../physac.h:1004:20: error: redefinition of 'PolygonData CreateRandomPolygon(float, int)'
 static PolygonData CreateRandomPolygon(float radius, int sides)
                    ^
In file included from main.cpp:6:0:
physac.h:1004:20: note: 'PolygonData CreateRandomPolygon(float, int)' previously defined here
 static PolygonData CreateRandomPolygon(float radius, int sides)
                    ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'PolygonData CreateRectanglePolygon(Vector2, Vector2)':
Scenes/../physac.h:1030:20: error: redefinition of 'PolygonData CreateRectanglePolygon(Vector2, Vector2)'
 static PolygonData CreateRectanglePolygon(Vector2 pos, Vector2 size)
                    ^
In file included from main.cpp:6:0:
physac.h:1030:20: note: 'PolygonData CreateRectanglePolygon(Vector2, Vector2)' previously defined here
 static PolygonData CreateRectanglePolygon(Vector2 pos, Vector2 size)
                    ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void* PhysicsLoop(void*)':
Scenes/../physac.h:1055:14: error: redefinition of 'void* PhysicsLoop(void*)'
 static void *PhysicsLoop(void *arg)
              ^
In file included from main.cpp:6:0:
physac.h:1055:14: note: 'void* PhysicsLoop(void*)' previously defined here
 static void *PhysicsLoop(void *arg)
              ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void PhysicsStep()':
Scenes/../physac.h:1074:13: error: redefinition of 'void PhysicsStep()'
 static void PhysicsStep(void)
             ^
In file included from main.cpp:6:0:
physac.h:1074:13: note: 'void PhysicsStep()' previously defined here
 static void PhysicsStep(void)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void RunPhysicsStep()':
Scenes/../physac.h:1194:16: error: redefinition of 'void RunPhysicsStep()'
 PHYSACDEF void RunPhysicsStep(void)
                ^
In file included from main.cpp:6:0:
physac.h:1194:16: note: 'void RunPhysicsStep()' previously defined here
 PHYSACDEF void RunPhysicsStep(void)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void SetPhysicsTimeStep(double)':
Scenes/../physac.h:1216:16: error: redefinition of 'void SetPhysicsTimeStep(double)'
 PHYSACDEF void SetPhysicsTimeStep(double delta)
                ^
In file included from main.cpp:6:0:
physac.h:1216:16: note: 'void SetPhysicsTimeStep(double)' previously defined here
 PHYSACDEF void SetPhysicsTimeStep(double delta)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'int FindAvailableManifoldIndex()':
Scenes/../physac.h:1222:12: error: redefinition of 'int FindAvailableManifoldIndex()'
 static int FindAvailableManifoldIndex()
            ^
In file included from main.cpp:6:0:
physac.h:1222:12: note: 'int FindAvailableManifoldIndex()' previously defined here
 static int FindAvailableManifoldIndex()
            ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'PhysicsManifoldData* CreatePhysicsManifold(PhysicsBody, PhysicsBody)':
Scenes/../physac.h:1251:24: error: redefinition of 'PhysicsManifoldData* CreatePhysicsManifold(PhysicsBody, PhysicsBody)'
 static PhysicsManifold CreatePhysicsManifold(PhysicsBody a, PhysicsBody b)
                        ^
In file included from main.cpp:6:0:
physac.h:1251:24: note: 'PhysicsManifoldData* CreatePhysicsManifold(PhysicsBody, PhysicsBody)' previously defined here
 static PhysicsManifold CreatePhysicsManifold(PhysicsBody a, PhysicsBody b)
                        ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void DestroyPhysicsManifold(PhysicsManifold)':
Scenes/../physac.h:1285:13: error: redefinition of 'void DestroyPhysicsManifold(PhysicsManifold)'
 static void DestroyPhysicsManifold(PhysicsManifold manifold)
             ^
In file included from main.cpp:6:0:
physac.h:1285:13: note: 'void DestroyPhysicsManifold(PhysicsManifold)' previously defined here
 static void DestroyPhysicsManifold(PhysicsManifold manifold)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void SolvePhysicsManifold(PhysicsManifold)':
Scenes/../physac.h:1331:13: error: redefinition of 'void SolvePhysicsManifold(PhysicsManifold)'
 static void SolvePhysicsManifold(PhysicsManifold manifold)
             ^
In file included from main.cpp:6:0:
physac.h:1331:13: note: 'void SolvePhysicsManifold(PhysicsManifold)' previously defined here
 static void SolvePhysicsManifold(PhysicsManifold manifold)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void SolveCircleToCircle(PhysicsManifold)':
Scenes/../physac.h:1362:13: error: redefinition of 'void SolveCircleToCircle(PhysicsManifold)'
 static void SolveCircleToCircle(PhysicsManifold manifold)
             ^
In file included from main.cpp:6:0:
physac.h:1362:13: note: 'void SolveCircleToCircle(PhysicsManifold)' previously defined here
 static void SolveCircleToCircle(PhysicsManifold manifold)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void SolveCircleToPolygon(PhysicsManifold)':
Scenes/../physac.h:1405:13: error: redefinition of 'void SolveCircleToPolygon(PhysicsManifold)'
 static void SolveCircleToPolygon(PhysicsManifold manifold)
             ^
In file included from main.cpp:6:0:
physac.h:1405:13: note: 'void SolveCircleToPolygon(PhysicsManifold)' previously defined here
 static void SolveCircleToPolygon(PhysicsManifold manifold)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void SolvePolygonToCircle(PhysicsManifold)':
Scenes/../physac.h:1417:13: error: redefinition of 'void SolvePolygonToCircle(PhysicsManifold)'
 static void SolvePolygonToCircle(PhysicsManifold manifold)
             ^
In file included from main.cpp:6:0:
physac.h:1417:13: note: 'void SolvePolygonToCircle(PhysicsManifold)' previously defined here
 static void SolvePolygonToCircle(PhysicsManifold manifold)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void SolveDifferentShapes(PhysicsManifold, PhysicsBody, PhysicsBody)':
Scenes/../physac.h:1432:13: error: redefinition of 'void SolveDifferentShapes(PhysicsManifold, PhysicsBody, PhysicsBody)'
 static void SolveDifferentShapes(PhysicsManifold manifold, PhysicsBody bodyA, PhysicsBody bodyB)
             ^
In file included from main.cpp:6:0:
physac.h:1432:13: note: 'void SolveDifferentShapes(PhysicsManifold, PhysicsBody, PhysicsBody)' previously defined here
 static void SolveDifferentShapes(PhysicsManifold manifold, PhysicsBody bodyA, PhysicsBody bodyB)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void SolvePolygonToPolygon(PhysicsManifold)':
Scenes/../physac.h:1524:13: error: redefinition of 'void SolvePolygonToPolygon(PhysicsManifold)'
 static void SolvePolygonToPolygon(PhysicsManifold manifold)
             ^
In file included from main.cpp:6:0:
physac.h:1524:13: note: 'void SolvePolygonToPolygon(PhysicsManifold)' previously defined here
 static void SolvePolygonToPolygon(PhysicsManifold manifold)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void IntegratePhysicsForces(PhysicsBody)':
Scenes/../physac.h:1633:13: error: redefinition of 'void IntegratePhysicsForces(PhysicsBody)'
 static void IntegratePhysicsForces(PhysicsBody body)
             ^
In file included from main.cpp:6:0:
physac.h:1633:13: note: 'void IntegratePhysicsForces(PhysicsBody)' previously defined here
 static void IntegratePhysicsForces(PhysicsBody body)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void InitializePhysicsManifolds(PhysicsManifold)':
Scenes/../physac.h:1652:13: error: redefinition of 'void InitializePhysicsManifolds(PhysicsManifold)'
 static void InitializePhysicsManifolds(PhysicsManifold manifold)
             ^
In file included from main.cpp:6:0:
physac.h:1652:13: note: 'void InitializePhysicsManifolds(PhysicsManifold)' previously defined here
 static void InitializePhysicsManifolds(PhysicsManifold manifold)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void IntegratePhysicsImpulses(PhysicsManifold)':
Scenes/../physac.h:1686:13: error: redefinition of 'void IntegratePhysicsImpulses(PhysicsManifold)'
 static void IntegratePhysicsImpulses(PhysicsManifold manifold)
             ^
In file included from main.cpp:6:0:
physac.h:1686:13: note: 'void IntegratePhysicsImpulses(PhysicsManifold)' previously defined here
 static void IntegratePhysicsImpulses(PhysicsManifold manifold)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void IntegratePhysicsVelocity(PhysicsBody)':
Scenes/../physac.h:1798:13: error: redefinition of 'void IntegratePhysicsVelocity(PhysicsBody)'
 static void IntegratePhysicsVelocity(PhysicsBody body)
             ^
In file included from main.cpp:6:0:
physac.h:1798:13: note: 'void IntegratePhysicsVelocity(PhysicsBody)' previously defined here
 static void IntegratePhysicsVelocity(PhysicsBody body)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void CorrectPhysicsPositions(PhysicsManifold)':
Scenes/../physac.h:1815:13: error: redefinition of 'void CorrectPhysicsPositions(PhysicsManifold)'
 static void CorrectPhysicsPositions(PhysicsManifold manifold)
             ^
In file included from main.cpp:6:0:
physac.h:1815:13: note: 'void CorrectPhysicsPositions(PhysicsManifold)' previously defined here
 static void CorrectPhysicsPositions(PhysicsManifold manifold)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'Vector2 GetSupport(PhysicsShape, Vector2)':
Scenes/../physac.h:1841:16: error: redefinition of 'Vector2 GetSupport(PhysicsShape, Vector2)'
 static Vector2 GetSupport(PhysicsShape shape, Vector2 dir)
                ^
In file included from main.cpp:6:0:
physac.h:1841:16: note: 'Vector2 GetSupport(PhysicsShape, Vector2)' previously defined here
 static Vector2 GetSupport(PhysicsShape shape, Vector2 dir)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'float FindAxisLeastPenetration(int*, PhysicsShape, PhysicsShape)':
Scenes/../physac.h:1863:14: error: redefinition of 'float FindAxisLeastPenetration(int*, PhysicsShape, PhysicsShape)'
 static float FindAxisLeastPenetration(int *faceIndex, PhysicsShape shapeA, PhysicsShape shapeB)
              ^
In file included from main.cpp:6:0:
physac.h:1863:14: note: 'float FindAxisLeastPenetration(int*, PhysicsShape, PhysicsShape)' previously defined here
 static float FindAxisLeastPenetration(int *faceIndex, PhysicsShape shapeA, PhysicsShape shapeB)
              ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void FindIncidentFace(Vector2*, Vector2*, PhysicsShape, PhysicsShape, int)':
Scenes/../physac.h:1906:13: error: redefinition of 'void FindIncidentFace(Vector2*, Vector2*, PhysicsShape, PhysicsShape, int)'
 static void FindIncidentFace(Vector2 *v0, Vector2 *v1, PhysicsShape ref, PhysicsShape inc, int index)
             ^
In file included from main.cpp:6:0:
physac.h:1906:13: note: 'void FindIncidentFace(Vector2*, Vector2*, PhysicsShape, PhysicsShape, int)' previously defined here
 static void FindIncidentFace(Vector2 *v0, Vector2 *v1, PhysicsShape ref, PhysicsShape inc, int index)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'int Clip(Vector2, float, Vector2*, Vector2*)':
Scenes/../physac.h:1941:12: error: redefinition of 'int Clip(Vector2, float, Vector2*, Vector2*)'
 static int Clip(Vector2 normal, float clip, Vector2 *faceA, Vector2 *faceB)
            ^
In file included from main.cpp:6:0:
physac.h:1941:12: note: 'int Clip(Vector2, float, Vector2*, Vector2*)' previously defined here
 static int Clip(Vector2 normal, float clip, Vector2 *faceA, Vector2 *faceB)
            ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'bool BiasGreaterThan(float, float)':
Scenes/../physac.h:1978:13: error: redefinition of 'bool BiasGreaterThan(float, float)'
 static bool BiasGreaterThan(float valueA, float valueB)
             ^
In file included from main.cpp:6:0:
physac.h:1978:13: note: 'bool BiasGreaterThan(float, float)' previously defined here
 static bool BiasGreaterThan(float valueA, float valueB)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'Vector2 TriangleBarycenter(Vector2, Vector2, Vector2)':
Scenes/../physac.h:1984:16: error: redefinition of 'Vector2 TriangleBarycenter(Vector2, Vector2, Vector2)'
 static Vector2 TriangleBarycenter(Vector2 v1, Vector2 v2, Vector2 v3)
                ^
In file included from main.cpp:6:0:
physac.h:1984:16: note: 'Vector2 TriangleBarycenter(Vector2, Vector2, Vector2)' previously defined here
 static Vector2 TriangleBarycenter(Vector2 v1, Vector2 v2, Vector2 v3)
                ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void InitTimer()':
Scenes/../physac.h:1995:13: error: redefinition of 'void InitTimer()'
 static void InitTimer(void)
             ^
In file included from main.cpp:6:0:
physac.h:1995:13: note: 'void InitTimer()' previously defined here
 static void InitTimer(void)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'uint64_t GetTimeCount()':
Scenes/../physac.h:2020:17: error: redefinition of 'uint64_t GetTimeCount()'
 static uint64_t GetTimeCount(void)
                 ^
In file included from main.cpp:6:0:
physac.h:2020:17: note: 'uint64_t GetTimeCount()' previously defined here
 static uint64_t GetTimeCount(void)
                 ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'double GetCurrentTime()':
Scenes/../physac.h:2042:15: error: redefinition of 'double GetCurrentTime()'
 static double GetCurrentTime(void)
               ^
In file included from main.cpp:6:0:
physac.h:2042:15: note: 'double GetCurrentTime()' previously defined here
 static double GetCurrentTime(void)
               ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'Vector2 MathCross(float, Vector2)':
Scenes/../physac.h:2048:23: error: redefinition of 'Vector2 MathCross(float, Vector2)'
 static inline Vector2 MathCross(float value, Vector2 vector)
                       ^
In file included from main.cpp:6:0:
physac.h:2048:23: note: 'Vector2 MathCross(float, Vector2)' previously defined here
 static inline Vector2 MathCross(float value, Vector2 vector)
                       ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'float MathCrossVector2(Vector2, Vector2)':
Scenes/../physac.h:2054:21: error: redefinition of 'float MathCrossVector2(Vector2, Vector2)'
 static inline float MathCrossVector2(Vector2 v1, Vector2 v2)
                     ^
In file included from main.cpp:6:0:
physac.h:2054:21: note: 'float MathCrossVector2(Vector2, Vector2)' previously defined here
 static inline float MathCrossVector2(Vector2 v1, Vector2 v2)
                     ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'float MathLenSqr(Vector2)':
Scenes/../physac.h:2060:21: error: redefinition of 'float MathLenSqr(Vector2)'
 static inline float MathLenSqr(Vector2 vector)
                     ^
In file included from main.cpp:6:0:
physac.h:2060:21: note: 'float MathLenSqr(Vector2)' previously defined here
 static inline float MathLenSqr(Vector2 vector)
                     ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'float MathDot(Vector2, Vector2)':
Scenes/../physac.h:2066:21: error: redefinition of 'float MathDot(Vector2, Vector2)'
 static inline float MathDot(Vector2 v1, Vector2 v2)
                     ^
In file included from main.cpp:6:0:
physac.h:2066:21: note: 'float MathDot(Vector2, Vector2)' previously defined here
 static inline float MathDot(Vector2 v1, Vector2 v2)
                     ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'float DistSqr(Vector2, Vector2)':
Scenes/../physac.h:2072:21: error: redefinition of 'float DistSqr(Vector2, Vector2)'
 static inline float DistSqr(Vector2 v1, Vector2 v2)
                     ^
In file included from main.cpp:6:0:
physac.h:2072:21: note: 'float DistSqr(Vector2, Vector2)' previously defined here
 static inline float DistSqr(Vector2 v1, Vector2 v2)
                     ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void MathNormalize(Vector2*)':
Scenes/../physac.h:2079:13: error: redefinition of 'void MathNormalize(Vector2*)'
 static void MathNormalize(Vector2 *vector)
             ^
In file included from main.cpp:6:0:
physac.h:2079:13: note: 'void MathNormalize(Vector2*)' previously defined here
 static void MathNormalize(Vector2 *vector)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'Vector2 Vector2Add(Vector2, Vector2)':
Scenes/../physac.h:2097:23: error: redefinition of 'Vector2 Vector2Add(Vector2, Vector2)'
 static inline Vector2 Vector2Add(Vector2 v1, Vector2 v2)
                       ^
In file included from main.cpp:6:0:
physac.h:2097:23: note: 'Vector2 Vector2Add(Vector2, Vector2)' previously defined here
 static inline Vector2 Vector2Add(Vector2 v1, Vector2 v2)
                       ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'Vector2 Vector2Subtract(Vector2, Vector2)':
Scenes/../physac.h:2103:23: error: redefinition of 'Vector2 Vector2Subtract(Vector2, Vector2)'
 static inline Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
                       ^
In file included from main.cpp:6:0:
physac.h:2103:23: note: 'Vector2 Vector2Subtract(Vector2, Vector2)' previously defined here
 static inline Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
                       ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'Mat2 Mat2Radians(float)':
Scenes/../physac.h:2110:13: error: redefinition of 'Mat2 Mat2Radians(float)'
 static Mat2 Mat2Radians(float radians)
             ^
In file included from main.cpp:6:0:
physac.h:2110:13: note: 'Mat2 Mat2Radians(float)' previously defined here
 static Mat2 Mat2Radians(float radians)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'void Mat2Set(Mat2*, float)':
Scenes/../physac.h:2119:13: error: redefinition of 'void Mat2Set(Mat2*, float)'
 static void Mat2Set(Mat2 *matrix, float radians)
             ^
In file included from main.cpp:6:0:
physac.h:2119:13: note: 'void Mat2Set(Mat2*, float)' previously defined here
 static void Mat2Set(Mat2 *matrix, float radians)
             ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'Mat2 Mat2Transpose(Mat2)':
Scenes/../physac.h:2131:20: error: redefinition of 'Mat2 Mat2Transpose(Mat2)'
 static inline Mat2 Mat2Transpose(Mat2 matrix)
                    ^
In file included from main.cpp:6:0:
physac.h:2131:20: note: 'Mat2 Mat2Transpose(Mat2)' previously defined here
 static inline Mat2 Mat2Transpose(Mat2 matrix)
                    ^
In file included from Scenes/Scenes.h:4:0,
                 from main.cpp:8:
Scenes/../physac.h: In function 'Vector2 Mat2MultiplyVector2(Mat2, Vector2)':
Scenes/../physac.h:2137:23: error: redefinition of 'Vector2 Mat2MultiplyVector2(Mat2, Vector2)'
 static inline Vector2 Mat2MultiplyVector2(Mat2 matrix, Vector2 vector)
                       ^
In file included from main.cpp:6:0:
physac.h:2137:23: note: 'Vector2 Mat2MultiplyVector2(Mat2, Vector2)' previously defined here
 static inline Vector2 Mat2MultiplyVector2(Mat2 matrix, Vector2 vector)

Examples require external libraries

When trying to execute example files (.exe), external DLL libraries are requested (MinGW libraries).

To avoid that, examples must be compiled using the following line:

gcc -o $(NAME_PART).exe $(FILE_NAME) -s $(RAYLIB_DIR)\raylib\raylib_icon -static -lraylib -lpthread -lglfw3 -lopengl32 -lgdi32 -lopenal32 -lwinmm -std=c99 -Wl,--subsystem,windows -Wl,-allow-multiple-definition

MinGW with GCC 5.3.0 should be used (includes updated pthread library).

Heap use after free in examples

Related issues: raysan5/raylib#485 and raysan5/raylib#486

As stated by another user by mail, those issues seem related to:

...when you call reset the code is still running in the thread... so while it iterating over the items, suddenly they are removed and of course you will get floating point errors and access violations. Also destroying and item while iterating over the list, will cause these problems too.

...basically in a thread environment, you have to project critical sections with semaphores.... I basically flatten the PhysicsLoop into a routine called PhysicsThread... and then have my own loop that calls PhysicsThread and I wrap this in critical sections (pseudocode:

procedure physics_loop
begin
    repeat 
        lock.enter;
        PhysicsThread;
        lock.leave
    until done = true;
end;

No shared libs (dlls, dylib, so) built for Physac

Hi victor!
It is weird if i asked for shared library files for Physac,Cause i'm trying to bind it to LuaJIT

Is it okay if you offered built shared library files (dll, dylib, so) for Physac?
Sorry if i'm annoying you

And thanks for reading ^^

Change return type of PhysicsLoop

When using the built-in pthreads functions, the return type of PhysicsLoop isn't used. However I'm trying to use SDL_CreateThread which expects the function to return an int. Could this be changed for better compatibility?

Do not compute physics for one body when a collision occurs

Hi there, I am using raylib and Physac for a small game about space.

There are a couple of bodies I'm using, one for the sun and one for a test planet. The player is a planet as well and can move freely but is effected by a pull from the planets by using PhysicsAddForce(). I do want the player and other planets to be effected by their pull.

When the player collides with a planet (and that planet is moving), the players force changes (bounces off) but so does the planets (bounces away). Is there a way to make it to where the planet is not effected by the player?

I think basically what I want is body->enabled = false but only for collisions? I'm not sure exactly.

I saw this: https://github.com/victorfisac/Physac/blob/master/src/physac.h#L1251 and thought it might be in there somewhere...but not sure.

2022-10-18_22-10-1666151653

The game currently looks like this. The sun is not moving, the small planet is the player, the large planet is orbiting around the sun.

Thank you for any help with this and thank you for creating Physac :)

Add examples pack

Physac needs a interesting pack of examples to show all features and results of the library. I have this pack as reference to adapt them to Physac: https://phaser.io/examples/v2/category/box2d

Current examples are a simple demo of creating random physics bodies and a shatter feature example...

Initialize frequency to a different value

I asked this question and we seem to have found out a bug:

In the GetCurrentTime() function there is this bit of code:

...
    return (double)(GetTimeCount() - baseTime)/frequency*1000;
...

Frequency get initialized when InitTimer() is called, but there is a snip that might fail and it would remain 0:

#if defined(__linux__)
    struct timespec now;
    if (clock_gettime(CLOCK_MONOTONIC, &now) == 0)
        frequency = 1000000000;
#endif

on linux, if clock_gettime() fails, frequency will remain 0, which will cause a division by 0 in GetCurrentTime()

Maybe initialize it with 1?

Typo in physac.h

At around like 255, I believe there is a typo and instead of:

int __stdcall QueryPerformanceCounter(unsigned long long int* lpPerformanceCount);
int __stdcall QueryPerformanceFrequency(unsigned long long int* lpFrequency);

there should be:

#if defined(__cplusplus)
extern "C" {                                    // Prevents name mangling of functions
#endif
int __stdcall QueryPerformanceCounter(unsigned long long int* lpPerformanceCount);
int __stdcall QueryPerformanceFrequency(unsigned long long int* lpFrequency);
#if defined(__cplusplus)
}
#endif

Performance with 100 contacting circles / FindAvailableManifoldIndex()

When running a small test with 100 colliding circles, the performance is extremely slow.
Profiling shows that 99% of the cpu time is consumed by the FindAvailableManifoldIndex() function.

It seems that this function returns the first available manifold id.
But it only used from the PhysicsStep function,
and that function first deletes all manifolds.

So would the first available manifold id not just be the number of manifolds + 1 ?

like so:

// Finds a valid index for a new manifold initialization
static int FindAvailableManifoldIndex()
{
    const int id = physicsManifoldsCount + 1;

    if (id >= PHYSAC_MAX_MANIFOLDS)
        return -1;
    return id;
}

my test program (cpp)

    SetPhysicsGravity(0, 0);

    // Create obstacle circle physics body
    Vector2 position = { 0, 0 };


    for (float i = 0; i < 100; i++)
    {
        CreatePhysicsBodyCircle({i,i}, 5, 10);
    };

    PhysicsBody floor = CreatePhysicsBodyRectangle({0,-100}, 500, 5, 10);
    floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)

    for (int i = 0; i < 5; i++)
    {
        PhysicsStep();
        std::cout << i << std::endl;
        
    }

No physics calculations in example programs

The examples in examples/ run, but no physics calulcations are applied. Tried current master branch on FreeBSD 12.1, with raylib 3.0.0 from ports:

# pkg install devel/raylib

Building and running (with raymath.h in src/):

$ gcc -I/usr/local/include/ -L/usr/local/lib/ -I../src/ -o demo physics_demo.c -lm -lpthread -lraylib
$ ./demo
INFO: Initializing raylib 3.0
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1920 x 1080
INFO:     > Render size:  800 x 450
INFO:     > Screen size:  800 x 450
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: OpenGL 3.3 Core profile supported
INFO: GL: OpenGL device information:
INFO:     > Vendor:   Intel Open Source Technology Center
INFO:     > Renderer: Mesa DRI Intel(R) HD Graphics 620 (Kaby Lake GT2) 
INFO:     > Version:  4.5 (Core Profile) Mesa 19.0.8
INFO:     > GLSL:     4.50
INFO: GL: Supported extensions count: 204
INFO: GL: DXT compressed textures supported
INFO: GL: ETC2/EAC compressed textures supported
INFO: GL: Anisotropic textures filtering supported (max: 16X)
INFO: TEXTURE: [ID 1] Texture created successfully (1x1 - 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Compiled successfully
INFO: SHADER: [ID 2] Compiled successfully
INFO: SHADER: [ID 3] Program loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Internal vertex buffers initialized successfully in RAM (CPU)
INFO: RLGL: Internal vertex buffers uploaded successfully to VRAM (GPU)
INFO: RLGL: Default state initialized successfully
INFO: TEXTURE: [ID 2] Texture created successfully (128x128 - 1 mipmaps)
INFO: FONT: Default font loaded successfully
[PHYSAC] physics module initialized successfully
[PHYSAC] physics thread created successfully
[PHYSAC] created polygon physics body id 0
[PHYSAC] created polygon physics body id 1
INFO: TIMER: Target time per frame: 16.667 milliseconds
[PHYSAC] created polygon physics body id 2
[PHYSAC] created polygon physics body id 3
[PHYSAC] created polygon physics body id 4
[PHYSAC] destroyed physics body id 4
[PHYSAC] destroyed physics body id 3
[PHYSAC] destroyed physics body id 2
[PHYSAC] destroyed physics body id 1
[PHYSAC] destroyed physics body id 0
[PHYSAC] physics module closed successfully
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: TEXTURE: [ID 1] Unloaded default texture data from VRAM (GPU)
INFO: Window closed successfully

The bodies are created on mouse click events, but they do not seem to move.

cpu usage 100%

The CPU overloaded,even if few bodies.What can I do? Thank you, for your work! (Linux Mint x64)

Physac library seems to not be doing anything

I setup raylib and physac and when I ran the example project, the physics bodies where just floating and not being affected by the collision.

The way i set raylib up was by installing it from the NuGet package manager in visual studio because raylib always works that way for me.

I tried importing physac into the project directly but it was missing some header files. So I added the header files and still got the same error of the physics bodies not being affected by gravity or collisions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.