@@ -356,6 +356,12 @@ class CPolylineBase
356
356
class CPolyline : public CPolylineBase
357
357
{
358
358
public:
359
+ CPolyline () :
360
+ m_Min (float64_t2(nbl::hlsl::numeric_limits<float64_t >::max, nbl::hlsl::numeric_limits<float64_t >::max)),
361
+ m_Max (float64_t2(nbl::hlsl::numeric_limits<float64_t >::min, nbl::hlsl::numeric_limits<float64_t >::min)),
362
+ m_closedPolygon (false )
363
+ {}
364
+
359
365
size_t getSectionsCount () const override { return m_sections.size (); }
360
366
361
367
const SectionInfo& getSectionInfoAt (const uint32_t idx) const override
@@ -423,6 +429,7 @@ class CPolyline : public CPolylineBase
423
429
m_linePoints[oldLinePointSize + i].p = linePoints[i];
424
430
m_linePoints[oldLinePointSize + i].phaseShift = 0.0 ;
425
431
m_linePoints[oldLinePointSize + i].stretchValue = 1.0 ;
432
+ addExtremum (linePoints[i]);
426
433
}
427
434
428
435
SectionInfo newSection = {};
@@ -463,6 +470,10 @@ class CPolyline : public CPolylineBase
463
470
m_quadBeziers[currBezierIdx].shape = quadBeziers[i];
464
471
m_quadBeziers[currBezierIdx].phaseShift = 0.0 ;
465
472
m_quadBeziers[currBezierIdx].stretchValue = 1.0 ;
473
+
474
+ addExtremum (quadBeziers[i].P0 );
475
+ addExtremum (quadBeziers[i].P1 ); // Currently We add the control point instead of actual extremum to avoid computing a quadratic formula for each bezier we add
476
+ addExtremum (quadBeziers[i].P2 );
466
477
}
467
478
468
479
const bool unifiedSection = (m_sections.size () > lastSectionsSize && m_sections.back ().type == ObjectType::QUAD_BEZIER);
@@ -1184,12 +1195,28 @@ class CPolyline : public CPolylineBase
1184
1195
m_closedPolygon = closed;
1185
1196
}
1186
1197
1198
+ float64_t2 getMin () const { return m_Min; }
1199
+ float64_t2 getMax () const { return m_Max; }
1200
+
1187
1201
protected:
1188
1202
std::vector<PolylineConnector> m_polylineConnector;
1189
1203
std::vector<SectionInfo> m_sections;
1190
1204
std::vector<LinePointInfo> m_linePoints;
1191
1205
std::vector<QuadraticBezierInfo> m_quadBeziers;
1192
1206
uint32_t lastSectionsSize = std::numeric_limits<uint32_t >::max();
1207
+ // important for miter and parallel generation
1208
+ bool m_closedPolygon = false ;
1209
+
1210
+ inline void addExtremum (const float64_t2& point)
1211
+ {
1212
+ m_Min.x = nbl::hlsl::min (m_Min.x , point.x );
1213
+ m_Min.y = nbl::hlsl::min (m_Min.y , point.y );
1214
+ m_Max.x = nbl::hlsl::max (m_Max.x , point.x );
1215
+ m_Max.y = nbl::hlsl::max (m_Max.y , point.y );
1216
+ }
1217
+
1218
+ float64_t2 m_Min; // min coordinate of the whole polyline
1219
+ float64_t2 m_Max; // max coordinate of the whole polyline
1193
1220
1194
1221
// Next 3 are protected member functions to modify current lines and bezier sections used in polyline offsetting:
1195
1222
@@ -1751,7 +1778,4 @@ class CPolyline : public CPolylineBase
1751
1778
nbl::core::vector<PolylineConnectorNormalHelperInfo> connectorNormalInfos;
1752
1779
float phaseShiftAtEndOfPolyline = 0 .0f ;
1753
1780
};
1754
-
1755
- // important for miter and parallel generation
1756
- bool m_closedPolygon = false ;
1757
1781
};
0 commit comments