!2524 优化:画多个门板配铰链时卡顿较大问题

pull/2423/MERGE
林三 7 months ago committed by ChenX
parent 62d9041b27
commit 6bf73a5a87

@ -609,13 +609,16 @@ export class DrawDoorTool
const isHandle = IsHandle(ironware); const isHandle = IsHandle(ironware);
const isHinge = IsHinge(ironware); const isHinge = IsHinge(ironware);
const xNormal = new Vector3().setFromMatrixColumn(ironware.OCSNoClone, 0); const XNormal = new Vector3().setFromMatrixColumn(ironware.OCSNoClone, 0);
const ZNormal = new Vector3().setFromMatrixColumn(ironware.OCSNoClone, 2); const ZNormal = new Vector3().setFromMatrixColumn(ironware.OCSNoClone, 2);
for (let otherEnt of allOtherEntitys) for (let otherEnt of allOtherEntitys)
{ {
const isDoor = IsDoor(otherEnt); const isDoor = IsDoor(otherEnt);
//是把手时 不是门板跳过
if (isHandle && !isDoor) continue;
if (otherEnt instanceof Board) if (otherEnt instanceof Board)
{ {
let br = otherEnt as Board; let br = otherEnt as Board;
@ -645,7 +648,7 @@ export class DrawDoorTool
//铰链避让 //铰链避让
if (this.hingeSet.has(ironware.Id))//如果是铰链 if (this.hingeSet.has(ironware.Id))//如果是铰链
{ {
if (isParallelTo(xNormal, br.Normal)) if (isParallelTo(XNormal, br.Normal))
{ {
if (!parseTypedHinges.has(ironware.Id)) if (!parseTypedHinges.has(ironware.Id))
{ {
@ -1197,27 +1200,39 @@ export function IsBoxAndEntitysIntersect(checkEnts: Entity[], intersectEnts: Ent
} }
else else
{ {
let newCheckEnt = checkEnt.Clone() as Solid3D; let newCheckEnt = checkEnt as Solid3D;
if (parentcheckEntOCS) newCheckEnt.ApplyMatrix(parentcheckEntOCS); if (parentcheckEntOCS)
{
newCheckEnt = newCheckEnt.Clone();
newCheckEnt.ApplyMatrix(parentcheckEntOCS);
}
let backParentIntersectEntOCS = new Matrix4().getInverse(parentIntersectEntOCS ?? new Matrix4);
let backTranslate = new Matrix4().setPosition(translate?.clone()?.negate() ?? new Vector3);
for (let intersectEnt of intersectEnts) for (let intersectEnt of intersectEnts)
{ {
if (intersectEnt instanceof HardwareCompositeEntity) if (intersectEnt instanceof HardwareCompositeEntity)
{ {
let ocs = intersectEnt.OCS; let ocs = intersectEnt.OCS;
if (parentIntersectEntOCS) ocs = new Matrix4().multiplyMatrices(parentIntersectEntOCS, ocs); if (parentIntersectEntOCS)
ocs = new Matrix4().multiplyMatrices(parentIntersectEntOCS, ocs);
let ents = intersectEnt.Entitys.filter(ent => ent instanceof ExtrudeHole || ent instanceof SweepSolid || ent instanceof ExtrudeSolid || ent instanceof HardwareCompositeEntity); let ents = intersectEnt.Entitys.filter(ent => ent instanceof ExtrudeHole || ent instanceof SweepSolid || ent instanceof ExtrudeSolid || ent instanceof HardwareCompositeEntity);
if (IsBoxAndEntitysIntersect([newCheckEnt], ents, ZNormal, isDoor, translate, ocs)) if (IsBoxAndEntitysIntersect([newCheckEnt], ents, ZNormal, isDoor, translate, ocs))
return true; return true;
} }
else else
{ {
let ent = intersectEnt.Clone() as Solid3D; let ent = intersectEnt as Solid3D;
if (parentIntersectEntOCS) ent.ApplyMatrix(parentIntersectEntOCS); if (parentIntersectEntOCS) ent.ApplyMatrix(parentIntersectEntOCS);
if (translate) ent.ApplyMatrix(new Matrix4().setPosition(translate)); if (translate) ent.ApplyMatrix(new Matrix4().setPosition(translate));
let entOBB = ent.OBB;
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 ExtrudeSolid, isDoor);
if (obb.intersectsOBB(ent.OBB)) if (obb.intersectsOBB(entOBB))
return true; return true;
} }
} }

Loading…
Cancel
Save