Picking a point on object without CRhinoGetObject


#1

hi

we want to retrieve the point on an object under the mouse and we followed your code sample at
http://developer.rhino3d.com/guides/cpp/picking_objects_without_crhinogetobject/

It works so far but on big meshes it takes a very long time to get the point. In comparison to this method we have also tried a sample with CRhinoGetObject and it works smoothly as we want it.

Do you have any idea why it takes so long with doc.PickObjects or do you have another method to retrieve an point on an object under the mouse pointer?


(Dale Fugier) #2

Hi Wolfgang,

I’ll need more information and details about what you are trying to do and why, in order to provide assistance.

Of course, there is CRhinoGetPoint for picking point locations and CRhinoGetObject for picking objects or components of objects.

– Dale


#3

Hi Dale,

sorry i thought you know already a solution :wink:

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();

    CRhinoPickContext pick_context;
    pick_context.m_view = (CRhinoView*)view;
    pick_context.m_pick_style = CRhinoPickContext::point_pick;
    pick_context.m_pick_mode = CRhinoPickContext::shaded_pick;

    CRhinoObjRefArray pick_list;
    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);
        pick_context.UpdateClippingPlanes();

        //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;
        return true;
    }
    else
        return false;

}

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.


(Dale Fugier) #4

Is there any reason you are not using a CRhinoGetPoint-derived class that overrides CRhinoGetPoint::OnMouseMove and CRhinoGetPoint::DynamicDraw?

Here is a sample.

https://github.com/mcneel/Rhino5Samples_CPP/blob/master/SampleCommands/cmdSampleCircle.cpp

– Dale


#5

Hi

yes there are some reasons why i can not use CRhinoGetPoint in this situation (with this special plugin). The main reason is that we give a feedback with our tool while other commands can run.

What i meant is that we have developed other tools or plugins, where we use CRhinoGetPoint without problems.


(Dale Fugier) #6

@dsw, sorry for not paying attention to this. Where are we at with this issue?

– Dale


#7

Still the same problem. Due to limitations of CRhinoGetPoint i must use CRhinoDoc::PickObjects and this one is very laggy if there are meshes in the scene with a lot of faces. The interesting part of this is, that only the existence of this big mesh makes this method laggy, even if the mesh is not visible in the viewport.