Fix stupidity in the rotate ops; first of all it was saving the

axis of rotation numerically, so that the associative thing breaks,
and then it also wasn't saving the point on the axis in the file,
so that snapped back to (0, 0, 0) on reload. Now it goes off the
hEntity for a point on the axis and a vector in its direction.

[git-p4: depot-paths = "//depot/solvespace/": change = 1790]
This commit is contained in:
Jonathan Westhues 2008-06-12 21:32:55 -08:00
parent b284baffce
commit 1674443ab2
2 changed files with 13 additions and 14 deletions

View File

@ -101,21 +101,18 @@ void Group::MenuGroup(int id) {
break; break;
case GraphicsWindow::MNU_GROUP_ROT: { case GraphicsWindow::MNU_GROUP_ROT: {
Vector n;
if(gs.points == 1 && gs.n == 1 && SS.GW.LockedInWorkplane()) { if(gs.points == 1 && gs.n == 1 && SS.GW.LockedInWorkplane()) {
g.predef.p = (SS.GetEntity(gs.point[0]))->PointGetNum(); g.predef.origin = gs.point[0];
Entity *w = SS.GetEntity(SS.GW.ActiveWorkplane()); Entity *w = SS.GetEntity(SS.GW.ActiveWorkplane());
n = (w->Normal()->NormalN()); g.predef.entityB = w->Normal()->h;
g.activeWorkplane = w->h; g.activeWorkplane = w->h;
} else if(gs.points == 1 && gs.vectors == 1 && gs.n == 2) { } else if(gs.points == 1 && gs.vectors == 1 && gs.n == 2) {
g.predef.p = (SS.GetEntity(gs.point[0]))->PointGetNum(); g.predef.origin = gs.point[0];
n = SS.GetEntity(gs.vector[0])->VectorGetNum(); g.predef.entityB = gs.vector[0];
} else { } else {
Error("Bad selection for new rotation."); Error("Bad selection for new rotation.");
return; return;
} }
n = n.WithMagnitude(1);
g.predef.q = Quaternion::From(0, n.x, n.y, n.z);
g.type = ROTATE; g.type = ROTATE;
g.opA = SS.GW.activeGroup; g.opA = SS.GW.activeGroup;
g.exprA = Expr::From(3)->DeepCopyKeep(); g.exprA = Expr::From(3)->DeepCopyKeep();
@ -395,13 +392,16 @@ void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
// The axis and center of rotation are specified numerically // The axis and center of rotation are specified numerically
#define EC(x) (Expr::From(x)) #define EC(x) (Expr::From(x))
#define EP(x) (Expr::From(h.param(x))) #define EP(x) (Expr::From(h.param(x)))
AddEq(l, (EC(predef.p.x))->Minus(EP(0)), 0); ExprVector orig = SS.GetEntity(predef.origin)->PointGetExprs();
AddEq(l, (EC(predef.p.y))->Minus(EP(1)), 1); AddEq(l, (orig.x)->Minus(EP(0)), 0);
AddEq(l, (EC(predef.p.z))->Minus(EP(2)), 2); AddEq(l, (orig.y)->Minus(EP(1)), 1);
AddEq(l, (orig.z)->Minus(EP(2)), 2);
// param 3 is the angle, which is free // param 3 is the angle, which is free
AddEq(l, (EC(predef.q.vx))->Minus(EP(4)), 3); Vector axis = SS.GetEntity(predef.entityB)->VectorGetNum();
AddEq(l, (EC(predef.q.vy))->Minus(EP(5)), 4); axis = axis.WithMagnitude(1);
AddEq(l, (EC(predef.q.vz))->Minus(EP(6)), 5); AddEq(l, (EC(axis.x))->Minus(EP(4)), 3);
AddEq(l, (EC(axis.y))->Minus(EP(5)), 4);
AddEq(l, (EC(axis.z))->Minus(EP(6)), 5);
} else if(type == EXTRUDE) { } else if(type == EXTRUDE) {
if(predef.entityB.v != Entity::FREE_IN_3D.v) { if(predef.entityB.v != Entity::FREE_IN_3D.v) {
// The extrusion path is locked along a line, normal to the // The extrusion path is locked along a line, normal to the

View File

@ -112,7 +112,6 @@ public:
struct { struct {
Quaternion q; Quaternion q;
Vector p;
hEntity origin; hEntity origin;
hEntity entityB; hEntity entityB;
hEntity entityC; hEntity entityC;