|
|
|
@ -532,7 +532,7 @@ export class DrawDoorTool
|
|
|
|
|
* @param isUpDownDoor 上下开门 否为左右开门
|
|
|
|
|
* @returns
|
|
|
|
|
*/
|
|
|
|
|
protected RelativeMetalsToBoard(allEntitys: Entity[], isUpDownDoor: boolean)
|
|
|
|
|
protected RelativeMetalsToBoard(allEntitys: Entity[], isUpDownDoor: boolean, doorSpaceSize: Vector3, spaceOCS: Matrix4)
|
|
|
|
|
{
|
|
|
|
|
let boards: Board[] = [];
|
|
|
|
|
let doors: Entity[] = [];
|
|
|
|
@ -584,14 +584,10 @@ export class DrawDoorTool
|
|
|
|
|
doors.push(en);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let scsInv = doors[0].SpaceOCSInv;
|
|
|
|
|
let doorBox = new Box3;
|
|
|
|
|
for (let door of doors)
|
|
|
|
|
doorBox.union(door.GetBoundingBoxInMtx(scsInv)); //获取门板空间盒子(在门板的空间坐标系中)
|
|
|
|
|
let scsInv = new Matrix4().getInverse(spaceOCS);
|
|
|
|
|
|
|
|
|
|
let doorSize = doorBox.getSize(new Vector3);
|
|
|
|
|
let doorWidth = doorSize.x;
|
|
|
|
|
let doorHight = doorSize.z;
|
|
|
|
|
const DoorSpaceWidth = doorSpaceSize.x;
|
|
|
|
|
const DoorSpaceHight = doorSpaceSize.z;
|
|
|
|
|
|
|
|
|
|
let moveFail = false;
|
|
|
|
|
let needUpdate = false;
|
|
|
|
@ -610,7 +606,8 @@ export class DrawDoorTool
|
|
|
|
|
const isHinge = IsHinge(ironware);
|
|
|
|
|
|
|
|
|
|
const XNormal = new Vector3().setFromMatrixColumn(ironware.OCSNoClone, 0);
|
|
|
|
|
const ZNormal = new Vector3().setFromMatrixColumn(ironware.OCSNoClone, 2);
|
|
|
|
|
//使用空间坐标系 左右开门时 向上为偏移正方向 上下开门时 向右为正方向
|
|
|
|
|
const ZNormal = new Vector3().setFromMatrixColumn(spaceOCS, isUpDownDoor ? 0 : 2);
|
|
|
|
|
|
|
|
|
|
for (let otherEnt of allOtherEntitys)
|
|
|
|
|
{
|
|
|
|
@ -667,12 +664,12 @@ export class DrawDoorTool
|
|
|
|
|
if (isUpDownDoor)
|
|
|
|
|
{
|
|
|
|
|
if (RecordHingeTrSizeX(hingeTr2Size_Map, hingeTr, size.x)) continue;
|
|
|
|
|
deviationNum = this.GetHingeMoveNum(doorWidth, ironBoxInDoorSpace, ironBox, ironware, verticalBoards, this.option.deviation, deviationNum, isUpDownDoor, ZNormal);
|
|
|
|
|
deviationNum = this.GetHingeMoveNum(DoorSpaceWidth, ironBoxInDoorSpace, ironBox, ironware, verticalBoards, this.option.deviation, deviationNum, isUpDownDoor, ZNormal);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (RecordHingeTrSizeX(hingeTr2Size_Map, hingeTr, size.z)) continue;
|
|
|
|
|
deviationNum = this.GetHingeMoveNum(doorHight, ironBoxInDoorSpace, ironBox, ironware, layerBoards, this.option.deviation, deviationNum, isUpDownDoor, ZNormal);
|
|
|
|
|
deviationNum = this.GetHingeMoveNum(DoorSpaceHight, ironBoxInDoorSpace, ironBox, ironware, layerBoards, this.option.deviation, deviationNum, isUpDownDoor, ZNormal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (deviationNum === 0)
|
|
|
|
@ -733,15 +730,13 @@ export class DrawDoorTool
|
|
|
|
|
let deviationNum = 1;
|
|
|
|
|
if (isUpDownDoor)
|
|
|
|
|
{
|
|
|
|
|
let doorWidth = doorBox.getSize(new Vector3).x;
|
|
|
|
|
if (RecordHingeTrSizeX(hingeTr2Size_Map, hingeTr, ironSize.x)) continue;
|
|
|
|
|
deviationNum = this.GetHingeMoveNum(doorWidth, ironBoxInDoorSpace, ironBox, ironware, verticalBoards, this.option.deviation, deviationNum, isUpDownDoor, ZNormal);
|
|
|
|
|
deviationNum = this.GetHingeMoveNum(DoorSpaceWidth, ironBoxInDoorSpace, ironBox, ironware, verticalBoards, this.option.deviation, deviationNum, isUpDownDoor, ZNormal);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
let doorHight = doorBox.getSize(new Vector3).z;
|
|
|
|
|
if (RecordHingeTrSizeX(hingeTr2Size_Map, hingeTr, ironSize.z)) continue;
|
|
|
|
|
deviationNum = this.GetHingeMoveNum(doorHight, ironBoxInDoorSpace, ironBox, ironware, layerBoards, this.option.deviation, deviationNum, isUpDownDoor, ZNormal);
|
|
|
|
|
deviationNum = this.GetHingeMoveNum(DoorSpaceHight, ironBoxInDoorSpace, ironBox, ironware, layerBoards, this.option.deviation, deviationNum, isUpDownDoor, ZNormal);
|
|
|
|
|
}
|
|
|
|
|
if (deviationNum === 0)
|
|
|
|
|
{
|
|
|
|
@ -929,7 +924,8 @@ export class DrawDoorTool
|
|
|
|
|
* @return {*} {number}
|
|
|
|
|
* @memberof DrawDoorTool
|
|
|
|
|
*/
|
|
|
|
|
private GetHingeMoveNum(doorSpecs: number, inventedBox: Box3, realityBox: Box3, ironware: Entity, checkEnts: Entity[], distance: number, deviationNum: number, isUpDownDoor: boolean, ZNormal: Vector3): number
|
|
|
|
|
private GetHingeMoveNum(doorSpecs: number, inventedBox: Box3, realityBox: Box3, ironware: Entity, checkEnts: Entity[],
|
|
|
|
|
distance: number, deviationNum: number, isUpDownDoor: boolean, ZNormal: Vector3): number
|
|
|
|
|
{
|
|
|
|
|
let box1 = inventedBox.clone();
|
|
|
|
|
let box1Info: number;
|
|
|
|
@ -952,6 +948,7 @@ export class DrawDoorTool
|
|
|
|
|
let intersect = false;
|
|
|
|
|
if (box1Info + (isUpDownDoor ? 10 : 100) < doorSpecs)
|
|
|
|
|
{
|
|
|
|
|
translate = ZNormal.clone().multiplyScalar(distance * deviationNum);
|
|
|
|
|
if (IsBoxAndEntitysIntersect(checkEnts, [ironware], ZNormal, false, translate))
|
|
|
|
|
intersect = true;
|
|
|
|
|
}
|
|
|
|
@ -986,6 +983,7 @@ export class DrawDoorTool
|
|
|
|
|
let intersect = false;
|
|
|
|
|
if (box2Info - (isUpDownDoor ? 10 : 100) > 0)
|
|
|
|
|
{
|
|
|
|
|
translate = ZNormal.clone().multiplyScalar(distance * -deviationNum);
|
|
|
|
|
if (IsBoxAndEntitysIntersect(checkEnts, [ironware], ZNormal, false, translate))
|
|
|
|
|
intersect = true;
|
|
|
|
|
}
|
|
|
|
@ -1137,44 +1135,42 @@ export function SetTypeHigneName(relativeDoors: Set<Entity>, allSpaceEnts: Entit
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取与铰链Z轴平行的向量
|
|
|
|
|
function GetNormalAddSize(normal: Vector3, xNormal: Vector3, yNormal: Vector3): Vector3
|
|
|
|
|
{
|
|
|
|
|
if (isParallelTo(normal, xNormal))
|
|
|
|
|
return new Vector3(10, -0.1, -0.1);
|
|
|
|
|
else if (isParallelTo(normal, yNormal))
|
|
|
|
|
return new Vector3(-0.1, 10, -0.1);
|
|
|
|
|
else
|
|
|
|
|
return new Vector3(-0.1, -0.1, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @export
|
|
|
|
|
* @param {OBB} obb
|
|
|
|
|
* @param {Vector3} normalizeZ
|
|
|
|
|
* @param {Matrix4} parentIntersectEntOCS
|
|
|
|
|
* @param {boolean} isExtrudeSolid
|
|
|
|
|
* @param {boolean} isSweepSolid
|
|
|
|
|
* @param {boolean} isDoor 门板类型不增加误差值
|
|
|
|
|
* @return {*} {OBB}
|
|
|
|
|
*/
|
|
|
|
|
export function getFuzzOBB(obb: OBB, normalizeZ: Vector3, parentIntersectEntOCS: Matrix4, isExtrudeSolid: boolean, isDoor: boolean): OBB
|
|
|
|
|
export function getFuzzOBB(obb: OBB, normalizeZ: Vector3, parentIntersectEntOCS: Matrix4, isSweepSolid: boolean, isDoor: boolean): OBB
|
|
|
|
|
{
|
|
|
|
|
let addSize = isDoor ? new Vector3() : new Vector3(-0.1, -0.1, 10);
|
|
|
|
|
if (!isExtrudeSolid)
|
|
|
|
|
addSize.applyMatrix4(parentIntersectEntOCS.clone().setPosition(0, 0, 0));
|
|
|
|
|
let halfSizes = obb.halfSizes.add(addSize.applyMatrix4((obb.ocs).clone().setPosition(0, 0, 0)));
|
|
|
|
|
let ocs = obb.ocs.clone();
|
|
|
|
|
let vz = normalizeZ.clone().multiplyScalar(10);
|
|
|
|
|
|
|
|
|
|
const XNormal = new Vector3().setFromMatrixColumn(ocs, 0).multiplyScalar(0.1);
|
|
|
|
|
const YNormal = new Vector3().setFromMatrixColumn(ocs, 1).multiplyScalar(0.1);
|
|
|
|
|
const ZNormal = new Vector3().setFromMatrixColumn(ocs, 2).multiplyScalar(0.1);
|
|
|
|
|
ocs.elements[12] += XNormal.x;
|
|
|
|
|
ocs.elements[13] += XNormal.y;
|
|
|
|
|
ocs.elements[14] += XNormal.z;
|
|
|
|
|
|
|
|
|
|
ocs.elements[12] += YNormal.x;
|
|
|
|
|
ocs.elements[13] += YNormal.y;
|
|
|
|
|
ocs.elements[14] += YNormal.z;
|
|
|
|
|
let addSize = isDoor ? new Vector3() : GetNormalAddSize(normalizeZ, XNormal, YNormal);
|
|
|
|
|
if (isSweepSolid)
|
|
|
|
|
addSize.applyMatrix4(parentIntersectEntOCS.clone().setPosition(0, 0, 0));
|
|
|
|
|
let halfSizes = obb.halfSizes.add(addSize);
|
|
|
|
|
|
|
|
|
|
ocs.elements[12] += ZNormal.x;
|
|
|
|
|
ocs.elements[13] += ZNormal.y;
|
|
|
|
|
ocs.elements[14] += ZNormal.z;
|
|
|
|
|
let vz = normalizeZ.clone().normalize().multiplyScalar(10);
|
|
|
|
|
|
|
|
|
|
ocs.elements[12] -= Math.abs(vz.x);
|
|
|
|
|
ocs.elements[13] -= Math.abs(vz.y);
|
|
|
|
|
ocs.elements[14] -= Math.abs(vz.z);
|
|
|
|
|
ocs.elements[12] -= vz.x;
|
|
|
|
|
ocs.elements[13] -= vz.y;
|
|
|
|
|
ocs.elements[14] -= vz.z;
|
|
|
|
|
|
|
|
|
|
return new OBB(ocs, halfSizes);
|
|
|
|
|
}
|
|
|
|
@ -1231,7 +1227,7 @@ export function IsBoxAndEntitysIntersect(checkEnts: Entity[], intersectEnts: Ent
|
|
|
|
|
if (translate) ent.ApplyMatrix(backTranslate);
|
|
|
|
|
if (parentIntersectEntOCS) ent.ApplyMatrix(backParentIntersectEntOCS);
|
|
|
|
|
|
|
|
|
|
let obb = getFuzzOBB(newCheckEnt.OBB, ZNormal, parentIntersectEntOCS, newCheckEnt instanceof ExtrudeSolid, isDoor);
|
|
|
|
|
let obb = getFuzzOBB(newCheckEnt.OBB, ZNormal, parentIntersectEntOCS, newCheckEnt instanceof SweepSolid, isDoor);
|
|
|
|
|
if (obb.intersectsOBB(entOBB))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|