From 05b50e0af8cabb2808d2b8c45b88854780f2ae46 Mon Sep 17 00:00:00 2001 From: Jonathan Westhues Date: Sun, 25 May 2008 06:36:03 -0800 Subject: [PATCH] Various tweaks, including a numerical improvement, to make the epsilon in the csg stuff meaningfully apply everywhere to the length. [git-p4: depot-paths = "//depot/solvespace/": change = 1742] --- drawconstraint.cpp | 2 +- entity.cpp | 2 +- mesh.cpp | 6 +++--- sketch.cpp | 1 + util.cpp | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drawconstraint.cpp b/drawconstraint.cpp index 9881e47d..62ab02ca 100644 --- a/drawconstraint.cpp +++ b/drawconstraint.cpp @@ -83,7 +83,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) { Vector gu = SS.GW.projUp.ScaledBy(1/SS.GW.scale); Vector gn = (gr.Cross(gu)).WithMagnitude(1/SS.GW.scale); - glxColor3d(1, 0.4, 1); + glxColor3d(1, 0.1, 1); switch(type) { case PT_PT_DISTANCE: { Vector ap = SS.GetEntity(ptA)->PointGetNum(); diff --git a/entity.cpp b/entity.cpp index 8f7c5d70..e8c3f0e3 100644 --- a/entity.cpp +++ b/entity.cpp @@ -746,7 +746,7 @@ void Entity::DrawOrGetDistance(int order) { break; } -#define CIRCLE_SIDES(r) (7 + (int)(10*((sqrt(r))*SS.GW.scale)/20)) +#define CIRCLE_SIDES(r) (7 + (int)(sqrt(r*SS.GW.scale))) case ARC_OF_CIRCLE: { if(order >= 0 && order != 1) break; Vector c = SS.GetEntity(point[0])->PointGetNum(); diff --git a/mesh.cpp b/mesh.cpp index ea255498..008d3744 100644 --- a/mesh.cpp +++ b/mesh.cpp @@ -320,7 +320,7 @@ SBsp3 *SBsp3::Insert(STriangle *tr, SMesh *instead) { if(!this) { // Brand new node; so allocate for it, and fill us in. SBsp3 *r = Alloc(); - r->n = tr->Normal(); + r->n = (tr->Normal()).WithMagnitude(1); r->d = (tr->a).Dot(r->n); r->tri = *tr; return r; @@ -501,7 +501,7 @@ SBsp2 *SBsp2::InsertEdge(SEdge *nedge, Vector nnp, Vector out) { // Brand new node; so allocate for it, and fill us in. SBsp2 *r = Alloc(); r->np = nnp; - r->no = (r->np).Cross((nedge->b).Minus(nedge->a)); + r->no = ((r->np).Cross((nedge->b).Minus(nedge->a))).WithMagnitude(1); if(out.Dot(r->no) < 0) { r->no = (r->no).ScaledBy(-1); } @@ -536,7 +536,7 @@ SBsp2 *SBsp2::InsertEdge(SEdge *nedge, Vector nnp, Vector out) { SBsp2 *m = Alloc(); m->np = nnp; - m->no = (m->np).Cross((nedge->b).Minus(nedge->a)); + m->no = ((m->np).Cross((nedge->b).Minus(nedge->a))).WithMagnitude(1); if(out.Dot(m->no) < 0) { m->no = (m->no).ScaledBy(-1); } diff --git a/sketch.cpp b/sketch.cpp index 30770d67..353c5e00 100644 --- a/sketch.cpp +++ b/sketch.cpp @@ -296,6 +296,7 @@ void Group::CopyEntity(hEntity in, int a, hParam dx, hParam dy, hParam dz, en.type = ep->type; en.h = Remap(ep->h, a); en.group = h; + en.construction = ep->construction; switch(ep->type) { case Entity::WORKPLANE: diff --git a/util.cpp b/util.cpp index cb166100..1cc87bc2 100644 --- a/util.cpp +++ b/util.cpp @@ -299,7 +299,7 @@ Vector Vector::ScaledBy(double v) { Vector Vector::WithMagnitude(double v) { double m = Magnitude(); - if(m < 0.001) { + if(m < LENGTH_EPS) { return MakeFrom(v, 0, 0); } else { return ScaledBy(v/Magnitude());