Ejemplo n.º 1
0
HitRecord* CrossSectionMouseProc::HitTest( ViewExp *vpt, IPoint2 *p, int type, int flags )
	{
	HitRecord *bestRec = NULL;

	vpt->ClearSubObjHitList();
	SetSplineHitOverride(SS_SPLINE);
	ip->SubObHitTest(ip->GetTime(),type,ip->GetCrossing(),flags,p,vpt);
	ClearSplineHitOverride();
	
	if ( vpt->NumSubObjHits() ) {
		HitLog &hits = vpt->GetSubObjHitList();
		DWORD best;
		for (HitRecord *rec = hits.First(); rec != NULL; rec = rec->Next()) {
			if (mCreating) {
				ShapeHitData *hit = ((ShapeHitData *)rec->hitData);
				if (hit->poly >= mPolys) continue;
			}
			if(bestRec == NULL || rec->distance < best) {
				best = rec->distance;
				bestRec = rec;
				}
			}
		}
	return bestRec;
	}
Ejemplo n.º 2
0
int SegRefineMouseProc::proc(
			HWND hwnd, 
			int msg, 
			int point, 
			int flags, 
			IPoint2 m )
	{
	ViewExp *vpt = ip->GetViewport(hwnd);	
	int res = TRUE;

	switch ( msg ) {
		case MOUSE_PROPCLICK:
			ip->SetStdCommandMode(CID_OBJMOVE);
			break;

		case MOUSE_POINT:
			if(HitTest(vpt,&m,HITTYPE_POINT,0) ) {
				HitLog &hits = vpt->GetSubObjHitList();
				HitRecord *rec = hits.First();
				HitRecord *bestRec = rec;
				DWORD best = rec->distance;
				while(rec) {
					rec = rec->Next();
					if(rec) {
						if(rec->distance < best) {
							best = rec->distance;
							bestRec = rec;
							}
						}
					}
				ShapeHitData *hit = ((ShapeHitData *)bestRec->hitData);
				es->DoSegRefine(vpt, hit->shape, hit->poly, hit->index, m);
				}
			res = FALSE;
			break;
		
		case MOUSE_FREEMOVE:
			vpt->SnapPreview(m,m,NULL, SNAP_IN_3D);
			if ( HitTest(vpt,&m,HITTYPE_POINT,HIT_ABORTONHIT) ) {
				SetCursor(GetTransformCursor());
				}
			else {
				SetCursor(LoadCursor(NULL,IDC_ARROW));
				}
			break;
			
		}

	if ( vpt ) ip->ReleaseViewport(vpt);
	return res;
	}
Ejemplo n.º 3
0
int TrimMouseProc::proc( 
		HWND hwnd, 
		int msg, 
		int point, 
		int flags, 
		IPoint2 m )
	{	
	ViewExp *vpt = ip->GetViewport(hwnd);
	int res = TRUE;
//	IntersectPt fromPt, toPt;
	BOOL extend = FALSE;
	switch ( msg ) {
		case MOUSE_PROPCLICK:
			ip->SetStdCommandMode(CID_OBJMOVE);
			break;

		case MOUSE_POINT:						
			if(HitTest(vpt,&m,HITTYPE_POINT,0) ) {
				HitLog &hits = vpt->GetSubObjHitList();
				HitRecord *rec = hits.First();
				HitRecord *bestRec = rec;
				DWORD best = rec->distance;
				while(rec) {
					rec = rec->Next();
					if(rec) {
						if(rec->distance < best) {
							best = rec->distance;
							bestRec = rec;
							}
						}
					}
				ShapeHitData *hit = ((ShapeHitData *)bestRec->hitData);
				es->HandleTrimExtend(vpt, hit, m, SHAPE_TRIM);
				}
			res = FALSE;
			break;

		case MOUSE_FREEMOVE:
			if ( HitTest(vpt,&m,HITTYPE_POINT,HIT_ABORTONHIT) ) {
				SetCursor(GetTransformCursor());
				}
			else {
				SetCursor(LoadCursor(NULL,IDC_ARROW));
				}
			break;
		}
	
	if ( vpt ) ip->ReleaseViewport(vpt);
	return res;
	}
Ejemplo n.º 4
0
void EditFaceDataMod::SelectSubComponent (HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert) {
	EditFaceDataModData *d = NULL, *od = NULL;

	ModContextList mcList;
	INodeTab nodes;
	ip->GetModContexts(mcList,nodes);
	BitArray nsel;

	for (int nd=0; nd<mcList.Count(); nd++) {
		d = (EditFaceDataModData*) mcList[nd]->localData;
		if (d==NULL) continue;
		HitRecord *hr = hitRec;
		if (!all && (hr->modContext->localData != d)) continue;
		for (; hr!=NULL; hr=hr->Next()) if (hr->modContext->localData == d) break;
		if (hr==NULL) continue;

		Mesh *mesh = d->GetCacheMesh();
		MNMesh *mnmesh = d->GetCacheMNMesh();
		if (!mesh && !mnmesh) continue;
		if (theHold.Holding() && !d->GetHeld()) theHold.Put (new SelectRestore (this, d));

		switch (selLevel) {
		case SEL_FACE:
			nsel = d->GetFaceSel();
			for (; hr != NULL; hr=hr->Next()) {
				if (d != hr->modContext->localData) continue;
				nsel.Set (hr->hitInfo, invert ? !d->GetFaceSel()[hr->hitInfo] : selected);
				if (!all) break;
			}
			d->GetFaceSel() = nsel;
			break;
		}
	}

	nodes.DisposeTemporary ();
	SelectionChanged ();
}
Ejemplo n.º 5
0
BOOL BindMouseProc::HitASegment(ViewExp *vpt, IPoint2 *p, BezierShape *shape, int poly, int vert,
	BezierShape **shapeOut, int *polyOut, int *vertOut) {

	int first = 1;
	
	SetSplineHitOverride(SS_SEGMENT);
	if(HitTest(vpt, p, HITTYPE_POINT, 0) ) {
		HitLog &hits = vpt->GetSubObjHitList();
		HitRecord *rec = hits.First();
		DWORD best = 9999;
		HitRecord *bestRec;
		while(rec) {
			ShapeHitData *hit = ((ShapeHitData *)rec->hitData);
			// If there's an exclusion shape, this must be a part of it!
			Spline3D *spline = hit->shape->splines[hit->poly];
			int scount = spline->KnotCount()-1;
			if ((poly == hit->poly) && ((vert-1) == 0) && (hit->index == 0))
				{
				}
			else if ((poly == hit->poly) && (vert == ((scount+1)*3-2)) && (hit->index == (scount-1)))
				{
				}
			else if(first || rec->distance < best) 
				{
				first = 0;
				best = rec->distance;
				bestRec = rec;
				}
			rec = rec->Next();
			}
		if(!first) {
			ShapeHitData *hit = ((ShapeHitData *)bestRec->hitData);
			if(shapeOut)
				*shapeOut = hit->shape;
			if(polyOut)
				*polyOut = hit->poly;
			if(vertOut)
				*vertOut = hit->index;
			ClearSplineHitOverride();
			return TRUE;
			}
		}
	ClearSplineHitOverride();
	return FALSE;

	}
Ejemplo n.º 6
0
BOOL VertConnectMouseProc::HitAnEndpoint(ViewExp *vpt, IPoint2 *p, BezierShape *shape, int poly, int vert,
	BezierShape **shapeOut, int *polyOut, int *vertOut) {
	int first = 1;
	
	if(HitTest(vpt, p, HITTYPE_POINT, 0) ) {
		HitLog &hits = vpt->GetSubObjHitList();
		HitRecord *rec = hits.First();
		DWORD best = 9999;
		HitRecord *bestRec;
		while(rec) {
			ShapeHitData *hit = ((ShapeHitData *)rec->hitData);
			// If there's an exclusion shape, this must be a part of it!
			if(!shape || shape == hit->shape) {
				// If there's an exclusion shape, the vert & poly can't be the same!
				if(!shape || (shape && !(poly == hit->poly && vert == hit->index))) {
					Spline3D *spline = hit->shape->splines[hit->poly];
					if(!spline->Closed()) {
						int hitKnot = hit->index / 3;
						if(hitKnot == 0 || hitKnot == (spline->KnotCount() - 1)) {
							if(first || rec->distance < best) {
								first = 0;
								best = rec->distance;
								bestRec = rec;
								}
							}
						}
					}
				}
			rec = rec->Next();
			}
		if(!first) {
			ShapeHitData *hit = ((ShapeHitData *)bestRec->hitData);
			if(shapeOut)
				*shapeOut = hit->shape;
			if(polyOut)
				*polyOut = hit->poly;
			if(vertOut)
				*vertOut = hit->index;
			return TRUE;
			}
		}
	return FALSE;
	}
Ejemplo n.º 7
0
int CrossInsertMouseProc::proc(
			HWND hwnd, 
			int msg, 
			int point, 
			int flags, 
			IPoint2 m )
	{
	ViewExp *vpt = ip->GetViewport(hwnd);	
	int res = TRUE;

	switch ( msg ) {
		case MOUSE_PROPCLICK:
			ip->SetStdCommandMode(CID_OBJMOVE);
			break;

		case MOUSE_POINT:
			if(HitTest(vpt,&m,HITTYPE_POINT,0) ) {
				HitLog &hits = vpt->GetSubObjHitList();
				HitRecord *rec = hits.First();
				ShapeHitData *h1 = (ShapeHitData *)rec->hitData;
				rec = rec->Next();
				assert(rec);
				ShapeHitData *h2 = (ShapeHitData *)rec->hitData;
				assert(h1->shape == h2->shape);
				es->DoCrossInsert(vpt, h1->shape, h1->poly, h1->index, h2->poly, h2->index, m);
				}
			res = FALSE;
			break;
		
		case MOUSE_FREEMOVE:
			if ( HitTest(vpt,&m,HITTYPE_POINT,0) ) {
				SetCursor(GetTransformCursor());
				}
			else {
				SetCursor(LoadCursor(NULL,IDC_ARROW));
				}
			break;
			
		}

	if ( vpt ) ip->ReleaseViewport(vpt);
	return res;
	}
Ejemplo n.º 8
0
BOOL CreateLineMouseProc::InsertWhere(ViewExp *vpt, IPoint2 *p, BezierShape **shapeOut, int *polyOut,
		int *segOut, int *vertOut) {
	int first = 1;

	// Reset these!
	*segOut = -1;
	*vertOut = -1;

	// Only valid insertion vertices are endpoints of the spline
	if(HitTest(vpt, p, HITTYPE_POINT, 0, ES_VERTEX) ) {
		HitLog &hits = vpt->GetSubObjHitList();
		HitRecord *rec = hits.First();
		DWORD best = 9999;
		HitRecord *bestRec;
		while(rec) {
			ShapeHitData *hit = ((ShapeHitData *)rec->hitData);
			int hitKnot = hit->index / 3;
			Spline3D *spline = hit->shape->splines[hit->poly];
			if(!spline->Closed() && (hitKnot == 0 || hitKnot == (spline->KnotCount() - 1))) {
				if(first || rec->distance < best) {
					first = 0;
					best = rec->distance;
					bestRec = rec;
					}
				}
			rec = rec->Next();
			}
		if(!first) {
			ShapeHitData *hit = ((ShapeHitData *)bestRec->hitData);
			if(shapeOut)
				*shapeOut = hit->shape;
			if(polyOut)
				*polyOut = hit->poly;
			if(vertOut)
				*vertOut = hit->index;
			return TRUE;
			}
		}

	return FALSE;
	}
Ejemplo n.º 9
0
BOOL CrossInsertMouseProc::HitTest( 
		ViewExp *vpt, IPoint2 *p, int type, int flags )
	{
	vpt->ClearSubObjHitList();
	SetSplineHitOverride(SS_SPLINE);
	ip->SubObHitTest(ip->GetTime(),type,ip->GetCrossing(),flags,p,vpt);
	ClearSplineHitOverride();
	// Make sure that there are exactly two hits and they are on different polygons of
	// the same shape
	if ( vpt->NumSubObjHits() == 2 ) {
		HitLog &hits = vpt->GetSubObjHitList();
		HitRecord *rec = hits.First();
		ShapeHitData *h1 = (ShapeHitData *)rec->hitData;
		rec = rec->Next();
		assert(rec);
		ShapeHitData *h2 = (ShapeHitData *)rec->hitData;
		if((h1->shape == h2->shape) && (h1->poly != h2->poly))
			return TRUE;
		}
	return FALSE;			
	}
Ejemplo n.º 10
0
HitRecord* PasteTangentMouseProc::HitTest( ViewExp *vpt, IPoint2 *p, int type, int flags )
	{
	HitRecord *bestRec = NULL;

	vpt->ClearSubObjHitList();
	SetSplineHitOverride(SS_VERTEX);
	ip->SubObHitTest(ip->GetTime(),type,ip->GetCrossing(),flags,p,vpt);
	ClearSplineHitOverride();
	
	if ( vpt->NumSubObjHits() ) {
		HitLog &hits = vpt->GetSubObjHitList();
		DWORD best;
		for (HitRecord *rec = hits.First(); rec != NULL; rec = rec->Next()) {
			ShapeHitData *hit = ((ShapeHitData *)rec->hitData);
			if ((hit->index % 3) == 1) continue;
			if(bestRec == NULL || rec->distance < best) {
				best = rec->distance;
				bestRec = rec;
				}
			}
		}
	return bestRec;
	}