protected override void OnMouseDown(Rhino.Input.Custom.GetPointMouseEventArgs e)
{
starting_point = e.Point;
//RhinoApp.WriteLine($"测试打印,{starting_point}");
if (m_dc.PickResult.Mode != Rhino.UI.Gumball.GumballMode.None)
return; // 如果 Gumball 已经被选中,不做处理
m_dc.PickResult.SetToDefault(); // 重置拾取结果
// 构造一个拾取上下文
Rhino.Input.Custom.PickContext pick_context = new Rhino.Input.Custom.PickContext();
pick_context.View = e.Viewport.ParentView; // 设置当前视图
pick_context.PickStyle = Rhino.Input.Custom.PickStyle.PointPick; // 点选模式
// 获取拾取变换矩阵
var xform = e.Viewport.GetPickTransform(e.WindowPoint);
pick_context.SetPickTransform(xform);
// 获取射线(视锥线)
Rhino.Geometry.Line pick_line;
e.Viewport.GetFrustumLine(e.WindowPoint.X, e.WindowPoint.Y, out pick_line);
pick_context.PickLine = pick_line; // 设置拾取线
pick_context.UpdateClippingPlanes(); // 更新裁剪平面
//检测是否选中了 Gumball,如果选中则更新约束
m_dc.PickGumball(pick_context, this);
st_bool = true;
base.OnMouseDown(e);
}
When using rays to determine whether Gumball is selected, errors always occur in the perspective view. This has been bothering me. Is there a better way to solve this problem?