!2342 优化:铰链初始位置以及偏移后间距最低为5

pull/2350/head
林三 1 year ago committed by ChenX
parent 15cd59ef31
commit 22d300387d

@ -33,7 +33,10 @@ import { IsDoor, IsHandle, IsHinge } from "../../HideSelect/HideSelectUtils";
* *
* @type {*} * @type {*}
* */ * */
const MoveNum = 8; const MoveNum: number = 8;
//绘制出的铰链与层板(左右开门时)或立板(上下开门时)最低间距 或偏移后最低间距
export const BoxIntersectFuzz: number = 5;
export class DrawDoorTool export class DrawDoorTool
{ {
@ -618,7 +621,8 @@ export class DrawDoorTool
br2GrooveOutlinesCache.set(br, grooveOutlines); br2GrooveOutlinesCache.set(br, grooveOutlines);
} }
if (brBox.clone().intersect(ironBox).isSolid()) //门板不增加误差,防止隔壁门板误关联
if (brBox.clone().intersect(ironBox).isSolid() || !IsDoor(br) && brBox.intersectsBox(ironBox, BoxIntersectFuzz))
{ {
const center = ironBox.getCenter(new Vector3).applyMatrix4(br.OCSInv).setZ(0); const center = ironBox.getCenter(new Vector3).applyMatrix4(br.OCSInv).setZ(0);
if (grooveOutlines.some(c => c.PtInCurve(center)))//五金的中心在造型内部 if (grooveOutlines.some(c => c.PtInCurve(center)))//五金的中心在造型内部
@ -675,9 +679,9 @@ export class DrawDoorTool
{ {
if (!IsHinge(ironware)) continue; if (!IsHinge(ironware)) continue;
if (!IsBoxAndEntitysIntersect(ironBox, [otherEnt])) continue; let isDoor = IsDoor(otherEnt);
if (!IsBoxAndEntitysIntersect(ironBox, [otherEnt], BoxIntersectFuzz, undefined, isDoor)) continue;
if (IsDoor(otherEnt)) if (isDoor)
{ {
//铰链归属复合门板 //铰链归属复合门板
ironware.RelevanceBoards.push(otherEnt.Id); ironware.RelevanceBoards.push(otherEnt.Id);
@ -906,7 +910,7 @@ export class DrawDoorTool
if (box1Info + (isUpDownDoor ? 10 : 100) < doorSpecs) if (box1Info + (isUpDownDoor ? 10 : 100) < doorSpecs)
{ {
if (!IsBoxAndEntitysIntersect(realityBox1, checkEnts)) if (!IsBoxAndEntitysIntersect(realityBox1, checkEnts, BoxIntersectFuzz))
return number; return number;
else else
return this.MoveAgain(doorSpecs, inventedBox, realityBox, checkEnts, distance, number, isUpDownDoor); return this.MoveAgain(doorSpecs, inventedBox, realityBox, checkEnts, distance, number, isUpDownDoor);
@ -936,7 +940,7 @@ export class DrawDoorTool
} }
if (box2Info - (isUpDownDoor ? 10 : 100) > 0) if (box2Info - (isUpDownDoor ? 10 : 100) > 0)
{ {
if (!IsBoxAndEntitysIntersect(realityBox2, checkEnts)) if (!IsBoxAndEntitysIntersect(realityBox2, checkEnts, BoxIntersectFuzz))
return -number; return -number;
else else
{ {
@ -1010,7 +1014,7 @@ export function SetHingeType(br: Board, ironware: HardwareCompositeEntity): void
* @param checkEnts * @param checkEnts
* @param parentOCS * @param parentOCS
*/ */
export function IsBoxAndEntitysIntersect(enBox: Box3, checkEnts: Entity[], parentOCS?: Matrix4): boolean export function IsBoxAndEntitysIntersect(enBox: Box3, checkEnts: Entity[], fuzz?: number, parentOCS?: Matrix4, isDoor?: boolean): boolean
{ {
for (let checkEnt of checkEnts) for (let checkEnt of checkEnts)
{ {
@ -1019,22 +1023,29 @@ export function IsBoxAndEntitysIntersect(enBox: Box3, checkEnts: Entity[], paren
let ocs = checkEnt.OCSNoClone; let ocs = checkEnt.OCSNoClone;
if (parentOCS) ocs = new Matrix4().multiplyMatrices(parentOCS, ocs); if (parentOCS) ocs = new Matrix4().multiplyMatrices(parentOCS, ocs);
if (IsBoxAndEntitysIntersect(enBox, checkEnt.Entitys, ocs)) if (IsBoxAndEntitysIntersect(enBox, checkEnt.Entitys, fuzz, ocs, isDoor))
return true; return true;
} }
else else
{ {
let box = checkEnt.BoundingBox as Box3Ext; let box = checkEnt.BoundingBox as Box3Ext;
if (parentOCS) box.applyMatrix4(parentOCS); if (parentOCS) box.applyMatrix4(parentOCS);
if (box.intersectsBox(enBox, 10)) if (isDoor)
{
if (box.clone().intersect(enBox).Volume > 0)
return true;
}
else
{
if (box.intersectsBox(enBox, fuzz))
return true; return true;
} }
} }
}
return false; return false;
} }
/** /**
*
* *
* hingeSpace.GetParam("SY").value * hingeSpace.GetParam("SY").value
* *

@ -1,5 +1,5 @@
import { Box3, Vector3 } from "three"; import { Box3, Vector3 } from "three";
import { IsBoxAndEntitysIntersect, RecordHingeTrSizeX, SetHingeType, SetNoPareTypeHigneName } from "../../../Add-on/DrawBoard/DrawDoorDrawer/DrawDoorTool"; import { BoxIntersectFuzz, IsBoxAndEntitysIntersect, RecordHingeTrSizeX, SetHingeType, SetNoPareTypeHigneName } from "../../../Add-on/DrawBoard/DrawDoorDrawer/DrawDoorTool";
import { IsDoor, IsHandle, IsHinge } from "../../../Add-on/HideSelect/HideSelectUtils"; import { IsDoor, IsHandle, IsHinge } from "../../../Add-on/HideSelect/HideSelectUtils";
import { app } from "../../../ApplicationServices/Application"; import { app } from "../../../ApplicationServices/Application";
import { EBoardKeyList } from "../../../Common/BoardKeyList"; import { EBoardKeyList } from "../../../Common/BoardKeyList";
@ -402,7 +402,8 @@ export class TemplateDrawHingeTool
outlinesCache.set(br, grooveOutlines); outlinesCache.set(br, grooveOutlines);
} }
if (otherEntBox.clone().intersect(inventedBox).isSolid()) //门板不增加误差,防止隔壁门板误关联
if (otherEntBox.clone().intersect(inventedBox).isSolid() || !IsDoor(br) && otherEntBox.intersectsBox(inventedBox, BoxIntersectFuzz))
{ {
const center = inventedBox.getCenter(new Vector3).applyMatrix4(br.OCSInv).setZ(0); const center = inventedBox.getCenter(new Vector3).applyMatrix4(br.OCSInv).setZ(0);
if (grooveOutlines.some(c => c.PtInCurve(center))) if (grooveOutlines.some(c => c.PtInCurve(center)))
@ -447,7 +448,8 @@ export class TemplateDrawHingeTool
{ {
if (!IsHinge(ironware)) continue; if (!IsHinge(ironware)) continue;
if (!IsBoxAndEntitysIntersect(realityBox, [otherEnt])) continue; let isDoor = IsDoor(otherEnt);
if (!IsBoxAndEntitysIntersect(realityBox, [otherEnt], BoxIntersectFuzz, undefined, isDoor)) continue;
if (IsDoor(otherEnt)) if (IsDoor(otherEnt))
{ {
@ -511,7 +513,7 @@ export class TemplateDrawHingeTool
realityBox1.translate(new Vector3(0, 0, distance * number)); realityBox1.translate(new Vector3(0, 0, distance * number));
let box1Z = inventedBox1.getCenter(new Vector3).z; let box1Z = inventedBox1.getCenter(new Vector3).z;
if (box1Z + 100 < doorHight && !IsBoxAndEntitysIntersect(realityBox1, layers)) if (box1Z + 100 < doorHight && !IsBoxAndEntitysIntersect(realityBox1, layers, BoxIntersectFuzz))
return number * distance; return number * distance;
else else
{ {
@ -522,7 +524,7 @@ export class TemplateDrawHingeTool
let realityBox2 = realityBox.clone(); let realityBox2 = realityBox.clone();
realityBox2.translate(new Vector3(0, 0, distance * -number)); realityBox2.translate(new Vector3(0, 0, distance * -number));
if (box2Z - 100 > 0 && !IsBoxAndEntitysIntersect(realityBox2, layers)) if (box2Z - 100 > 0 && !IsBoxAndEntitysIntersect(realityBox2, layers, BoxIntersectFuzz))
return -number * distance; return -number * distance;
else else
{ {
@ -544,7 +546,7 @@ export class TemplateDrawHingeTool
realityBox1.translate(new Vector3(distance * number, 0, 0)); realityBox1.translate(new Vector3(distance * number, 0, 0));
if (box1Z + 100 < doorHight && !IsBoxAndEntitysIntersect(realityBox1, verticals)) if (box1Z + 100 < doorHight && !IsBoxAndEntitysIntersect(realityBox1, verticals, BoxIntersectFuzz))
return number * distance; return number * distance;
else else
{ {
@ -555,7 +557,7 @@ export class TemplateDrawHingeTool
let realityBox2 = realityBox.clone(); let realityBox2 = realityBox.clone();
realityBox2.translate(new Vector3(distance * -number, 0, 0)); realityBox2.translate(new Vector3(distance * -number, 0, 0));
if (box2Z - 100 > 0 && !IsBoxAndEntitysIntersect(realityBox2, verticals)) if (box2Z - 100 > 0 && !IsBoxAndEntitysIntersect(realityBox2, verticals, BoxIntersectFuzz))
return -number * distance; return -number * distance;
else else
{ {

Loading…
Cancel
Save