146 LDColor m_color; |
146 LDColor m_color; |
147 QColor m_randomColor; |
147 QColor m_randomColor; |
148 Vertex m_coords[4]; |
148 Vertex m_coords[4]; |
149 }; |
149 }; |
150 |
150 |
151 template<typename T, typename... Args> |
|
152 T* LDSpawn (Args... args) |
|
153 { |
|
154 static_assert (std::is_base_of<LDObject, T>::value, |
|
155 "spawn may only be used with LDObject-derivatives"); |
|
156 T* result = new T (args..., nullptr); |
|
157 |
|
158 // Set default color. Relying on virtual functions, this cannot be done in the c-tor. |
|
159 // TODO: store -1 as the default color |
|
160 if (result->isColored()) |
|
161 result->setColor (result->defaultColor()); |
|
162 |
|
163 return result; |
|
164 } |
|
165 |
|
166 // |
|
167 // |
151 // |
168 // Common code for objects with matrices. This class is multiple-derived in |
152 // Common code for objects with matrices. This class is multiple-derived in |
169 // and thus not used directly other than as a common storage point for matrices |
153 // and thus not used directly other than as a common storage point for matrices |
170 // and vertices. |
154 // and vertices. |
171 // |
155 // |