Prechádzať zdrojové kódy

parametrics: fix RopeNode breaks due to float imprecision

Fixes #1325
rdb 1 rok pred
rodič
commit
16431748de
1 zmenil súbory, kde vykonal 9 pridanie a 1 odobranie
  1. 9 1
      panda/src/parametrics/ropeNode.cxx

+ 9 - 1
panda/src/parametrics/ropeNode.cxx

@@ -526,8 +526,16 @@ get_connected_segments(RopeNode::CurveSegments &curve_segments,
     LPoint3 point;
     result->eval_segment_point(segment, 0.0f, point);
 
+    // We need a bit more relaxed threshold to prevent breaks between
+    // segments, see GitHub issue #1325.
+#ifdef STDFLOAT_DOUBLE
+    static const double threshold = 1.0e-8;
+#else
+    static const float threshold = 1.0e-4f;
+#endif
+
     if (curve_segment == nullptr ||
-        !point.almost_equal(last_point)) {
+        !point.almost_equal(last_point, threshold)) {
       // If the first point of this segment is different from the last point
       // of the previous segment, end the previous segment and begin a new
       // one.