--- a/src/ldtypes.cpp Sat Jun 01 20:31:33 2013 +0300 +++ b/src/ldtypes.cpp Sat Jun 01 21:36:03 2013 +0300 @@ -78,8 +78,8 @@ } str LDSubfile::getContents () { - str val = fmt ("1 %d %s ", color (), pos.stringRep (false).chars ()); - val += transform.stringRep (); + str val = fmt ("1 %d %s ", color (), position ().stringRep (false).chars ()); + val += transform ().stringRep (); val += ' '; val += fileName; return val; @@ -238,10 +238,12 @@ case LDObject::Subfile: { LDSubfile* ref = static_cast<LDSubfile*> (obj); + matrix newMatrix = transform * ref->transform (); + vertex newpos = ref->position (); - matrix newMatrix = transform * ref->transform; - ref->pos.transform (transform, pos); - ref->transform = newMatrix; + newpos.transform (transform, pos); + ref->setPosition (newpos); + ref->setTransform (newMatrix); } break; @@ -319,7 +321,7 @@ // Set the parent now so we know what inlined this. obj->setParent (this); - transformObject (obj, transform, pos, color ()); + transformObject (obj, transform (), position (), color ()); } return objs; @@ -461,11 +463,11 @@ } void LDSubfile::move (vertex vect) { - pos += vect; + setPosition (position () + vect); } void LDRadial::move (vertex vect) { - pos += vect; + setPosition (position () + vect); } void LDLine::move (vertex vect) { @@ -521,24 +523,21 @@ z0 = sin ((i * 2 * pi) / divisions ()), z1 = sin (((i + 1) * 2 * pi) / divisions ()); + LDObject* obj = null; + switch (type ()) { case LDRadial::Circle: { vertex v0 (x0, 0.0f, z0), v1 (x1, 0.0f, z1); - if (applyTransform) { - v0.transform (transform, pos); - v1.transform (transform, pos); - } - LDLine* line = new LDLine; line->coords[0] = v0; line->coords[1] = v1; line->setColor (edgecolor); line->setParent (this); - objs << line; + obj = line; } break; @@ -581,22 +580,16 @@ v2 (x2, y2, z2), v3 (x3, y3, z3); - if (applyTransform) { - v0.transform (transform, pos); - v1.transform (transform, pos); - v2.transform (transform, pos); - v3.transform (transform, pos); - } - LDQuad* quad = new LDQuad; quad->coords[0] = v0; quad->coords[1] = v1; quad->coords[2] = v2; quad->coords[3] = v3; + quad->setColor (color ()); quad->setParent (this); - objs << quad; + obj = quad; } break; @@ -616,12 +609,6 @@ v1 (x1, 0.0f, z1), v2 (x2, 0.0f, z2); - if (applyTransform) { - v0.transform (transform, pos); - v1.transform (transform, pos); - v2.transform (transform, pos); - } - LDTriangle* seg = new LDTriangle; seg->coords[0] = v0; seg->coords[1] = v1; @@ -629,13 +616,25 @@ seg->setColor (color ()); seg->setParent (this); - objs << seg; + if (applyTransform) + for (int i = 0; i < 3; ++i) + seg->coords[i].transform (transform (), position ()); + + obj = seg; } break; default: break; } + + if (obj) { + if (applyTransform) + for (int i = 0; i < obj->vertices (); ++i) + obj->coords[i].transform (transform (), position ()); + + objs << obj; + } } return objs; @@ -648,7 +647,7 @@ return fmt ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", str (radialTypeName ()).upper ().strip (' ').c (), color (), segments (), divisions (), number (), - pos.stringRep (false).chars(), transform.stringRep().chars()); + position ().stringRep (false).chars (), transform ().stringRep().chars ()); } char const* g_radialNameRoots[] = {