fix #IXWMX 修复直线拽拖错误的使用相对基点(保证切线捕捉正常)

pull/439/head
ChenX 5 years ago
parent 4256577694
commit eb1d06cb6f

@ -118,10 +118,11 @@ export class GripDragServices implements EditorService
if (snapIndexMap[0].indexArr.length === 1) if (snapIndexMap[0].indexArr.length === 1)
{ {
let i = snapIndexMap[0].indexArr[0]; let i = snapIndexMap[0].indexArr[0];
let snapServices = this.ed.GetPointServices.snapServices;
if (i === 0) if (i === 0)
baseP = snapIndexMap[0].ent.EndPoint; snapServices.TanBasePoint = snapIndexMap[0].ent.EndPoint;
else if (i === 2) else if (i === 2)
baseP = snapIndexMap[0].ent.StartPoint; snapServices.TanBasePoint = snapIndexMap[0].ent.StartPoint;
} }
} }

@ -79,6 +79,9 @@ export class SnapServices
private m_IsZAxis = false; private m_IsZAxis = false;
private m_SupportSnapPoints: SupportSnapPoint[] = [];//辅助捕捉点WCS private m_SupportSnapPoints: SupportSnapPoint[] = [];//辅助捕捉点WCS
private m_UCS: Matrix4; private m_UCS: Matrix4;
/** 切线捕捉时使用的基点 */
TanBasePoint: Vector3;
//开始捕捉 //开始捕捉
Start(prompt: GetPointPrompt) Start(prompt: GetPointPrompt)
{ {
@ -98,7 +101,7 @@ export class SnapServices
Entitys: [], Entitys: [],
}); });
//当基点在圆上或者圆弧上的时候,支持切线捕捉 //#region 当基点在圆上或者圆弧上的时候,支持切线捕捉
let sel = new SelectPick(app.Viewer, app.Viewer.WorldToScreen(prompt.BasePoint.clone())); let sel = new SelectPick(app.Viewer, app.Viewer.WorldToScreen(prompt.BasePoint.clone()));
sel.Select(app.Viewer.VisibleObjects, { filterTypes: [Circle, Arc] }); sel.Select(app.Viewer.VisibleObjects, { filterTypes: [Circle, Arc] });
let cirs = sel.SelectEntityList as (Circle | Arc)[]; let cirs = sel.SelectEntityList as (Circle | Arc)[];
@ -117,6 +120,7 @@ export class SnapServices
Point: prompt.BasePoint.clone(), Point: prompt.BasePoint.clone(),
Entitys: ents, Entitys: ents,
}); });
//#endregion
this.UpdateCrossCursor(); this.UpdateCrossCursor();
this.m_HasBasePoint = true; this.m_HasBasePoint = true;
@ -135,6 +139,7 @@ export class SnapServices
this.m_DelaySupportSnapId = undefined; this.m_DelaySupportSnapId = undefined;
} }
this.TanBasePoint = undefined;
this.m_SupportSnapPoints.length = 0; this.m_SupportSnapPoints.length = 0;
this.SnapPoint = undefined; this.SnapPoint = undefined;
this.m_SupportExtLinePts.length = 0; this.m_SupportExtLinePts.length = 0;
@ -221,13 +226,15 @@ export class SnapServices
let selectEns = PointPick(vcsP, app.Viewer, { filterErase: true }, app.Viewer.VisibleObjects).map(GetEntity).filter(e => e !== undefined); let selectEns = PointPick(vcsP, app.Viewer, { filterErase: true }, app.Viewer.VisibleObjects).map(GetEntity).filter(e => e !== undefined);
let viewXform = new Matrix3().setFromMatrix4(app.Viewer.Camera.matrix);
//如果只有切线捕捉 //如果只有切线捕捉
if (this.SnapModeEnable === ObjectSnapMode.Tan && !this.m_HasBasePoint) if (this.SnapModeEnable === ObjectSnapMode.Tan && !this.m_HasBasePoint)
for (let e of selectEns) for (let e of selectEns)
{ {
if (e instanceof Circle || e instanceof Arc) if (e instanceof Circle || e instanceof Arc)
{ {
let sps = e.GetObjectSnapPoints(ObjectSnapMode.Nea, wcsP, baseP); let sps = e.GetObjectSnapPoints(ObjectSnapMode.Nea, wcsP, baseP, viewXform);
for (let p of sps) for (let p of sps)
{ {
@ -241,9 +248,6 @@ export class SnapServices
} }
} }
let viewXform = new Matrix3().setFromMatrix4(app.Viewer.Camera.matrix);
//#region 实体点捕捉(端点,中点,圆心,垂点,切点) //#region 实体点捕捉(端点,中点,圆心,垂点,切点)
for (let mode of [ for (let mode of [
ObjectSnapMode.End, ObjectSnapMode.End,
@ -257,7 +261,11 @@ export class SnapServices
if ((mode & this.SnapModeEnable) === 0) if ((mode & this.SnapModeEnable) === 0)
continue; continue;
let snapData = this.CalcClosestSnapPoint(selectEns, mode, wcsP, vcsP, baseP, viewXform); let bp = baseP;
if (mode === ObjectSnapMode.Tan && this.TanBasePoint)
bp = this.TanBasePoint;
let snapData = this.CalcClosestSnapPoint(selectEns, mode, wcsP, vcsP, bp, viewXform);
if (snapData.Point) if (snapData.Point)
{ {

Loading…
Cancel
Save