diff -r b0a345196435 -r 6e29bb0e83c5 ldtypes.cpp --- a/ldtypes.cpp Sat Apr 13 02:11:54 2013 +0300 +++ b/ldtypes.cpp Sun Apr 14 03:54:40 2013 +0300 @@ -1,6 +1,6 @@ /* * LDForge: LDraw parts authoring CAD - * Copyright (C) 2013 Santeri `arezey` Piippo + * Copyright (C) 2013 Santeri Piippo * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -59,7 +59,8 @@ } void LDObject::commonInit () { - qObjListEntry = nullptr; + qObjListEntry = null; + parent = null; } LDGibberish::LDGibberish () { @@ -379,8 +380,12 @@ } // Transform the objects - for (LDObject* obj : objs) + for (LDObject* obj : objs) { + // Set the parent now so we know what inlined this. + obj->parent = this; + transformObject (obj, mMatrix, vPosition, dColor); + } return objs; } @@ -462,6 +467,20 @@ } // ============================================================================= +LDSubfile* LDObject::topLevelParent () { + if (!parent) + return null; + + LDObject* it = this; + + while (it->parent) + it = it->parent; + + return static_cast (it); +} + + +// ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void LDObject::move (vertex vVector) { vVector = vVector; /* to shut up GCC */ }