aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/contrib/dRay/dRay_Plane.cpp
diff options
context:
space:
mode:
authordan miller2007-10-19 05:15:33 +0000
committerdan miller2007-10-19 05:15:33 +0000
commit79eca25c945a535a7a0325999034bae17da92412 (patch)
tree40ff433d94859d629aac933d5ec73b382f62ba1a /libraries/ode-0.9/contrib/dRay/dRay_Plane.cpp
parentadding ode source to /libraries (diff)
downloadopensim-SC_OLD-79eca25c945a535a7a0325999034bae17da92412.zip
opensim-SC_OLD-79eca25c945a535a7a0325999034bae17da92412.tar.gz
opensim-SC_OLD-79eca25c945a535a7a0325999034bae17da92412.tar.bz2
opensim-SC_OLD-79eca25c945a535a7a0325999034bae17da92412.tar.xz
resubmitting ode
Diffstat (limited to 'libraries/ode-0.9/contrib/dRay/dRay_Plane.cpp')
-rw-r--r--libraries/ode-0.9/contrib/dRay/dRay_Plane.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/libraries/ode-0.9/contrib/dRay/dRay_Plane.cpp b/libraries/ode-0.9/contrib/dRay/dRay_Plane.cpp
new file mode 100644
index 0000000..cf03c5b
--- /dev/null
+++ b/libraries/ode-0.9/contrib/dRay/dRay_Plane.cpp
@@ -0,0 +1,35 @@
1// Ripped from Paul Bourke
2
3#include "Include\dRay.h"
4#include "dxRay.h"
5
6int dCollidePR(dxGeom* RayGeom, dxGeom* PlaneGeom, int Flags, dContactGeom* Contact, int Stride){
7 dVector3 Plane;
8 dGeomPlaneGetParams(PlaneGeom, Plane);
9
10 dVector3 Origin, Direction;
11 dGeomRayGet(RayGeom, Origin, Direction);
12
13 dReal Length = dGeomRayGetLength(RayGeom);
14
15 dReal Denom = Plane[0] * Direction[0] + Plane[1] * Direction[1] + Plane[2] * Direction[2];
16 if (dFabs(Denom) < 0.00001f){
17 return 0; // Ray never hits
18 }
19
20 float T = -(Plane[3] + Plane[0] * Origin[0] + Plane[1] * Origin[1] + Plane[2] * Origin[2]) / Denom;
21
22 if (T < 0 || T > Length){
23 return 0; // Ray hits but not within boundaries
24 }
25
26 Contact->pos[0] = Origin[0] + T * Direction[0];
27 Contact->pos[1] = Origin[1] + T * Direction[1];
28 Contact->pos[2] = Origin[2] + T * Direction[2];
29 Contact->pos[3] = REAL(0.0);
30 //Contact->normal = 0;
31 Contact->depth = 0.0f;
32 Contact->g1 = RayGeom;
33 Contact->g2 = PlaneGeom;
34 return 1;
35} \ No newline at end of file