From e0d8cceb65def88e6c425b1d78b3d84655cb9967 Mon Sep 17 00:00:00 2001 From: victorfisac Date: Sun, 3 Jan 2016 17:52:18 +0100 Subject: [PATCH 1/6] Fixed lighting engine module newlines at end of file --- src/lighting.c | 2 +- src/lighting.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lighting.c b/src/lighting.c index 5cf2a2ecb..9014dcd48 100644 --- a/src/lighting.c +++ b/src/lighting.c @@ -121,4 +121,4 @@ void SetMaterialGlossiness(Material *material, float glossiness) void SetMaterialNormalDepth(Material *material, float depth) { material->normalDepth[0] = depth; -} \ No newline at end of file +} diff --git a/src/lighting.h b/src/lighting.h index a35113c3e..e1fc4e50b 100644 --- a/src/lighting.h +++ b/src/lighting.h @@ -84,4 +84,4 @@ void SetMaterialNormalDepth(Material *material, float depth); // Set n } #endif -#endif // LIGHTING_H \ No newline at end of file +#endif // LIGHTING_H From a299bc289b36a40efcf9d02597d5122546458021 Mon Sep 17 00:00:00 2001 From: victorfisac Date: Sun, 3 Jan 2016 17:53:29 +0100 Subject: [PATCH 2/6] Improved and added functions to physac engine module - Improved physics calculations. - Added AddForceAtPosition function (added to all enabled rigidbodies). - Updated raylib header. --- src/physac.c | 150 +++++++++++++++++++++++++++++++++++++-------------- src/physac.h | 28 +++++----- src/raylib.h | 24 +++++---- 3 files changed, 138 insertions(+), 64 deletions(-) diff --git a/src/physac.c b/src/physac.c index 11e1766e3..73ce7adc6 100644 --- a/src/physac.c +++ b/src/physac.c @@ -1,6 +1,6 @@ /********************************************************************************************** * -* raylib physics engine module - Basic functions to apply physics to 2D objects +* [physac] raylib physics engine module - Basic functions to apply physics to 2D objects * * Copyright (c) 2015 Victor Fisac and Ramon Santamaria * @@ -36,7 +36,7 @@ // Defines and Macros //---------------------------------------------------------------------------------- #define MAX_ELEMENTS 1024 // Stored rigidbodies and colliders array length -#define DECIMAL_FIX 0.01f // Decimal margin for collision checks (avoid rigidbodies shake) +#define DECIMAL_FIX 0.26f // Decimal margin for collision checks (avoid rigidbodies shake) //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -52,7 +52,14 @@ static Rigidbody rigidbodies[MAX_ELEMENTS]; static bool collisionChecker = false; //---------------------------------------------------------------------------------- -// Module Functions Definition +// Module specific Functions Declarations +//---------------------------------------------------------------------------------- +static float Vector2Length(Vector2 vector); +static float Vector2LengthPoints(Vector2 a, Vector2 b); +static Vector2 Vector2Normalize(Vector2 vector); + +//---------------------------------------------------------------------------------- +// Module Functions Definitions //---------------------------------------------------------------------------------- void InitPhysics() { @@ -94,12 +101,32 @@ void ApplyPhysics(int index, Vector2 *position) { if (rigidbodies[index].enabled) { - // Apply gravity - rigidbodies[index].velocity.y += rigidbodies[index].acceleration.y; - rigidbodies[index].velocity.x += rigidbodies[index].acceleration.x; + // Apply friction to acceleration + if (rigidbodies[index].acceleration.x > DECIMAL_FIX) + { + rigidbodies[index].acceleration.x -= rigidbodies[index].friction; + } + else if (rigidbodies[index].acceleration.x < -DECIMAL_FIX) + { + rigidbodies[index].acceleration.x += rigidbodies[index].friction; + } + else + { + rigidbodies[index].acceleration.x = 0; + } - rigidbodies[index].velocity.y += physics.gravity.y; - rigidbodies[index].velocity.x += physics.gravity.x; + if (rigidbodies[index].acceleration.y > DECIMAL_FIX / 2) + { + rigidbodies[index].acceleration.y -= rigidbodies[index].friction; + } + else if (rigidbodies[index].acceleration.y < -DECIMAL_FIX / 2) + { + rigidbodies[index].acceleration.y += rigidbodies[index].friction; + } + else + { + rigidbodies[index].acceleration.y = 0; + } // Apply friction to velocity if (rigidbodies[index].isGrounded) @@ -118,11 +145,11 @@ void ApplyPhysics(int index, Vector2 *position) } } - if (rigidbodies[index].velocity.y > DECIMAL_FIX) + if (rigidbodies[index].velocity.y > DECIMAL_FIX / 2) { rigidbodies[index].velocity.y -= rigidbodies[index].friction; } - else if (rigidbodies[index].velocity.y < -DECIMAL_FIX) + else if (rigidbodies[index].velocity.y < -DECIMAL_FIX / 2) { rigidbodies[index].velocity.y += rigidbodies[index].friction; } @@ -131,35 +158,13 @@ void ApplyPhysics(int index, Vector2 *position) rigidbodies[index].velocity.y = 0; } - // Apply friction to acceleration - if (rigidbodies[index].isGrounded) - { - if (rigidbodies[index].acceleration.x > DECIMAL_FIX) - { - rigidbodies[index].acceleration.x -= rigidbodies[index].friction; - } - else if (rigidbodies[index].acceleration.x < -DECIMAL_FIX) - { - rigidbodies[index].acceleration.x += rigidbodies[index].friction; - } - else - { - rigidbodies[index].acceleration.x = 0; - } - } + // Apply gravity + rigidbodies[index].velocity.y += physics.gravity.y; + rigidbodies[index].velocity.x += physics.gravity.x; - if (rigidbodies[index].acceleration.y > DECIMAL_FIX) - { - rigidbodies[index].acceleration.y -= rigidbodies[index].friction; - } - else if (rigidbodies[index].acceleration.y < -DECIMAL_FIX) - { - rigidbodies[index].acceleration.y += rigidbodies[index].friction; - } - else - { - rigidbodies[index].acceleration.y = 0; - } + // Apply acceleration + rigidbodies[index].velocity.y += rigidbodies[index].acceleration.y; + rigidbodies[index].velocity.x += rigidbodies[index].acceleration.x; // Update position vector position->x += rigidbodies[index].velocity.x; @@ -250,10 +255,49 @@ void SetRigidbodyVelocity(int index, Vector2 velocity) rigidbodies[index].velocity.y = velocity.y; } +void SetRigidbodyAcceleration(int index, Vector2 acceleration) +{ + rigidbodies[index].acceleration.x = acceleration.x; + rigidbodies[index].acceleration.y = acceleration.y; +} + void AddRigidbodyForce(int index, Vector2 force) { - rigidbodies[index].acceleration.x = force.x * rigidbodies[index].mass; - rigidbodies[index].acceleration.y = force.y * rigidbodies[index].mass; + rigidbodies[index].acceleration.x = force.x / rigidbodies[index].mass; + rigidbodies[index].acceleration.y = force.y / rigidbodies[index].mass; +} + +void AddForceAtPosition(Vector2 position, float intensity, float radius) +{ + for(int i = 0; i < MAX_ELEMENTS; i++) + { + if(rigidbodies[i].enabled) + { + // Get position from its collider + Vector2 pos = {colliders[i].bounds.x, colliders[i].bounds.y}; + + // Get distance between rigidbody position and target position + float distance = Vector2LengthPoints(position, pos); + + if(distance <= radius) + { + // Calculate force based on direction + Vector2 force = {colliders[i].bounds.x - position.x, colliders[i].bounds.y - position.y}; + + // Normalize the direction vector + force = Vector2Normalize(force); + + // Invert y value + force.y *= -1; + + // Apply intensity and distance + force = (Vector2){force.x * intensity / distance, force.y * intensity / distance}; + + // Add calculated force to the rigidbodies + AddRigidbodyForce(i, force); + } + } + } } void SetColliderEnabled(int index, bool state) @@ -270,3 +314,29 @@ Rigidbody GetRigidbody(int index) { return rigidbodies[index]; } + +//---------------------------------------------------------------------------------- +// Module specific Functions Definitions +//---------------------------------------------------------------------------------- +static float Vector2Length(Vector2 vector) +{ + return sqrt((vector.x * vector.x) + (vector.y * vector.y)); +} + +static float Vector2LengthPoints(Vector2 a, Vector2 b) +{ + Vector2 vector = {b.x - a.x, b.y - a.y}; + return sqrt((vector.x * vector.x) + (vector.y * vector.y)); +} + +static Vector2 Vector2Normalize(Vector2 vector) +{ + float length = Vector2Length(vector); + + if(length != 0) + { + return (Vector2){vector.x / length, vector.y / length}; + } + + return (Vector2){0, 0}; +} diff --git a/src/physac.h b/src/physac.h index aec57d6fc..7dbfe1fe7 100644 --- a/src/physac.h +++ b/src/physac.h @@ -1,6 +1,6 @@ /********************************************************************************************** * -* raylib physics engine module - Basic functions to apply physics to 2D objects +* [physac] raylib physics engine module - Basic functions to apply physics to 2D objects * * Copyright (c) 2015 Victor Fisac and Ramon Santamaria * @@ -74,23 +74,25 @@ extern "C" { // Prevents name mangling of functions #endif //---------------------------------------------------------------------------------- -// Module Functions Declaration +// Module Functions Declarations //---------------------------------------------------------------------------------- -void InitPhysics(); // Initialize all internal physics values -void SetPhysics(Physics settings); // Set physics settings values using Physics data type to overwrite internal physics settings +void InitPhysics(); // Initialize all internal physics values +void SetPhysics(Physics settings); // Set physics settings values using Physics data type to overwrite internal physics settings -void AddRigidbody(int index, Rigidbody rigidbody); // Initialize a new rigidbody with parameters to internal index slot -void AddCollider(int index, Collider collider); // Initialize a new Collider with parameters to internal index slot +void AddRigidbody(int index, Rigidbody rigidbody); // Initialize a new rigidbody with parameters to internal index slot +void AddCollider(int index, Collider collider); // Initialize a new Collider with parameters to internal index slot -void ApplyPhysics(int index, Vector2 *position); // Apply physics to internal rigidbody, physics calculations are applied to position pointer parameter -void SetRigidbodyEnabled(int index, bool state); // Set enabled state to a defined rigidbody -void SetRigidbodyVelocity(int index, Vector2 velocity); // Set velocity of rigidbody (without considering of mass value) -void AddRigidbodyForce(int index, Vector2 force); // Set rigidbody force (considering mass value) +void ApplyPhysics(int index, Vector2 *position); // Apply physics to internal rigidbody, physics calculations are applied to position pointer parameter +void SetRigidbodyEnabled(int index, bool state); // Set enabled state to a defined rigidbody +void SetRigidbodyVelocity(int index, Vector2 velocity); // Set velocity of rigidbody (without considering of mass value) +void SetRigidbodyAcceleration(int index, Vector2 acceleration); // Set acceleration of rigidbody (without considering of mass value) +void AddRigidbodyForce(int index, Vector2 force); // Set rigidbody force (considering mass value) +void AddForceAtPosition(Vector2 position, float intensity, float radius); // Add a force to all enabled rigidbodies at a position -void SetColliderEnabled(int index, bool state); // Set enabled state to a defined collider +void SetColliderEnabled(int index, bool state); // Set enabled state to a defined collider -Rigidbody GetRigidbody(int index); // Returns the internal rigidbody data defined by index parameter -Collider GetCollider(int index); // Returns the internal collider data defined by index parameter +Rigidbody GetRigidbody(int index); // Returns the internal rigidbody data defined by index parameter +Collider GetCollider(int index); // Returns the internal collider data defined by index parameter #ifdef __cplusplus } diff --git a/src/raylib.h b/src/raylib.h index 864a240ad..99a6979cd 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -793,21 +793,23 @@ void SetMaterialNormalDepth(Material *material, float depth); // Set n //---------------------------------------------------------------------------------- // Physics System Functions (engine-module: physics) //---------------------------------------------------------------------------------- -void InitPhysics(); // Initialize all internal physics values -void SetPhysics(Physics settings); // Set physics settings values using Physics data type to overwrite internal physics settings +void InitPhysics(); // Initialize all internal physics values +void SetPhysics(Physics settings); // Set physics settings values using Physics data type to overwrite internal physics settings -void AddRigidbody(int index, Rigidbody rigidbody); // Initialize a new rigidbody with parameters to internal index slot -void AddCollider(int index, Collider collider); // Initialize a new Collider with parameters to internal index slot +void AddRigidbody(int index, Rigidbody rigidbody); // Initialize a new rigidbody with parameters to internal index slot +void AddCollider(int index, Collider collider); // Initialize a new Collider with parameters to internal index slot -void ApplyPhysics(int index, Vector2 *position); // Apply physics to internal rigidbody, physics calculations are applied to position pointer parameter -void SetRigidbodyEnabled(int index, bool state); // Set enabled state to a defined rigidbody -void SetRigidbodyVelocity(int index, Vector2 velocity); // Set velocity of rigidbody (without considering of mass value) -void AddRigidbodyForce(int index, Vector2 force); // Set rigidbody force (considering mass value) +void ApplyPhysics(int index, Vector2 *position); // Apply physics to internal rigidbody, physics calculations are applied to position pointer parameter +void SetRigidbodyEnabled(int index, bool state); // Set enabled state to a defined rigidbody +void SetRigidbodyVelocity(int index, Vector2 velocity); // Set velocity of rigidbody (without considering of mass value) +void SetRigidbodyAcceleration(int index, Vector2 acceleration); // Set acceleration of rigidbody (without considering of mass value) +void AddRigidbodyForce(int index, Vector2 force); // Set rigidbody force (considering mass value) +void AddForceAtPosition(Vector2 position, float intensity, float radius); // Add a force to all enabled rigidbodies at a position -void SetColliderEnabled(int index, bool state); // Set enabled state to a defined collider +void SetColliderEnabled(int index, bool state); // Set enabled state to a defined collider -Rigidbody GetRigidbody(int index); // Returns the internal rigidbody data defined by index parameter -Collider GetCollider(int index); // Returns the internal collider data defined by index parameter +Rigidbody GetRigidbody(int index); // Returns the internal rigidbody data defined by index parameter +Collider GetCollider(int index); // Returns the internal collider data defined by index parameter //------------------------------------------------------------------------------------ // Audio Loading and Playing Functions (Module: audio) From 6608c5a8a7be1ad0f94dc643ec0537338f6829de Mon Sep 17 00:00:00 2001 From: victorfisac Date: Sun, 3 Jan 2016 17:54:06 +0100 Subject: [PATCH 3/6] Fixed physics basic example example name --- examples/physics_basic_rigidbody.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/physics_basic_rigidbody.c b/examples/physics_basic_rigidbody.c index 2f3fffbc2..17d6564fa 100644 --- a/examples/physics_basic_rigidbody.c +++ b/examples/physics_basic_rigidbody.c @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raylib [physics] example - Basic rigidbody +* raylib [physac] physics example - Basic rigidbody * * Welcome to raylib! * From b8b34a1b26df0b9b8c39d21f22f11000044fe5da Mon Sep 17 00:00:00 2001 From: victorfisac Date: Sun, 3 Jan 2016 17:58:16 +0100 Subject: [PATCH 4/6] Added new physics example New physics example to see AddForceAtPosition() behaviour applied to 5 rigidbodies. --- examples/physics_rigidbody_force.c | 141 +++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 examples/physics_rigidbody_force.c diff --git a/examples/physics_rigidbody_force.c b/examples/physics_rigidbody_force.c new file mode 100644 index 000000000..726e7c671 --- /dev/null +++ b/examples/physics_rigidbody_force.c @@ -0,0 +1,141 @@ +/******************************************************************************************* +* +* raylib [physac] physics example - Rigidbody forces +* +* This example has been created using raylib 1.3 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +#define MAX_OBJECTS 5 +#define OBJECTS_OFFSET 150 + +#define FORCE_INTENSITY 250.0f // Customize by user +#define FORCE_RADIUS 100 // Customize by user + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [physics] example - rigidbodies forces"); + SetTargetFPS(60); // Enable v-sync + InitPhysics(); // Initialize internal physics values (max rigidbodies/colliders available: 1024) + + // Physics initialization + Physics worldPhysics = {true, false, (Vector2){0, -9.81f}}; + + // Set internal physics settings + SetPhysics(worldPhysics); + + // Objects initialization + Transform objects[MAX_OBJECTS]; + for(int i = 0; i < MAX_OBJECTS; i++) + { + objects[i] = (Transform){(Vector2){75 + OBJECTS_OFFSET * i, (screenHeight - 50) / 2}, 0.0f, (Vector2){50, 50}}; + AddCollider(i, (Collider){true, RectangleCollider, (Rectangle){objects[i].position.x, objects[i].position.y, objects[i].scale.x, objects[i].scale.y}, 0}); + AddRigidbody(i, (Rigidbody){true, 1.0f, (Vector2){0, 0}, (Vector2){0, 0}, false, false, true, 0.5f, 0.5f}); + } + + // Floor initialization + // NOTE: floor doesn't need a rigidbody because it's a static physic object, just a collider to collide with other dynamic colliders (with rigidbody) + Transform floor = (Transform){(Vector2){0, screenHeight * 0.8f}, 0.0f, (Vector2){screenWidth, screenHeight * 0.2f}}; + AddCollider(MAX_OBJECTS, (Collider){true, RectangleCollider, (Rectangle){floor.position.x, floor.position.y, floor.scale.x, floor.scale.y}, 0}); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + + // Update object physics + // NOTE: all physics detections and reactions are calculated in ApplyPhysics() function (You will live happier :D) + for(int i = 0; i < MAX_OBJECTS; i++) + { + ApplyPhysics(i, &objects[i].position); + } + + // Check foce button input + if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + { + AddForceAtPosition(GetMousePosition(), FORCE_INTENSITY, FORCE_RADIUS); + } + + // Check debug mode toggle button input + if(IsKeyPressed(KEY_P)) + { + // Update program physics value + worldPhysics.debug = !worldPhysics.debug; + + // Update internal physics value + SetPhysics(worldPhysics); + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + // Check if debug mode is enabled + if(worldPhysics.debug) + { + // Draw every internal physics stored collider if it is active (floor included) + for(int i = 0; i < MAX_OBJECTS + 1; i++) + { + if(GetCollider(i).enabled) + { + // Draw collider bounds + DrawRectangleLines(GetCollider(i).bounds.x, GetCollider(i).bounds.y, GetCollider(i).bounds.width, GetCollider(i).bounds.height, GREEN); + + // Check if current collider is not floor + if(i < MAX_OBJECTS) + { + // Draw lines between mouse position and objects if they are in force range + if(CheckCollisionPointCircle(GetMousePosition(), (Vector2){GetCollider(i).bounds.x + GetCollider(i).bounds.width / 2, GetCollider(i).bounds.y + GetCollider(i).bounds.height / 2}, FORCE_RADIUS)) + { + DrawLineV(GetMousePosition(), (Vector2){GetCollider(i).bounds.x + GetCollider(i).bounds.width / 2, GetCollider(i).bounds.y + GetCollider(i).bounds.height / 2}, RED); + } + } + } + } + + // Draw radius circle + DrawCircleLines(GetMousePosition().x, GetMousePosition().y, FORCE_RADIUS, RED); + } + else + { + // Draw objects + for(int i = 0; i < MAX_OBJECTS; i++) + { + DrawRectangleRec((Rectangle){objects[i].position.x, objects[i].position.y, objects[i].scale.x, objects[i].scale.y}, GRAY); + } + + // Draw floor + DrawRectangleRec((Rectangle){floor.position.x, floor.position.y, floor.scale.x, floor.scale.y}, BLACK); + } + + + // Draw help messages + DrawText("Use LEFT MOUSE BUTTON to create a force in mouse position", (screenWidth - MeasureText("Use LEFT MOUSE BUTTON to create a force in mouse position", 20)) / 2, screenHeight * 0.20f, 20, LIGHTGRAY); + DrawText("Use P to switch DEBUG MODE", (screenWidth - MeasureText("Use P to switch DEBUG MODE", 20)) / 2, screenHeight * 0.3f, 20, LIGHTGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} From 8fa5c9dce29e3d25cfe5c6e9baba2b6655e071bb Mon Sep 17 00:00:00 2001 From: victorfisac Date: Sun, 3 Jan 2016 18:05:09 +0100 Subject: [PATCH 5/6] Added rigidbody force example image --- examples/physics_rigidbody_force.png | Bin 0 -> 18510 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/physics_rigidbody_force.png diff --git a/examples/physics_rigidbody_force.png b/examples/physics_rigidbody_force.png new file mode 100644 index 0000000000000000000000000000000000000000..48afa91b05fe843aea605d30e3af39996dddca1c GIT binary patch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0r9{a8z;Mad&~qnK)wMvqv2%Dj(@W*olR$U3rBG0sM9GY3&2+FDcm;#Wz^HPN z3j&ZAv9*Z7WfZgkfv5qCfQk!D21mdKI;Vst08*?pTmS$7 literal 0 HcmV?d00001 From 1656d17b22b362e54710b7164638464e02bd7e5a Mon Sep 17 00:00:00 2001 From: victorfisac Date: Sun, 3 Jan 2016 18:24:20 +0100 Subject: [PATCH 6/6] Fixed little bug in lighting blinn phong example --- examples/lighting_blinn_phong.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/lighting_blinn_phong.c b/examples/lighting_blinn_phong.c index 48949b032..d4ff548a7 100644 --- a/examples/lighting_blinn_phong.c +++ b/examples/lighting_blinn_phong.c @@ -31,7 +31,7 @@ int main() // Model initialization Vector3 position = { 0.0, 0.0, 0.0 }; Model model = LoadModel("resources/model/dwarf.obj"); - // Shader shader = LoadShader("resources/shaders/phong.vs", "resources/shaders/phong.fs"); + Shader shader = LoadShader("resources/shaders/phong.vs", "resources/shaders/phong.fs"); SetModelShader(&model, shader); // Shader locations initialization @@ -154,7 +154,7 @@ int main() Begin3dMode(camera); - DrawModel(model, position, 0.1f, (Color){255 * blinnMaterial.diffuseColor[0], 255 * blinnMaterial.diffuseColor[1], 255 * blinnMaterial.diffuseColor[2], 255}); + DrawModel(model, position, 4.0f, (Color){255 * blinnMaterial.diffuseColor[0], 255 * blinnMaterial.diffuseColor[1], 255 * blinnMaterial.diffuseColor[2], 255}); DrawSphere((Vector3){directionalLight.position[0], directionalLight.position[1], directionalLight.position[2]}, 1, YELLOW);