void CWndStyleEditor::ProcEditRect(UINT uMessage, WPARAM wParam, LPARAM lParam) { float X = float( LOWORD(lParam) ) - m_StyleRender.m_fOffX; float Y = float( HIWORD(lParam) ) - m_StyleRender.m_fOffY; X = limit2(X,0.0f,float(m_StyleRender.m_Width)); Y = limit2(Y,0.0f,float(m_StyleRender.m_Height)); switch( uMessage ) { case WM_MOUSEMOVE: if(m_bIsButtonDown) { if(Y>m_MouseButtonY) { m_Rect.top = m_MouseButtonY; m_Rect.bottom = Y; } else { m_Rect.top = Y; m_Rect.bottom = m_MouseButtonY; } if(X>m_MouseButtonX) { m_Rect.left = m_MouseButtonX; m_Rect.right = X; } else { m_Rect.left = m_MouseButtonX; m_Rect.right = X; } if(m_pBlock) ((*m_pBlock)[m_BlockIndex]) = m_Rect; RefreshView(); } break; case WM_LBUTTONUP: m_bIsButtonDown = false; break; case WM_LBUTTONDOWN: m_bIsButtonDown = true; m_MouseButtonX = X; m_MouseButtonY = Y; break; default: break; } }
float CMedObjFollowState::GetRealMovedDist()const { uint64 uCurTime = m_pCoreObj->GetConnection()->GetConnTime(); const uint32 uElapsedTime = uint32(uCurTime - m_uThisPathExpiredTime); const float fRealDist = m_fBeginDist + sqr::CalMoveStep( m_fSpeed, uElapsedTime ); float fIdealMovedDist = limit2( fRealDist, GetMovedDist(), GetEndDist() ); float fMaxMovedDist = GetEndDist(); if(fIdealMovedDist > fMaxMovedDist) fIdealMovedDist = fMaxMovedDist; return fIdealMovedDist; }
Vector2 * Vector2::limit(float limit) { return limit2(limit*limit); }
void CGameGacCamera::SetCameraOffset( const float MouseDelta ) { float fCamOffset = m_fCamDist + MouseDelta * 5.0f; m_fCamDist = limit2( fCamOffset, m_pRTSCameraCtrller->GetMinDist(), m_pRTSCameraCtrller->GetMaxDist() ); m_pRTSCameraCtrller->SetDist(m_fCamDist); }