sorry i thought you know already a solution
I don’t know where to start explaining…
We want to draw a circle on an known object (brep or mesh) as feedback. For this we made a conduit to draw the circle. To get the point for drawing the circle we react on mouse movement and retrieve the mouse position on the screen, from this i retrieve the 2D position in the view, from this point i retrieve the 3D point on the geometry with this code:
bool GetRaycastPoint(const CRhinoView * view, const CPoint & view_wnd_point, ON_3dPoint & raycastPoint)
CRhinoViewport &viewPort = view->ActiveViewport();
pick_context.m_view = (CRhinoView*)view;
pick_context.m_pick_style = CRhinoPickContext::point_pick;
pick_context.m_pick_mode = CRhinoPickContext::shaded_pick;
int pick_count = 0;
if (viewPort.GetPickXform(view_wnd_point.x, view_wnd_point.y, pick_context.m_pick_region.m_xform))
// adds objects to pick_list - does not change any status
viewPort.VP().GetFrustumLine(view_wnd_point.x, view_wnd_point.y, pick_context.m_pick_line);
//TODO: performance problem on big meshes
pick_count = RhinoApp().ActiveDoc()->PickObjects(pick_context, pick_list);
if (pick_count > 0)
// only use first pick
raycastPoint = pick_list.First()->m_point;
This works very good on brep (even big ones) and small meshes. But if the mesh gets to big (>200 000 faces) it begins to lag.
At the other hand i use CRhinoGetPoint on big meshes (>1 000 000 faces) and it works without problems. So Rhino is capable to do this, i just don’t know how.
I also tried to use the
CRhinoPickContext::PickMesh method, but with this method i got a wrong result. Half of the time i got the point on the back side (invisible side) of the geometry.