Skip to content
Snippets Groups Projects
Commit ead25d6a authored by Alexander Rose's avatar Alexander Rose
Browse files

tweak BoundaryHelper performance

parent 55f4abb6
No related branches found
No related tags found
No related merge requests found
/** /**
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2020-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
...@@ -13,6 +13,7 @@ import { Box3D } from './primitives/box3d'; ...@@ -13,6 +13,7 @@ import { Box3D } from './primitives/box3d';
export class BoundaryHelper { export class BoundaryHelper {
private dir: Vec3[]; private dir: Vec3[];
private dirLength: number;
private minDist: number[] = []; private minDist: number[] = [];
private maxDist: number[] = []; private maxDist: number[] = [];
...@@ -56,13 +57,13 @@ export class BoundaryHelper { ...@@ -56,13 +57,13 @@ export class BoundaryHelper {
} }
includePosition(p: Vec3) { includePosition(p: Vec3) {
for (let i = 0, il = this.dir.length; i < il; ++i) { for (let i = 0; i < this.dirLength; ++i) {
this.computeExtrema(i, p); this.computeExtrema(i, p);
} }
} }
includePositionRadius(center: Vec3, radius: number) { includePositionRadius(center: Vec3, radius: number) {
for (let i = 0, il = this.dir.length; i < il; ++i) { for (let i = 0; i < this.dirLength; ++i) {
this.computeSphereExtrema(i, center, radius); this.computeSphereExtrema(i, center, radius);
} }
} }
...@@ -101,7 +102,7 @@ export class BoundaryHelper { ...@@ -101,7 +102,7 @@ export class BoundaryHelper {
} }
reset() { reset() {
for (let i = 0, il = this.dir.length; i < il; ++i) { for (let i = 0; i < this.dirLength; ++i) {
this.minDist[i] = Infinity; this.minDist[i] = Infinity;
this.maxDist[i] = -Infinity; this.maxDist[i] = -Infinity;
this.extrema[i * 2] = Vec3(); this.extrema[i * 2] = Vec3();
...@@ -112,6 +113,7 @@ export class BoundaryHelper { ...@@ -112,6 +113,7 @@ export class BoundaryHelper {
constructor(quality: EposQuality) { constructor(quality: EposQuality) {
this.dir = getEposDir(quality); this.dir = getEposDir(quality);
this.dirLength = this.dir.length;
this.reset(); this.reset();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment