void SelectCurvePointByRay (vec3_t org, vec3_t dir, int buttons) { int i, besti; float d, bestd; vec3_t temp; // find the point closest to the ray besti = -1; bestd = 8; for (i=0 ; i<g_qeglobals.d_numpoints ; i++) { VectorSubtract (g_qeglobals.d_points[i], org, temp); d = DotProduct (temp, dir); VectorMA (org, d, dir, temp); VectorSubtract (g_qeglobals.d_points[i], temp, temp); d = VectorLength (temp); if (d <= bestd) { bestd = d; besti = i; } } if (besti == -1) { if (g_pParentWnd->ActiveXY()->AreaSelectOK()) { g_qeglobals.d_select_mode = sel_area; VectorCopy(org, g_qeglobals.d_vAreaTL); VectorCopy(org, g_qeglobals.d_vAreaBR); } return; } //Sys_Printf ("hit vertex\n"); AddPatchMovePoint(g_qeglobals.d_points[besti], buttons & MK_CONTROL, buttons & MK_SHIFT); }
/* ======================================================================================================================= ======================================================================================================================= */ void SelectCurvePointByRay(const idVec3 &org, const idVec3 &dir, int buttons) { int i, besti; float d, bestd; idVec3 temp; // find the point closest to the ray float scale = g_pParentWnd->ActiveXY()->Scale(); besti = -1; bestd = 8 / scale / 2; //bestd = 8; for (i = 0; i < g_qeglobals.d_numpoints; i++) { temp = g_qeglobals.d_points[i] - org; d = temp * dir; temp = org + d * dir; temp = g_qeglobals.d_points[i] - temp; d = temp.Length(); if ( d <= bestd ) { bestd = d; besti = i; } } if (besti == -1) { if (g_pParentWnd->ActiveXY()->AreaSelectOK()) { g_qeglobals.d_select_mode = sel_area; VectorCopy(org, g_qeglobals.d_vAreaTL); VectorCopy(org, g_qeglobals.d_vAreaBR); } return; } // Sys_Status ("hit vertex\n"); AddPatchMovePoint( g_qeglobals.d_points[besti], ( buttons & MK_CONTROL ) != 0, ( buttons & MK_SHIFT ) != 0 ); }