summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-04-08 22:38:11 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-04-08 22:40:06 -0300
commit4286aef69313e048fa91710c35456c08a252fd3c (patch)
tree866ecba1e556f587aed886166afea79a47487248 /core/math
parent6075dfe511728ab3fb59915a18ca99e5b8789d8b (diff)
Particle system is complete. Rejoice!
Diffstat (limited to 'core/math')
-rw-r--r--core/math/geometry.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 2469e799a0..909d8164c3 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -105,23 +105,23 @@ public:
}
static void get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2, Vector3 &c1, Vector3 &c2) {
-#if 0
- //do the function 'd' as defined by pb. I think is is dot product of some sort
+#if 1
+//do the function 'd' as defined by pb. I think is is dot product of some sort
#define d_of(m, n, o, p) ((m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z))
//calculate the parametric position on the 2 curves, mua and mub
- real_t mua = ( d_of(p1,q1,q2,q1) * d_of(q2,q1,p2,p1) - d_of(p1,q1,p2,p1) * d_of(q2,q1,q2,q1) ) / ( d_of(p2,p1,p2,p1) * d_of(q2,q1,q2,q1) - d_of(q2,q1,p2,p1) * d_of(q2,q1,p2,p1) );
- real_t mub = ( d_of(p1,q1,q2,q1) + mua * d_of(q2,q1,p2,p1) ) / d_of(q2,q1,q2,q1);
+ real_t mua = (d_of(p1, q1, q2, q1) * d_of(q2, q1, p2, p1) - d_of(p1, q1, p2, p1) * d_of(q2, q1, q2, q1)) / (d_of(p2, p1, p2, p1) * d_of(q2, q1, q2, q1) - d_of(q2, q1, p2, p1) * d_of(q2, q1, p2, p1));
+ real_t mub = (d_of(p1, q1, q2, q1) + mua * d_of(q2, q1, p2, p1)) / d_of(q2, q1, q2, q1);
//clip the value between [0..1] constraining the solution to lie on the original curves
if (mua < 0) mua = 0;
if (mub < 0) mub = 0;
if (mua > 1) mua = 1;
if (mub > 1) mub = 1;
- c1 = p1.linear_interpolate(p2,mua);
- c2 = q1.linear_interpolate(q2,mub);
-#endif
-
+ c1 = p1.linear_interpolate(p2, mua);
+ c2 = q1.linear_interpolate(q2, mub);
+#else
+ //this is broken do not use
Vector3 u = p2 - p1;
Vector3 v = q2 - q1;
Vector3 w = p1 - q1;
@@ -144,8 +144,9 @@ public:
c1 = w + sc * u;
c2 = w + tc * v;
- // get the difference of the two closest points
- //Vector dP = w + (sc * u) - (tc * v); // = L1(sc) - L2(tc)
+// get the difference of the two closest points
+//Vector dP = w + (sc * u) - (tc * v); // = L1(sc) - L2(tc)
+#endif
}
static real_t get_closest_distance_between_segments(const Vector3 &p_from_a, const Vector3 &p_to_a, const Vector3 &p_from_b, const Vector3 &p_to_b) {