From 67d33734294bb2ab1d5c70a884ac17bddb4c5ef9 Mon Sep 17 00:00:00 2001 From: arc1tec4 Date: Sun, 27 Oct 2024 08:52:02 -0600 Subject: [PATCH] Add files via upload --- rc_sprite_physics.h | 185 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 rc_sprite_physics.h diff --git a/rc_sprite_physics.h b/rc_sprite_physics.h new file mode 100644 index 0000000..f7d4156 --- /dev/null +++ b/rc_sprite_physics.h @@ -0,0 +1,185 @@ +#include "rc_sprite2D.h" + +void rc_applySpriteAngularImpulse(int spr_id, float impulse, bool wake) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return; + + if(!rc_sprite[spr_id].active) + return; + + rc_sprite[spr_id].physics.body->ApplyAngularImpulse(impulse, wake); +} + +void rc_applySpriteForce(int spr_id, double fX, double fY, double pX, double pY, bool wake) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return; + + if(!rc_sprite[spr_id].active) + return; + + rc_sprite[spr_id].physics.body->ApplyForce(b2Vec2(fX, fY), b2Vec2(pX, pY), wake); +} + +void rc_applySpriteForceToCenter(int spr_id, double x, double y, bool wake) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return; + + if(!rc_sprite[spr_id].active) + return; + + rc_sprite[spr_id].physics.body->ApplyForceToCenter(b2Vec2(x, y), wake); +} + +void rc_applySpriteLinearImpulse(int spr_id, double iX, double iY, double pX, double pY, bool wake) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return; + + if(!rc_sprite[spr_id].active) + return; + + rc_sprite[spr_id].physics.body->ApplyLinearImpulse(b2Vec2(iX, iY), b2Vec2(pX, pY), wake); +} + +void rc_applySpriteLinearForceToCenter(int spr_id, double x, double y, bool wake) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return; + + if(!rc_sprite[spr_id].active) + return; + + rc_sprite[spr_id].physics.body->ApplyLinearImpulseToCenter(b2Vec2(x, y), wake); +} + +void rc_applySpriteTorque(int spr_id, float torque, bool wake) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return; + + if(!rc_sprite[spr_id].active) + return; + + rc_sprite[spr_id].physics.body->ApplyTorque(torque, wake); +} + +float rc_getSpriteAngle(int spr_id) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return 0; + + if(!rc_sprite[spr_id].active) + return 0; + + return rc_sprite[spr_id].physics.body->GetAngle(); +} + +float rc_getSpriteAngularVelocity(int spr_id) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return 0; + + if(!rc_sprite[spr_id].active) + return 0; + + return rc_sprite[spr_id].physics.body->GetAngularVelocity(); +} + +float rc_getSpriteInertia(int spr_id) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return 0; + + if(!rc_sprite[spr_id].active) + return 0; + + return rc_sprite[spr_id].physics.body->GetInertia(); +} + +void rc_getSpriteLinearVelocity(int spr_id, double* x, double* y) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return; + + if(!rc_sprite[spr_id].active) + return; + + *x = (double)rc_sprite[spr_id].physics.body->GetLinearVelocity().x; + *y = (double)rc_sprite[spr_id].physics.body->GetLinearVelocity().y; +} + +void rc_getSpriteLinearVelocityFromLocalPoint(int spr_id, double* x, double* y, double pX, double pY) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return; + + if(!rc_sprite[spr_id].active) + return; + + b2Vec2 pos = rc_sprite[spr_id].physics.body->GetLinearVelocityFromLocalPoint(b2Vec2(pX, pY)); + *x = pos.x; + *y = pos.y; +} + +void rc_getSpriteLinearVelocityFromWorldPoint(int spr_id, double* x, double* y, double wX, double wY) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return 0; + + if(!rc_sprite[spr_id].active) + return 0; + + b2Vec2 pos = rc_sprite[spr_id].physics.body->GetLinearVelocityFromWorldPoint(b2Vec2(wX, wY)); + *x = pos.x; + *y = pos.y; +} + +void rc_getSpriteLocalPoint() ******************************* +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return 0; + + if(!rc_sprite[spr_id].active) + return 0; +} + +void rc_getSpriteLocalVector() ******************************* +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return 0; + + if(!rc_sprite[spr_id].active) + return 0; +} + +float rc_getSpriteMass(int spr_id) +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return 0; + + if(!rc_sprite[spr_id].active) + return 0; + + return rc_sprite[spr_id].physics.body->GetMass(); +} + +void rc_getSpriteMassData(int spr_id) ******************************* +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return 0; + + if(!rc_sprite[spr_id].active) + return 0; +} + +void rc_getSpriteTransform(int spr_id) ******************************* +{ + if(spr_id < 0 || spr_id >= rc_sprite.size()) + return 0; + + if(!rc_sprite[spr_id].active) + return 0; +}