MCPcopy Create free account
hub / github.com/axmolengine/axmol / getCascadeBoundingBox

Function getCascadeBoundingBox

core/base/Utils.cpp:262–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262Rect getCascadeBoundingBox(Node* node)
263{
264 Rect cbb;
265 Vec2 contentSize = node->getContentSize();
266
267 // check all children bounding box, get maximize box
268 Node* child = nullptr;
269 bool merge = false;
270 for (auto&& object : node->getChildren())
271 {
272 child = dynamic_cast<Node*>(object);
273 if (!child->isVisible())
274 continue;
275
276 const Rect box = getCascadeBoundingBox(child);
277 if (box.size.width <= 0 || box.size.height <= 0)
278 continue;
279
280 if (!merge)
281 {
282 cbb = box;
283 merge = true;
284 }
285 else
286 {
287 cbb.merge(box);
288 }
289 }
290
291 // merge content size
292 if (contentSize.width > 0 && contentSize.height > 0)
293 {
294 const Rect box = RectApplyAffineTransform(Rect(0, 0, contentSize.width, contentSize.height),
295 node->getNodeToWorldAffineTransform());
296 if (!merge)
297 {
298 cbb = box;
299 }
300 else
301 {
302 cbb.merge(box);
303 }
304 }
305
306 return cbb;
307}
308
309Sprite* createSpriteFromBase64Cached(const char* base64String, const char* key)
310{

Calls 6

RectApplyAffineTransformFunction · 0.85
RectFunction · 0.50
getContentSizeMethod · 0.45
isVisibleMethod · 0.45
mergeMethod · 0.45

Tested by

no test coverage detected