void Node::evaluateBounds() const { if (_boundsChanged) { ASSERT_MESSAGE(!_boundsMutex, "re-entering bounds evaluation"); _boundsMutex = true; _bounds = childBounds(); _bounds.includeAABB( AABB::createFromOrientedAABBSafe(localAABB(), localToWorld()) ); _boundsMutex = false; _boundsChanged = false; // Now that our bounds are re-calculated, notify the scenegraph GraphPtr sceneGraph = _sceneGraph.lock(); if (sceneGraph) { sceneGraph->nodeBoundsChanged(const_cast<Node*>(this)->shared_from_this()); } } }
void Node::evaluateBounds() const { if (_boundsChanged) { ASSERT_MESSAGE(!_boundsMutex, "re-entering bounds evaluation"); _boundsMutex = true; _bounds = childBounds(); _bounds.includeAABB( aabb_for_oriented_aabb_safe(localAABB(), localToWorld()) ); _boundsMutex = false; _boundsChanged = false; // Now that our bounds are re-calculated, notify the scenegraph GlobalSceneGraph().nodeBoundsChanged(const_cast<Node*>(this)->shared_from_this()); } }
void UiElement::updateLayout( const UiLayoutContext& context ) { if( !m_layoutChanged ) { return; } UiRectangle parentBounds; if( m_pParent ) { parentBounds = m_pParent->m_layoutRectangle; } else { parentBounds.left = 0.0f; parentBounds.top = 0.0f; parentBounds.bottom = m_height.value; parentBounds.right = m_width.value; } m_layoutRectangle = parentBounds; getElementLayoutSizeAndPosition( m_layoutRectangle.left, m_layoutRectangle.right, m_position.getLeft(), m_position.getRight(), m_width, parentBounds.left, parentBounds.right, 0.0f, m_margin.left, m_margin.right, m_padding.getWidth(), context ); getElementLayoutSizeAndPosition( m_layoutRectangle.top, m_layoutRectangle.bottom, m_position.getTop(), m_position.getBottom(), m_height, parentBounds.top, parentBounds.bottom, 0.0f, m_margin.top, m_margin.bottom, m_padding.getHeight(), context ); UiRectangle childBounds( f32::maxValue, f32::maxValue, -f32::maxValue, -f32::maxValue ); if( m_children.isEmpty() ) { childBounds.clear(); } for( UiElement& child : m_children ) { child.updateLayout( context ); childBounds.extend( child.m_layoutRectangle ); } getElementLayoutSizeAndPosition( m_layoutRectangle.left, m_layoutRectangle.right, m_position.getLeft(), m_position.getRight(), m_width, parentBounds.left, parentBounds.right, childBounds.getWidth(), m_margin.left, m_margin.right, m_padding.getWidth(), context ); getElementLayoutSizeAndPosition( m_layoutRectangle.top, m_layoutRectangle.bottom, m_position.getTop(), m_position.getBottom(), m_height, parentBounds.top, parentBounds.bottom, childBounds.getHeight(), m_margin.top, m_margin.bottom, m_padding.getHeight(), context ); m_layoutChanged = false; }