!1460 优化:提高排钻性能

pull/1460/MERGE
ChenX 4 years ago
parent 9bde63536a
commit 2a0cdf3634

@ -612,7 +612,7 @@ export class DrawDrillingTool extends Singleton
{
let b1 = g.ContourCurve.BoundingBox;
b1.max.add(new Vector3(0, 0, g.Thickness));
const diffMat = ocsInv.clone().multiply(g.OCS);
const diffMat = ocsInv.clone().multiply(g.OCSNoClone);
b1.applyMatrix4(diffMat);
let isBoxInt = b1.intersectsBox(box);
let isRotate = !equaln(diffMat.elements[0], 1);
@ -765,7 +765,6 @@ export class DrawDrillingTool extends Singleton
}
private ParseHolesisThrough(ents: CylinderHole[] | ExtrudeHole[], refEnts: CylinderHole[] | ExtrudeHole[])
{
let nor = this.m_Face.LocalBoard.Normal;
for (let en of ents)
{
if (!en) continue;
@ -779,6 +778,8 @@ export class DrawDrillingTool extends Singleton
else
radius = en.Radius;
let enOcsInv = en.OCSInv;
for (let refEn of refEnts)
{
let refRadius: number;
@ -791,8 +792,8 @@ export class DrawDrillingTool extends Singleton
else
refRadius = refEn.Radius;
let p2 = refEn.Position.applyMatrix4(en.OCSInv);
let p2End = refEn.Position.add(refEn.Normal.multiplyScalar(refEn.Height)).applyMatrix4(en.OCSInv);
let p2 = refEn.Position.applyMatrix4(enOcsInv);
let p2End = refEn.Position.add(refEn.Normal.multiplyScalar(refEn.Height)).applyMatrix4(enOcsInv);
if (equaln(radius, refRadius, 1e-2)
&& isParallelTo(p2, ZAxis, 0.01)
@ -882,15 +883,16 @@ export class DrawDrillingTool extends Singleton
{
let isCollsion = false;
let faceOcsInv = this.m_Face.OCSInv;
for (let i = 0; i < drills.length; i++)
{
const ds = drills[i];
if (this.IsTk(ds)) continue;
let bs1 = this.GetDrillsBox(ds, this.m_Face.OCSInv);
let bs1 = this.GetDrillsBox(ds, faceOcsInv);
for (let refDr of refDrillList)
{
if (this.IsTk(refDr)) continue;
let bs2 = this.GetDrillsBox(refDr, this.m_Face.OCSInv);
let bs2 = this.GetDrillsBox(refDr, faceOcsInv);
//#I1FFNB
if (bs1.some(b => bs2.some(b2 => this.DrillIsCollsion(b, b2))))
{
@ -1104,7 +1106,7 @@ export class DrawDrillingTool extends Singleton
}
DrillIsCollsion(b1: Box3Ext, b2: Box3Ext)
{
if (b1.clone().intersect(b2).isSolid(1e-2))
if (b1.intersectsBox(b2, 1e-2))
{
if (b1.TempData && b2.TempData)
{
@ -1116,8 +1118,9 @@ export class DrawDrillingTool extends Singleton
{
if (!isParallelTo(h1.Normal, h2.Normal)) return true;
let p1 = h1.Position.applyMatrix4(h1.OCSInv).setZ(0);
let p2 = h2.Position.applyMatrix4(h1.OCSInv).setZ(0);
let ocsInv = h1.OCSInv;
let p1 = h1.Position.applyMatrix4(ocsInv).setZ(0);
let p2 = h2.Position.applyMatrix4(ocsInv).setZ(0);
let len = p1.distanceTo(p2);

@ -1,13 +1,14 @@
import { Box3, BufferGeometry, CylinderBufferGeometry, Float32BufferAttribute, LineSegments, Matrix4, Mesh, Object3D, Shape as TShape, Vector3, Matrix3 } from "three";
import { BufferGeometry, CylinderBufferGeometry, Float32BufferAttribute, LineSegments, Matrix3, Matrix4, Mesh, Object3D, Shape as TShape, Vector3 } from "three";
import { ColorMaterial } from '../../Common/ColorPalette';
import { DisposeThreeObj, Object3DRemoveAll } from '../../Common/Dispose';
import { FixIndex } from "../../Common/Utils";
import { ObjectSnapMode } from "../../Editor/ObjectSnapMode";
import { Box3Ext } from "../../Geometry/Box";
import { RenderType } from "../../GraphicsSystem/RenderType";
import { Factory, CADFactory } from '../CADFactory';
import { CADFactory, Factory } from '../CADFactory';
import { CADFiler } from '../CADFiler';
import { Hole } from "./Hole";
import { ObjectSnapMode } from "../../Editor/ObjectSnapMode";
import { Circle } from "../Entity/Circle";
import { Hole } from "./Hole";
export enum GangDrillType
{
@ -90,9 +91,17 @@ export class CylinderHole extends Hole
}
get BoundingBox()
{
let box = new Box3(new Vector3(-this._Radius, -this._Radius, 0), new Vector3(this._Radius, this._Radius, this._Height));
return box.applyMatrix4(this.OCS);
return this.BoundingBoxInOCS.applyMatrix4(this._Matrix);
}
/**
* Box
*/
get BoundingBoxInOCS(): Box3Ext
{
return new Box3Ext(new Vector3(-this._Radius, -this._Radius, 0), new Vector3(this._Radius, this._Radius, this._Height));
}
private _MeshGeometry: CylinderBufferGeometry;
get MeshGeometry()
{

Loading…
Cancel
Save