86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
static bool
intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to)
{
OFVector3D v = *to, w = d.origin;
const OFVector3D *p;
v = OFSubtractVectors3D(v, *from);
w = OFSubtractVectors3D(w, *from);
float c1 = dotprod(w, v);
if (c1 <= 0)
p = from;
else {
float c2 = dotprod(v, v);
if (c2 <= c1)
p = to;
else {
v = OFMultiplyVector3D(v, c1 / c2);
v = OFAddVectors3D(v, *from);
p = &v;
}
|
|
|
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
static bool
intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to)
{
OFVector3D v = *to, w = d.origin;
const OFVector3D *p;
v = OFSubtractVectors3D(v, *from);
w = OFSubtractVectors3D(w, *from);
float c1 = OFDotProductOfVectors3D(w, v);
if (c1 <= 0)
p = from;
else {
float c2 = OFDotProductOfVectors3D(v, v);
if (c2 <= c1)
p = to;
else {
v = OFMultiplyVector3D(v, c1 / c2);
v = OFAddVectors3D(v, *from);
p = &v;
}
|