コード例 #1
0
ファイル: CTextureCanvas.cpp プロジェクト: Genghoidal/SLADE
/* CTextureCanvas::onMouseEvent
 * Called when and mouse event is generated (movement/clicking/etc)
 *******************************************************************/
void CTextureCanvas::onMouseEvent(wxMouseEvent& e)
{
	bool refresh = false;

	// MOUSE MOVEMENT
	if (e.Moving() || e.Dragging())
	{
		dragging = false;

		// Pan if middle button is down
		if (e.MiddleIsDown())
		{
			offset = offset + point2_t(e.GetPosition().x - mouse_prev.x, e.GetPosition().y - mouse_prev.y);
			refresh = true;
			dragging = true;
		}
		else if (e.LeftIsDown())
			dragging = true;

		// Check if patch hilight changes
		point2_t pos = screenToTexPosition(e.GetX(), e.GetY());
		int patch = patchAt(pos.x, pos.y);
		if (hilight_patch != patch)
		{
			hilight_patch = patch;
			refresh = true;
		}
	}

	// LEFT BUTTON UP
	else if (e.LeftUp())
	{
		// If we were dragging, generate end drag event
		if (dragging)
		{
			dragging = false;
			updateTexturePreview();
			refresh = true;
			wxCommandEvent evt(EVT_DRAG_END, GetId());
			evt.SetInt(wxMOUSE_BTN_LEFT);
			ProcessWindowEvent(evt);
		}
	}

	// LEAVING
	if (e.Leaving())
	{
		// Set no hilighted patch
		hilight_patch = -1;
		refresh = true;
	}

	// Refresh is needed
	if (refresh)
		Refresh();

	// Update 'previous' mouse coordinates
	mouse_prev.set(e.GetPosition().x, e.GetPosition().y);
}
コード例 #2
0
ファイル: PatchMesh.cpp プロジェクト: amattwithers/aphid
char PatchMesh::intersect(unsigned idx, IntersectionContext * ctx) const
{
	PointInsidePolygonTest pa = patchAt(idx);

	if(!patchIntersect(pa, ctx)) return 0;
	
	postIntersection(idx, ctx);
	
	return 1;
}
コード例 #3
0
ファイル: PatchMesh.cpp プロジェクト: amattwithers/aphid
char PatchMesh::selectFace(const unsigned & idx, SelectionContext * ctx) const
{
	PointInsidePolygonTest pa = patchAt(idx);
	if(!ctx->closeTo(pa.normal())) return 0;
	
	Vector3F closestP;
	char inside;
	if(pa.distanceTo(ctx->center(), closestP, inside) > ctx->radius()) return 0;
	
	ctx->addToSelection(idx);
	
	return 1;
}
コード例 #4
0
ファイル: PatchMesh.cpp プロジェクト: amattwithers/aphid
char PatchMesh::closestPoint(unsigned idx, const Vector3F & origin, IntersectionContext * ctx) const
{
	PointInsidePolygonTest pa = patchAt(idx);
	
	Vector3F px;
	char inside = 1;
	float d = pa.distanceTo(origin, px, inside);
	
	if(d > ctx->m_minHitDistance) 
		return 0;
		
	ctx->m_minHitDistance = d;
	ctx->m_componentIdx = idx;
	ctx->m_closestP = px;
	ctx->m_hitP = px;

	return 1;
}
コード例 #5
0
ファイル: PatchMesh.cpp プロジェクト: amattwithers/aphid
Vector3F PatchMesh::getFaceNormal(const unsigned & idx) const
{
	PointInsidePolygonTest pa = patchAt(idx);
	return pa.normal();
}