Skip to content

Commit

Permalink
Refactor src/rigid_body.c
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeokkim committed Nov 8, 2024
1 parent 3c4bf7c commit 48d34b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/external/ferox_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
/* Creates a bit array with `n` bits. */
#define frCreateBitArray(n) \
calloc( \
((n) + (INT_BIT - 1) / INT_BIT), \
sizeof(frBitArray) \
((n) + (INT_BIT - 1)) / INT_BIT, \
sizeof(int) \
)

/* Releases the memory allocated for `ba`. */
Expand Down
16 changes: 8 additions & 8 deletions src/rigid_body.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ void frSetBodyUserData(frBody *b, void *userData) {
bool frBodyContainsPoint(const frBody *b, frVector2 point) {
if (b == NULL) return false;

const frShape *s = frGetBodyShape(b);
const frShape *s = b->shape;

frTransform tx = frGetBodyTransform(b);
frTransform tx = b->tx;
frShapeType type = frGetShapeType(s);

if (type == FR_SHAPE_CIRCLE) {
Expand Down Expand Up @@ -338,11 +338,11 @@ void frApplyAccumulatedImpulses(frBody *b1,
if (b1 == NULL || b2 == NULL || collision == NULL) return;

if (b1->mtn.inverseMass + b2->mtn.inverseMass <= 0.0f) {
if (frGetBodyType(b1) == FR_BODY_STATIC)
if (b1->type == FR_BODY_STATIC)
b1->mtn.velocity.x = b1->mtn.velocity
.y = b1->mtn.angularVelocity = 0.0f;

if (frGetBodyType(b2) == FR_BODY_STATIC)
if (b2->type == FR_BODY_STATIC)
b2->mtn.velocity.x = b2->mtn.velocity
.y = b2->mtn.angularVelocity = 0.0f;

Expand All @@ -355,9 +355,9 @@ void frApplyAccumulatedImpulses(frBody *b1,
frVector2 contactPoint = collision->contacts[i].point;

frVector2 relPosition1 = frVector2Subtract(contactPoint,
frGetBodyPosition(b1));
b1->tx.position);
frVector2 relPosition2 = frVector2Subtract(contactPoint,
frGetBodyPosition(b2));
b2->tx.position);

float relPositionCross1 = frVector2Cross(relPosition1,
collision->direction);
Expand Down Expand Up @@ -460,9 +460,9 @@ void frResolveCollision(frBody *b1,
frVector2 contactPoint = collision->contacts[i].point;

frVector2 relPosition1 = frVector2Subtract(contactPoint,
frGetBodyPosition(b1));
b1->tx.position);
frVector2 relPosition2 = frVector2Subtract(contactPoint,
frGetBodyPosition(b2));
b2->tx.position);

frVector2 relNormal1 = frVector2LeftNormal(relPosition1);
frVector2 relNormal2 = frVector2LeftNormal(relPosition2);
Expand Down

0 comments on commit 48d34b0

Please sign in to comment.