Skip to content

Commit

Permalink
improvement: remove computeBoundingBox for shapes for now
Browse files Browse the repository at this point in the history
They'll be back for the acceleration structure
  • Loading branch information
haakonflatval-cognite committed May 30, 2022
1 parent df7821a commit ba0b9cf
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 42 deletions.
6 changes: 1 addition & 5 deletions viewer/packages/pointclouds/src/styling/shapes/Box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { ShapeType } from './IRawShape';
import { IShape } from './IShape';
import { AABB, m4MultiplyV3WithTranslation, Mat4, Vec3 } from './linalg';
import { m4MultiplyV3WithTranslation, Mat4, Vec3 } from './linalg';

export type RawBox = {
type: ShapeType.Box;
Expand All @@ -18,10 +18,6 @@ export class Box implements IShape {
this.invMatrix = invertedInstanceMatrix;
}

computeBoundingBox(): AABB {
throw Error('Bounding box not implemented for box primitive');
}

containsPoint(point: Vec3): boolean {
const transformedPoint = m4MultiplyV3WithTranslation(this.invMatrix, point);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { IShape } from './IShape';
import { IRawShape, ShapeType } from './IRawShape';

import { Vec3, AABB, b3Union, emptyBox3 } from './linalg';
import { Vec3 } from './linalg';

export type RawCompositeShape = {
type: ShapeType.Composite;
Expand All @@ -19,14 +19,6 @@ export class CompositeShape implements IShape {
this._innerShapes = shapes.slice();
}

computeBoundingBox(): AABB {
const totalBoundingBox = this._innerShapes.reduce(
(newBox, shape) => b3Union(newBox, shape.computeBoundingBox()),
emptyBox3()
);
return totalBoundingBox;
}

containsPoint(point: Vec3): boolean {
for (const shape of this._innerShapes) {
if (shape.containsPoint(point)) {
Expand Down
22 changes: 1 addition & 21 deletions viewer/packages/pointclouds/src/styling/shapes/Cylinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { ShapeType } from './IRawShape';
import { IShape } from './IShape';

import { Vec3, v3Scale, v3Middle, v3Length, v3Sub, v3Normalized, v3Dot, AABB } from './linalg';
import { Vec3, v3Scale, v3Middle, v3Length, v3Sub, v3Normalized, v3Dot } from './linalg';

export type RawCylinder = {
type: ShapeType.Cylinder;
Expand Down Expand Up @@ -49,26 +49,6 @@ export class Cylinder implements IShape {
return v3Normalized(v3Sub(this._centerA, this._centerB));
}

computeBoundingBox(): AABB {
/* const halfHeight = this.getHalfHeight();
const middle = this.getMiddle();
out.set(
utilVector.clone().set(-this._radius, -halfHeight, -this._radius),
utilVector.set(this._radius, halfHeight, this._radius)
);
const rotation = new THREE.Quaternion().setFromUnitVectors(
new THREE.Vector3(0.0, 1.0, 0.0),
utilVector.copy(this._centerA).sub(this._centerB).normalize()
);
out.applyMatrix4(new THREE.Matrix4().makeRotationFromQuaternion(rotation));
out.translate(middle);
return out; */
throw Error('[Cylinder] Bounding box not yet implemented');
}

containsPoint(point: Vec3): boolean {
const halfHeight = this.getHalfHeight();
const middle = this.getMiddle();
Expand Down
8 changes: 1 addition & 7 deletions viewer/packages/pointclouds/src/styling/shapes/IShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@

import { IRawShape } from './IRawShape';

import { Vec3, AABB } from './linalg';
import { Vec3 } from './linalg';

export interface IShape {
/**
* Returns a bounding box containing the shape.
* May be just a crude approximation, but is guaranteed to contain the entire shape
*/
computeBoundingBox(): AABB;

containsPoint(point: Vec3): boolean;

toRawShape(): IRawShape;
Expand Down

0 comments on commit ba0b9cf

Please sign in to comment.