void PhyFixed::updateJoint(real timestep) { // If the joint is disabled, we don't do anything here if (!m_shared->enabled) { return; } // Updating the global matrices and the dof updateJointInfo(); #ifdef WORLDSIM_USE_NEWTON UNUSED_PARAM( timestep ); //--- Restrict the movement on the centre of the joint along all tree orthonormal direction NewtonUserJointAddLinearRow( m_priv->joint, &m_shared->globalMatrixChild.w_pos[0], &m_shared->globalMatrixParent.w_pos[0], &m_shared->globalMatrixParent.x_ax[0] ); NewtonUserJointSetRowStiffness( m_priv->joint, 1.0f ); NewtonUserJointAddLinearRow( m_priv->joint, &m_shared->globalMatrixChild.w_pos[0], &m_shared->globalMatrixParent.w_pos[0], &m_shared->globalMatrixParent.y_ax[0] ); NewtonUserJointSetRowStiffness( m_priv->joint, 1.0f ); NewtonUserJointAddLinearRow( m_priv->joint, &m_shared->globalMatrixChild.w_pos[0], &m_shared->globalMatrixParent.w_pos[0], &m_shared->globalMatrixParent.z_ax[0] ); NewtonUserJointSetRowStiffness( m_priv->joint, 1.0f ); //--- In order to constraint the rotation about X and Y axis of the joint //--- we use LinearRow (that are stronger) getting a point far from objects along //--- the Z axis. Doing this if the two object rotates about X or Y axes then //--- the difference between qChild and qParent augments and then Newton Engine will apply //--- a corresponding force (that applyied outside the centre of the object will become //--- a torque) that will blocks any rotation about X and Y axis real len = 5000.0; wVector qChild( m_shared->globalMatrixChild.w_pos + m_shared->globalMatrixChild.z_ax.scale(len) ); wVector qParent( m_shared->globalMatrixParent.w_pos + m_shared->globalMatrixParent.z_ax.scale(len) ); NewtonUserJointAddLinearRow( m_priv->joint, &qChild[0], &qParent[0], &m_shared->globalMatrixParent.x_ax[0] ); NewtonUserJointSetRowStiffness( m_priv->joint, 1.0 ); NewtonUserJointAddLinearRow( m_priv->joint, &qChild[0], &qParent[0], &m_shared->globalMatrixParent.y_ax[0] ); NewtonUserJointSetRowStiffness( m_priv->joint, 1.0 ); NewtonUserJointAddAngularRow( m_priv->joint, 0.0f, &m_shared->globalMatrixParent.z_ax[0] ); NewtonUserJointSetRowStiffness( m_priv->joint, 1.0f ); //--- In order to do the same with third axis (Z), I need others point along different axis /* qChild = wVector( m_shared->globalMatrixChild.w_pos + m_shared->globalMatrixChild.y_ax.scale(len) ); qParent = wVector( m_shared->globalMatrixParent.w_pos + m_shared->globalMatrixParent.y_ax.scale(len) ); NewtonUserJointAddLinearRow( m_priv->joint, &qChild[0], &qParent[0], &m_shared->globalMatrixParent.z_ax[0] ); NewtonUserJointSetRowStiffness( m_priv->joint, 1.0 );*/ //--- Retrive forces applied to the joint by the constraints Shared* const d = m_shared.getModifiableShared(); d->forceOnJoint.x = NewtonUserJointGetRowForce (m_priv->joint, 0); d->forceOnJoint.y = NewtonUserJointGetRowForce (m_priv->joint, 1); d->forceOnJoint.z = NewtonUserJointGetRowForce (m_priv->joint, 2); #endif }
void cUIMenu::FixMenuPos( eeVector2i& Pos, cUIMenu * Menu, cUIMenu * Parent, cUIMenuSubMenu * SubMenu ) { eeAABB qScreen( 0.f, 0.f, cUIManager::instance()->MainControl()->Size().Width(), cUIManager::instance()->MainControl()->Size().Height() ); eeAABB qPos( Pos.x, Pos.y, Pos.x + Menu->Size().Width(), Pos.y + Menu->Size().Height() ); if ( NULL != Parent && NULL != SubMenu ) { eeVector2i addToPos( 0, 0 ); if ( NULL != SubMenu ) { addToPos.y = SubMenu->Size().Height(); } eeVector2i sPos = SubMenu->Pos(); SubMenu->ControlToScreen( sPos ); eeVector2i pPos = Parent->Pos(); Parent->ControlToScreen( pPos ); eeAABB qParent( pPos.x, pPos.y, pPos.x + Parent->Size().Width(), pPos.y + Parent->Size().Height() ); Pos.x = qParent.Right; Pos.y = sPos.y; qPos.Left = Pos.x; qPos.Right = qPos.Left + Menu->Size().Width(); qPos.Top = Pos.y; qPos.Bottom = qPos.Top + Menu->Size().Height(); if ( !qScreen.Contains( qPos ) ) { Pos.y = sPos.y + SubMenu->Size().Height() - Menu->Size().Height(); qPos.Top = Pos.y; qPos.Bottom = qPos.Top + Menu->Size().Height(); if ( !qScreen.Contains( qPos ) ) { Pos.x = qParent.Left - Menu->Size().Width(); Pos.y = sPos.y; qPos.Left = Pos.x; qPos.Right = qPos.Left + Menu->Size().Width(); qPos.Top = Pos.y; qPos.Bottom = qPos.Top + Menu->Size().Height(); if ( !qScreen.Contains( qPos ) ) { Pos.y = sPos.y + SubMenu->Size().Height() - Menu->Size().Height(); qPos.Top = Pos.y; qPos.Bottom = qPos.Top + Menu->Size().Height(); } } } } else { if ( !qScreen.Contains( qPos ) ) { Pos.y -= Menu->Size().Height(); qPos.Top -= Menu->Size().Height(); qPos.Bottom -= Menu->Size().Height(); if ( !qScreen.Contains( qPos ) ) { Pos.x -= Menu->Size().Width(); qPos.Left -= Menu->Size().Width(); qPos.Right -= Menu->Size().Width(); if ( !qScreen.Contains( qPos ) ) { Pos.y += Menu->Size().Height(); qPos.Top += Menu->Size().Height(); qPos.Bottom += Menu->Size().Height(); } } } } }