THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/05/2011 at 16:29, xxxxxxxx wrote:
Hmm looks like GetNearestPoint only works in Points mode
And as is, this GeRayCollider code runs super slow when there are a lot of points.
Here's what I have, I am doing it in the draw because I want it to update live..
Which I could probably do more effectively in GetCursorInfo() or write my own function and call that from the Draw() but this is mostly for testing. 
AutoAlloc<ViewportSelect> vps;
if(!vps) return TOOLDRAW_0;
BaseObject* op = doc->GetActiveObject();
if(!op) return TOOLDRAW_0;
bd->SetMatrix_Matrix(op, Matrix());
ModelingCommandData mcd;
mcd.op = op;
mcd.mode = MODELINGCOMMANDMODE_ALL;
mcd.doc = doc;
SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd);
BaseObject *res = static_cast<BaseObject*>(mcd.result->GetIndex(0));
PolygonObject *objPoly = (PolygonObject * )res;
if (!objPoly) return TOOLDRAW_0;
LONG pointCount = objPoly->GetPointCount();
Vector * points = objPoly->GetPointW();
AutoAlloc<GeRayCollider> cRay;
// Make sure RayCollider is there
if (!cRay)
{
GePrint("ERROR - RayCollider not Initialized");
return TOOLDRAW_0;
}
for(int i = 0; i < pointCount; i++){
Vector wtail = bd->SW(Vector(cursorX, cursorY, 0));
Vector whead = bd->SW(Vector(cursorX, cursorY, 100000));
Vector otail = (!points[i]) * wtail;
Vector oray = (whead - wtail) ^ (!points[i]);
cRay->Init(objPoly, TRUE);
cRay->Intersect(otail, !oray, 10000.0);
Vector distance = PointLineDistance(wtail, whead, points[i]);
const Real threshold = 20.0; // How close the mouse is to the point befor triggering the collision
Real dist = distance.GetLength();
if(dist <= threshold){
bd->SetPen(Vector(1,0,0));
bd->DrawHandle(points[i], DRAWHANDLE_BIG, NOCLIP_Z);
}
}
return TOOLDRAW_AXIS|TOOLDRAW_HANDLES;