ref: 96472bc52ce103a27f3863b5528d5789090830e8
parent: 2ce8658f750d32ea39c12b2fbab7423a40995011
author: David <gek@katherine>
date: Mon Feb 15 06:35:56 EST 2021
SDL EXAMPLES physics library update
--- a/SDL_Examples/Makefile
+++ b/SDL_Examples/Makefile
@@ -6,7 +6,7 @@
LIB= ../lib/libTinyGL.a
all: $(ALL_T)
clean:
- rm -f $(ALL_T)
+ rm -f $(ALL_T) *.exe
texture:
gcc texture.c $(LIB) -o texture $(GL_INCLUDES) $(GL_LIBS) $(CFLAGS) -lSDL -lSDL_mixer -lmad -logg -lmikmod -logg -lm
helloworld:
--- a/SDL_Examples/include/chadphys.h
+++ b/SDL_Examples/include/chadphys.h
@@ -55,21 +55,22 @@
.d[2]=0,
.d[3]=0
};
- if(a->shape.c[3] > 0 && b->shape.c[3] > 0) //Both Spheres!
+ if(a->shape.c.d[3] > 0 && b->shape.c.d[3] > 0) //Both Spheres!
{
penvec = spherevsphere(a->shape.c, b->shape.c);
- } else if(a->shape.c[3] <= 0 && b->shape.c[3] <= 0) //Both boxes!
+ } else if(a->shape.c.d[3] <= 0 && b->shape.c.d[3] <= 0) //Both boxes!
{
penvec = boxvbox(a->shape,b->shape);
- } else if (a->shape.c[3] > 0 && b->shape.c[3] <= 0) //a is a sphere, b is a box
+ } else if (a->shape.c.d[3] > 0 && b->shape.c.d[3] <= 0) //a is a sphere, b is a box
{
- penvec = aabbvsphere(b->shape,a->shape.c);
- //b was first so we have to swap these.
+ penvec = spherevaabb(a->shape.c,b->shape);
+
+
+ } else if (a->shape.c.d[3] <= 0 && b->shape.c.d[3] > 0){ //a is a box, b is a sphere
+ penvec = spherevaabb(b->shape.c,a->shape);
penvec.d[0] *= -1;
penvec.d[1] *= -1;
penvec.d[2] *= -1;
- } else if (a->shape.c[3] <= 0 && b->shape.c[3] > 0){ //a is a box, b is a sphere
- penvec = aabbvsphere(a->shape,b->shape.c);
} else {
puts("\nInvalid configuration. Error.\n");
}