Skip to content

Commit

Permalink
Fixes to bounds construction
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraq committed Jun 21, 2024
1 parent fe5fcbe commit b5b5988
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,30 @@ class Node<T extends Node> implements SceneEvents, Scriptable<T>, Visitable {
*/
T addChild(Node child, int index = -1) {

// Put child node in place
if (index != -1) {
children.add(index, child)
}
else {
children.add(child)
}
child.parent = this

// Allow it to process
var scene = getScene()
if (scene) {
addNodeAndChildren(scene, child).join()
}
bounds.expand(child.bounds)

var childPosition = child.position
var childBounds = new Rectanglef(child.bounds).translate(childPosition.x, childPosition.y)
if (bounds.lengthX() && bounds.lengthY()) {
bounds.expand(childBounds)
}
else {
bounds.set(childBounds)
}

return this
}

Expand Down

0 comments on commit b5b5988

Please sign in to comment.