diff -r 95fde37e1f00 -r 778eed342ee4 src/gui_editactions.cpp --- a/src/gui_editactions.cpp Sat Jun 01 20:31:33 2013 +0300 +++ b/src/gui_editactions.cpp Sat Jun 01 21:36:03 2013 +0300 @@ -171,8 +171,8 @@ // Create the replacement primitive. LDSubfile* prim = new LDSubfile; - memcpy (&prim->pos, &rad->pos, sizeof rad->pos); // inherit position - memcpy (&prim->transform, &rad->transform, sizeof rad->transform); // inherit matrix + prim->setPosition (rad->position ()); // inherit position + prim->setTransform (rad->transform ()); // inherit matrix prim->setColor (rad->color ()); // inherit color prim->fileName = name; prim->fileInfo = file; @@ -435,8 +435,8 @@ // ============================================================================= static void doRotate (const short l, const short m, const short n) { vector sel = g_win->sel (); - vertex origin; vector queue; + const vertex rotpoint = rotPoint (sel); const double angle = (pi * currentGrid ().confs[Grid::Angle]->value) / 180; // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2 @@ -457,28 +457,27 @@ (n * n * (1 - cosangle)) + cosangle }); - origin = rotPoint (sel); - - // Apply the above matrix to everything + // Apply the above matrix to everything - first, mark down + // which vertices to transform for (LDObject* obj : sel) { if (obj->vertices ()) for (short i = 0; i < obj->vertices (); ++i) queue << &obj->coords[i]; else if (obj->hasMatrix ()) { - LDMatrixObject* mobj = static_cast (obj); - - queue << &mobj->pos; - mobj->transform = mobj->transform * transform; + LDMatrixObject* mo = static_cast (obj); + queue << const_cast (&mo->position ()); // TEMPORARY HACK + mo->setTransform (mo->transform () * transform); } else if (obj->getType () == LDObject::Vertex) queue << &static_cast (obj)->pos; g_win->R ()->compileObject (obj); } + // Now do the actual transformations for (vertex* v : queue) { - v->move (-origin); + v->move (-rotpoint); v->transform (transform, g_origin); - v->move (origin); + v->move (rotpoint); } g_win->refresh ();