//--------------------------------------------------------------------- void OverlayElement::_update(void) { // Check size if pixel-based switch (mMetricsMode) { case GMM_PIXELS : if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate) { Real vpWidth, vpHeight; OverlayManager& oMgr = OverlayManager::getSingleton(); vpWidth = (Real) (oMgr.getViewportWidth()); vpHeight = (Real) (oMgr.getViewportHeight()); mPixelScaleX = 1.0f / vpWidth; mPixelScaleY = 1.0f / vpHeight; mLeft = mPixelLeft * mPixelScaleX; mTop = mPixelTop * mPixelScaleY; mWidth = mPixelWidth * mPixelScaleX; mHeight = mPixelHeight * mPixelScaleY; } break; case GMM_RELATIVE_ASPECT_ADJUSTED : if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate) { Real vpWidth, vpHeight; OverlayManager& oMgr = OverlayManager::getSingleton(); vpWidth = (Real) (oMgr.getViewportWidth()); vpHeight = (Real) (oMgr.getViewportHeight()); mPixelScaleX = 1.0f / (10000.0f * (vpWidth / vpHeight)); mPixelScaleY = 1.0f / 10000.0f; mLeft = mPixelLeft * mPixelScaleX; mTop = mPixelTop * mPixelScaleY; mWidth = mPixelWidth * mPixelScaleX; mHeight = mPixelHeight * mPixelScaleY; } break; default: break; } _updateFromParent(); // NB container subclasses will update children too // Tell self to update own position geometry if (mGeomPositionsOutOfDate && mInitialised) { updatePositionGeometry(); mGeomPositionsOutOfDate = false; } // Tell self to update own texture geometry if (mGeomUVsOutOfDate && mInitialised) { updateTextureGeometry(); mGeomUVsOutOfDate = false; } }
//----------------------------------------------------------------------- Vector3 Node::convertWorldToLocalPosition( const Vector3 &worldPos ) { if (mNeedParentUpdate) { _updateFromParent(); } return mDerivedOrientation.Inverse() * (worldPos - mDerivedPosition) / mDerivedScale; }
//----------------------------------------------------------------------- const Vector3 & Node::_getDerivedScale(void) const { if (mNeedParentUpdate) { _updateFromParent(); } return mDerivedScale; }
//----------------------------------------------------------------------- Quaternion Node::convertWorldToLocalOrientation( const Quaternion &worldOrientation ) { if (mNeedParentUpdate) { _updateFromParent(); } return mDerivedOrientation.Inverse() * worldOrientation; }
//--------------------------------------------------------------------- void OverlayElement::_getClippingRegion(Rectangle &clippingRegion) { if (mDerivedOutOfDate) { _updateFromParent(); } clippingRegion = mClippingRegion; }
// Transform to Vector Helpers const Vector3 & Transform::Forward() { if (cachedTransformOutOfDate) { _updateFromParent(); } return forward; };
//----------------------------------------------------------------------- const Vector3 & Transform::_getDerivedScale(void) { if (needParentUpdate) { _updateFromParent(); } return derivedScale; }
//----------------------------------------------------------------------- const Quaternion & Node::_getDerivedOrientation(void) const { if (mNeedParentUpdate) { _updateFromParent(); } return mDerivedOrientation; }
//----------------------------------------------------------------------- const Quaternion & Transform::_getDerivedOrientation(void) { if (needParentUpdate) { _updateFromParent(); } return derivedOrientation; }
const Vector3 & Transform::Right() { if (cachedTransformOutOfDate) { _updateFromParent(); } return right; };
const Vector3 & Transform::Up() { if (cachedTransformOutOfDate) { _updateFromParent(); } return up; };
//--------------------------------------------------------------------- Real OverlayElement::_getDerivedTop(void) { if (mDerivedOutOfDate) { _updateFromParent(); } return mDerivedTop; }
//----------------------------------------------------------------------- Vector3 Node::convertLocalToWorldPosition( const Vector3 &localPos ) { if (mNeedParentUpdate) { _updateFromParent(); } return (mDerivedOrientation * localPos * mDerivedScale) + mDerivedPosition; }
//----------------------------------------------------------------------- Quaternion Node::convertLocalToWorldOrientation( const Quaternion &localOrientation ) { if (mNeedParentUpdate) { _updateFromParent(); } return mDerivedOrientation * localOrientation; }
void sgNode::update( Float32 deltaTime ) { if(m_bNeedUpdateFromParent) _updateFromParent(); // update children ChildNodeMap::iterator it = m_Children.begin(); ChildNodeMap::iterator eit = m_Children.end(); for(; it!=eit; ++it) { it->second->update(deltaTime); } }
//----------------------------------------------------------------------- void Node::_update(bool updateChildren, bool parentHasChanged) { // always clear information about parent notification mParentNotified = false ; // Short circuit the off case if (!updateChildren && !mNeedParentUpdate && !mNeedChildUpdate && !parentHasChanged ) { return; } // See if we should process everyone if (mNeedParentUpdate || parentHasChanged) { // Update transforms from parent _updateFromParent(); } if (mNeedChildUpdate || parentHasChanged) { ChildNodeMap::iterator it, itend; itend = mChildren.end(); for (it = mChildren.begin(); it != itend; ++it) { Node* child = it->second; child->_update(true, true); } mChildrenToUpdate.clear(); } else { // Just update selected children ChildUpdateSet::iterator it, itend; itend = mChildrenToUpdate.end(); for(it = mChildrenToUpdate.begin(); it != itend; ++it) { Node* child = *it; child->_update(true, false); } mChildrenToUpdate.clear(); } mNeedChildUpdate = false; }
void Transform::_update(bool updateChildren, bool parentHasChanged) { if (IsEnabled()) { // always clear information about parent notification parentNotified = false; // See if we should process everyone if (needParentUpdate || parentHasChanged) { // Update transforms from parent _updateFromParent(); } /* if (childrenToUpdate.size() > 0) { for_each(childrenToUpdate.begin(), childrenToUpdate.end(), [](Transform::Ptr child){ child->_update(true, false); }); childrenToUpdate.clear(); } */ //if (updateChildren) //{ if (needChildUpdate || parentHasChanged) { for_each(children.begin(), children.end(), [](Transform::Ptr child){ child->_update(true, true); }); } else { for_each(childrenToUpdate.begin(), childrenToUpdate.end(), [](Transform::Ptr child){ child->_update(true, false); }); } childrenToUpdate.clear(); needChildUpdate = false; // Now that the children have been updated, update the this transforms bounds UpdateBounds(); //} } }
// [7/30/2008 zhangxiang] const Quaternion &sgNode::_getDerivedOrientation(void) const{ if(m_bNeedUpdateFromParent){ _updateFromParent(); } return m_DerivedOrientation; }
// [7/30/2008 zhangxiang] const Vector3 &sgNode::_getDerivedPosition(void) const{ if(m_bNeedUpdateFromParent){ _updateFromParent(); } return m_DerivedPosition; }
// [7/30/2008 zhangxiang] const Vector3 &sgNode::_getDerivedScale(void) const{ if(m_bNeedUpdateFromParent){ _updateFromParent(); } return m_DerivedScale; }