summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2019-02-05 22:05:47 -0600
committerepoch <epoch@hacking.allowed.org>2019-02-05 22:05:47 -0600
commitfda612360aae6a3df9ff3bfb419d05b3c56503ee (patch)
tree06cbc9cfd8aa5566abf98e03374854dd82a964ad /src
parent3691d2d55b83cda0f49ce96734a557522c5e424c (diff)
downloadhackvr-fda612360aae6a3df9ff3bfb419d05b3c56503ee.tar.gz
hackvr-fda612360aae6a3df9ff3bfb419d05b3c56503ee.zip
added physics.c
Diffstat (limited to 'src')
-rw-r--r--src/physics.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/physics.c b/src/physics.c
new file mode 100644
index 0000000..a414244
--- /dev/null
+++ b/src/physics.c
@@ -0,0 +1,33 @@
+#include "common.h"
+
+extern struct global global;
+extern struct gra_global gra_global;
+
+#define MINIMUM_Y 10
+#define GRAVITY 9.8
+
+//collision detection and gravity
+//I need to get a sphere of each object then compare distances and radii.
+//maye let each object have a collision box type. either rectangular prism or sphere.
+//sphere would be fine for players.
+
+/// VELOCITIES:
+/*
+foward/backward, left/right, up/down, x, y, z
+rotation-relative-x,rry,rrz
+*/
+int apply_physics() {
+ int i;
+ //we can just assume things will float if they don't have a group_rot
+ for(i=0;global.group_rot[i] && i < MAXSHAPES;i++) {//this should be applied to group_rots
+ if(!strcmp(global.group_rot[i]->id,global.user)) {//only apply gravity to the camera.
+ global.group_rot[i]->v.y += (GRAVITY / (float)(global.lps?global.lps:1)); //heh. "fps" needs a headless equivalent now.
+ global.group_rot[i]->p.y -= global.group_rot[i]->v.y;
+ if(global.group_rot[i]->p.y < MINIMUM_Y) {//we've moved so we need to output a move command?
+ global.group_rot[i]->v.y=0;
+ global.group_rot[i]->p.y=MINIMUM_Y;
+ }
+ }
+ }
+ return 1;
+}