void CChildView::OnRButtonUp(UINT nFlags, CPoint point) { switch (_LMBState) { case ELMBState::AddCircleObstacle: case ELMBState::AddOBBObstacle: RemoveObstacle(point); break; case ELMBState::IntersectSegment: { _intersectsegment.ChangeDestination(Vector2Df(point)); CheckIntersect(); Invalidate(); break; } } __super::OnRButtonUp(nFlags, point); }
bool CManipRot::UIEventHandler( const ui::Event& EV ) { int ex = EV.miX; int ey = EV.miY; CVector2 posubp = EV.GetUnitCoordBP(); CCamera *pcam = mManager.GetActiveCamera(); bool brval = false; bool isshift = false; //CSystem::IsKeyDepressed(VK_SHIFT ); bool isctrl = false; //CSystem::IsKeyDepressed(VK_CONTROL ); switch( EV.miEventCode ) { case ui::UIEV_PUSH: { mManager.mManipHandler.Init(posubp, pcam->mCameraData.GetIVPMatrix(), pcam->QuatC ); mBaseTransform = mManager.mCurTransform; SelectBestPlane(posubp); brval = true; } break; case ui::UIEV_RELEASE: { mManager.DisableManip(); brval = true; } break; case ui::UIEV_DRAG: { IntersectWithPlanes( posubp ); if ( CheckIntersect() ) { /////////////////////////////////////////// // calc normalvectors from base:origin to point on activeintersection plane (in world space) const CVector3 & Origin = mBaseTransform.GetTransform().GetPosition(); CVector3 D1 = (Origin-mActiveIntersection->mIntersectionPoint).Normal(); CVector3 D0 = (Origin-mActiveIntersection->mBaseIntersectionPoint).Normal(); /////////////////////////////////////////// // calc matrix to put worldspace vector into plane local space CMatrix4 MatWldToObj = mBaseTransform.GetTransform().GetMatrix(); //GetRotation(); MatWldToObj.Inverse(); CVector4 bAxisAngle = mLocalRotationAxis; CQuaternion brq; brq.FromAxisAngle(bAxisAngle); CMatrix4 MatObjToPln = brq.ToMatrix(); MatObjToPln.Inverse(); CMatrix4 MatWldToPln = MatObjToPln*MatWldToObj; //CMatrix4 MatInvRot = InvQuat.ToMatrix(); /////////////////////////////////////////// // calc plane local rotation CVector4 AxisAngle = mLocalRotationAxis; CVector4 D0I = CVector4(D0,CReal(0.0f)).Transform(MatWldToPln); CVector4 D1I = CVector4(D1,CReal(0.0f)).Transform(MatWldToPln); //orkprintf( "D0 <%f %f %f>\n", float(D0.GetX()), float(D0.GetY()), float(D0.GetZ()) ); //orkprintf( "D1 <%f %f %f>\n", float(D1.GetX()), float(D1.GetY()), float(D1.GetZ()) ); //orkprintf( "D0I <%f %f %f>\n", float(D0I.GetX()), float(D0I.GetY()), float(D0I.GetZ()) ); //orkprintf( "D1I <%f %f %f>\n", float(D1I.GetX()), float(D1I.GetY()), float(D1I.GetZ()) ); AxisAngle.SetW( CalcAngle(D0I,D1I) ); CQuaternion RotQ; RotQ.FromAxisAngle( AxisAngle ); /////////////////// // Rot Snap if( isshift ) { CReal SnapAngleVal( PI2/16.0f ); CVector4 NewAxisAngle = RotQ.ToAxisAngle(); CReal Angle = NewAxisAngle.GetW(); Angle = SnapReal( Angle, SnapAngleVal ); NewAxisAngle.SetW( Angle ); RotQ.FromAxisAngle( NewAxisAngle ); } /////////////////// // accum rotation CQuaternion oq = mBaseTransform.GetTransform().GetRotation(); CQuaternion NewQ = RotQ.Multiply(oq); /////////////////// // Rot Reset To Identity if( isctrl && isshift ) { NewQ.FromAxisAngle( CVector4( CReal(0.0f), CReal(1.0f), CReal(0.0f), CReal(0.0f) ) ); } /////////////////// TransformNode mset = mManager.mCurTransform; mset.GetTransform().SetRotation( NewQ ); mManager.ApplyTransform( mset ); /////////////////// } brval = true; } break; default: break; } return brval; }
QuadTree MakeTree(int size, int center_x, int center_y, int lo_proc, int hi_proc, QuadTree parent, ChildType ct, int level) { int intersect=0; QuadTree retval; #ifdef FUTURES retval = (QuadTree) ALLOC(lo_proc,sizeof(*retval)); #else retval = (QuadTree) mymalloc(sizeof(*retval)); #endif retval->parent = parent; retval->childtype = ct; intersect = CheckIntersect(center_x,center_y,size); size = size/2; if ((intersect==0) && (size<512)) { retval->color = white; retval->nw = NULL; retval->ne = NULL; retval->sw = NULL; retval->se = NULL; } else if (intersect==2) { retval->color=black; retval->nw = NULL; retval->ne = NULL; retval->sw = NULL; retval->se = NULL; } else { if (!level) { retval->color = black; retval->nw = NULL; retval->ne = NULL; retval->sw = NULL; retval->se = NULL; } else { int mid1,mid2; #ifdef FUTURES future_cell_int fc_sw,fc_se,fc_ne; #endif mid1 = (lo_proc+hi_proc)/2; mid2 = (lo_proc+hi_proc+1)/2; #ifndef FUTURES retval->sw = MakeTree(size,center_x-size,center_y-size, (mid2+hi_proc+1)/2,hi_proc,retval, southwest,level-1); retval->se = MakeTree(size,center_x+size,center_y-size, mid2,(mid2+hi_proc)/2,retval, southeast,level-1); retval->ne = MakeTree(size,center_x+size,center_y+size, (lo_proc+mid1+1)/2,mid1,retval, northeast,level-1); retval->nw = MakeTree(size,center_x-size,center_y+size, lo_proc,(lo_proc+mid1)/2,retval, northwest,level-1); #else FUTURE(size,center_x-size,center_y-size, (mid2+hi_proc+1)/2,hi_proc,retval, southwest,level-1,MakeTree,&fc_sw); FUTURE(size,center_x+size,center_y-size, mid2,(mid2+hi_proc)/2,retval, southeast,level-1,MakeTree,&fc_se); FUTURE(size,center_x+size,center_y+size, (lo_proc+mid1+1)/2,mid1,retval, northeast,level-1,MakeTree,&fc_ne); retval->nw = MakeTree(size,center_x-size,center_y+size, lo_proc,(lo_proc+mid1)/2,retval, northwest,level-1); TOUCH(&fc_sw); retval->sw = (QuadTree) fc_sw.value; TOUCH(&fc_se); retval->se = (QuadTree) fc_se.value; TOUCH(&fc_ne); retval->ne = (QuadTree) fc_ne.value; #endif retval->color = grey; } } return retval; }