优化:网洞的盒子

pull/1916/MERGE
ChenX 2 years ago
parent 12508396f4
commit d1258b5b49

@ -4,7 +4,7 @@ import { ColorMaterial } from "../../../../../Common/ColorPalette";
import { ObjectSnapMode } from "../../../../../Editor/ObjectSnapMode"; import { ObjectSnapMode } from "../../../../../Editor/ObjectSnapMode";
import { Box3Ext } from "../../../../../Geometry/Box"; import { Box3Ext } from "../../../../../Geometry/Box";
import { CreatePolylinePath } from "../../../../../Geometry/CreatePolylinePath"; import { CreatePolylinePath } from "../../../../../Geometry/CreatePolylinePath";
import { AsVector3, equalv2 } from "../../../../../Geometry/GeUtils"; import { AsVector3, equalv2, ZAxis } from "../../../../../Geometry/GeUtils";
import { RenderType } from "../../../../../GraphicsSystem/RenderType"; import { RenderType } from "../../../../../GraphicsSystem/RenderType";
import { Factory } from "../../../../CADFactory"; import { Factory } from "../../../../CADFactory";
import { CADFiler } from "../../../../CADFiler"; import { CADFiler } from "../../../../CADFiler";
@ -14,6 +14,7 @@ import { Line } from "../../../../Entity/Line";
import { Polyline } from "../../../../Entity/Polyline"; import { Polyline } from "../../../../Entity/Polyline";
import { CreateGetCurveParam, GetLineParam } from "../../../ParseService/GetCurveParam"; import { CreateGetCurveParam, GetLineParam } from "../../../ParseService/GetCurveParam";
import { RoomWallBase } from "../RoomWallBase"; import { RoomWallBase } from "../RoomWallBase";
import { RoomWallLine } from "../RoomWallLine";
import { RoomHoleBase } from "./RoomHoleBase"; import { RoomHoleBase } from "./RoomHoleBase";
enum HoleType enum HoleType
@ -44,6 +45,9 @@ export class RoomHolePolyline extends RoomHoleBase
this.Regions.push(w.Region); this.Regions.push(w.Region);
w.OCSNoClone.elements[14] = this._Matrix.elements[14]; w.OCSNoClone.elements[14] = this._Matrix.elements[14];
w.Height = this.Height; w.Height = this.Height;
if (w instanceof RoomWallLine)
w.UpdateOCSToMinBox();
} }
} }
get FakerWalls(): RoomWallBase[] { return this._FakerWalls; } get FakerWalls(): RoomWallBase[] { return this._FakerWalls; }
@ -52,6 +56,11 @@ export class RoomHolePolyline extends RoomHoleBase
override get BoundingBoxInOCS(): Box3Ext override get BoundingBoxInOCS(): Box3Ext
{ {
let box = new Box3Ext;
let inv = this.OCSInv;
for (let w of this._FakerWalls)
box.union(w.GetBoundingBoxInMtx(inv));
return box;
return new Box3Ext().copy(this.BoundingBox).applyMatrix4(this.OCSInv); return new Box3Ext().copy(this.BoundingBox).applyMatrix4(this.OCSInv);
} }
@ -93,15 +102,28 @@ export class RoomHolePolyline extends RoomHoleBase
//使用FakerWalls来更新这个洞的信息 //使用FakerWalls来更新这个洞的信息
UpdatePoints() UpdatePoints()
{ {
let ocsInv = this.OCSInv;
let pts: Vector3[] = []; let pts: Vector3[] = [];
for (let w of this._FakerWalls) for (let w of this._FakerWalls)
pts.push(w.StartPoint.applyMatrix4(ocsInv)); pts.push(w.StartPoint);
if (this._FakerWalls.length) if (this._FakerWalls.length)
pts.push(this._FakerWalls[this._FakerWalls.length - 1].EndPoint.applyMatrix4(ocsInv)); pts.push(this._FakerWalls[this._FakerWalls.length - 1].EndPoint);
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();
if (pts.length === 2)
{
let x = pts[1].clone().sub(pts[0]).normalize();
let z = ZAxis;
let y = z.clone().cross(x).normalize();
this._Matrix.makeBasis(x, y, z).setPosition(pts[0]);
}
else
this._Matrix.setPosition(pts[1]);
let ocsInv = this.OCSInv;
for (let p of pts) p.applyMatrix4(ocsInv);
this._Points = pts; this._Points = pts;
this.Update(); this.Update();
} }

@ -5,7 +5,7 @@ import { EntityUpdateWrap } from "../../../../Common/EntityUpdateWrap";
import { ObjectSnapMode } from "../../../../Editor/ObjectSnapMode"; import { ObjectSnapMode } from "../../../../Editor/ObjectSnapMode";
import { Box3Ext } from "../../../../Geometry/Box"; import { Box3Ext } from "../../../../Geometry/Box";
import { BufferGeometryUtils } from "../../../../Geometry/BufferGeometryUtils"; import { BufferGeometryUtils } from "../../../../Geometry/BufferGeometryUtils";
import { equaln, equalv3, midPoint, MoveMatrix, ZeroVec } from "../../../../Geometry/GeUtils"; import { equaln, equalv3, midPoint, MoveMatrix, ZAxis, ZeroVec } from "../../../../Geometry/GeUtils";
import { RenderType } from "../../../../GraphicsSystem/RenderType"; import { RenderType } from "../../../../GraphicsSystem/RenderType";
import { SubtractRange, Tape } from "../../../../ueapi"; import { SubtractRange, Tape } from "../../../../ueapi";
import { Factory } from "../../../CADFactory"; import { Factory } from "../../../CADFactory";
@ -32,6 +32,22 @@ export class RoomWallLine extends RoomWallBase
this.Thickness = _Thickness; this.Thickness = _Thickness;
} }
UpdateOCSToMinBox()
{
this.WriteAllObjectRecord();
let sp = this.StartPoint;
let ep = this.EndPoint;
let x = this.GetFistDeriv(0).normalize();
let z = ZAxis;
let y = z.clone().cross(x).normalize();
this._Matrix.makeBasis(x, y, z).setPosition(sp);
let inv = this.OCSInv;
this._StartPoint.copy(sp).applyMatrix4(inv);
this._EndPoint.copy(ep).applyMatrix4(inv);
}
get StartPoint(): Vector3 get StartPoint(): Vector3
{ {
return this._StartPoint.clone().applyMatrix4(this.OCSNoClone); return this._StartPoint.clone().applyMatrix4(this.OCSNoClone);
@ -96,6 +112,8 @@ export class RoomWallLine extends RoomWallBase
let p3 = parse.OffsetPoint(this._EndPoint.clone(), this.Thickness * 0.5);//left let p3 = parse.OffsetPoint(this._EndPoint.clone(), this.Thickness * 0.5);//left
let p4 = parse.OffsetPoint(this._EndPoint.clone(), this.Thickness * -0.5);//right let p4 = parse.OffsetPoint(this._EndPoint.clone(), this.Thickness * -0.5);//right
p1.z = this._Height;
return new Box3Ext().setFromPoints([p1, p2, p3, p4]); return new Box3Ext().setFromPoints([p1, p2, p3, p4]);
} }

Loading…
Cancel
Save