Gui: Fix empty sketch plane rendering
This commit is contained in:
@@ -119,6 +119,7 @@ public:
|
||||
inline BoundBox2d(double fX1, double fY1, double fX2, double fY2);
|
||||
~BoundBox2d() = default;
|
||||
inline bool IsValid() const;
|
||||
inline bool IsInfinite() const;
|
||||
inline bool IsEqual(const BoundBox2d& bbox, double tolerance) const;
|
||||
|
||||
// operators
|
||||
@@ -477,6 +478,11 @@ inline bool BoundBox2d::IsValid() const
|
||||
return (MaxX >= MinX) && (MaxY >= MinY);
|
||||
}
|
||||
|
||||
inline bool BoundBox2d::IsInfinite() const
|
||||
{
|
||||
return MaxX >= DOUBLE_MAX && MaxY >= DOUBLE_MAX && MinX <= -DOUBLE_MAX && MinY <= -DOUBLE_MAX;
|
||||
}
|
||||
|
||||
inline bool BoundBox2d::IsEqual(const BoundBox2d& bbox, double tolerance) const
|
||||
{
|
||||
return Vector2d(MinX, MinY).IsEqual(Vector2d(bbox.MinX, bbox.MinY), tolerance)
|
||||
|
||||
@@ -396,6 +396,12 @@ void ViewProvider2DObject::updatePlane()
|
||||
Base::ViewOrthoProjMatrix proj(place.inverse().toMatrix());
|
||||
Base::BoundBox2d bb = bbox.ProjectBox(&proj);
|
||||
|
||||
// when projection of invalid it often results in infinite shapes
|
||||
// if that happens we simply use some small bounding box to mark plane
|
||||
if (bb.IsInfinite() || !bb.IsValid()) {
|
||||
bb = Base::BoundBox2d(-1, -1, 1, 1);
|
||||
}
|
||||
|
||||
SbVec3f verts[4] = {
|
||||
SbVec3f(bb.MinX - horizontalPlanePadding, bb.MinY - verticalPlanePadding, 0),
|
||||
SbVec3f(bb.MinX - horizontalPlanePadding, bb.MaxY + verticalPlanePadding, 0),
|
||||
|
||||
@@ -42,7 +42,7 @@ class PartGuiExport ViewProvider2DObject : public PartGui::ViewProviderPart
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(PartGui::ViewProvider2DObject);
|
||||
|
||||
static constexpr float horizontalPlanePadding = 8;
|
||||
static constexpr float verticalPlanePadding = 5;
|
||||
static constexpr float verticalPlanePadding = 6;
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
|
||||
Reference in New Issue
Block a user