Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Z scaling #937

Merged
merged 25 commits into from Mar 25, 2021
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2a001a6
modify model transform keyin to take scaling
MarcNeely Feb 11, 2021
581a421
test
MarcNeely Mar 10, 2021
5a41d6b
fix instancing
MarcNeely Mar 10, 2021
17374c1
Compare forceNoInstancing
pmconne Mar 10, 2021
26f9e49
restore deleted property.
pmconne Mar 10, 2021
48e2f41
Remove unnecessary invalidateScene and requestRedraw calls.
pmconne Mar 10, 2021
e4c3ac1
Cleanup & make work nicer with Z offset
MarcNeely Mar 12, 2021
5a5b2d9
fix rgb axes in measure distance tool
MarcNeely Mar 12, 2021
a742f67
Merge branch 'z-scaling' of https://github.com/imodeljs/imodeljs into…
MarcNeely Mar 12, 2021
023c1fc
Remove debug
MarcNeely Mar 15, 2021
8e2638d
lint & typo
MarcNeely Mar 18, 2021
567b7fe
Merge branch 'master' into z-scaling
MarcNeely Mar 22, 2021
f09107e
Merge branch 'master' into z-scaling
mergify[bot] Mar 22, 2021
1aa841e
Modify tessellation for nonuniform scaling
MarcNeely Mar 22, 2021
9d3b718
Merge branch 'z-scaling' of https://github.com/imodeljs/imodeljs into…
MarcNeely Mar 22, 2021
dbc6969
rush change
MarcNeely Mar 22, 2021
325b952
extract-api
MarcNeely Mar 22, 2021
dbce0b4
Replace use of System.instance with IModelApp.rSys
MarcNeely Mar 23, 2021
2609c68
move scaleFactor calc to TileDrawArgs constructor
MarcNeely Mar 23, 2021
1e78608
Merge branch 'master' into z-scaling
pmconne Mar 25, 2021
a8b328c
Merge branch 'master' into z-scaling
mergify[bot] Mar 25, 2021
b033c23
Merge branch 'master' into z-scaling
mergify[bot] Mar 25, 2021
ba5928b
Merge branch 'master' into z-scaling
mergify[bot] Mar 25, 2021
d071d13
Merge branch 'master' into z-scaling
mergify[bot] Mar 25, 2021
015c99d
Merge branch 'master' into z-scaling
mergify[bot] Mar 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 31 additions & 2 deletions core/frontend/src/tile/Tile.ts
Expand Up @@ -7,7 +7,7 @@
*/

import { assert, dispose } from "@bentley/bentleyjs-core";
import { Arc3d, ClipPlaneContainment, Matrix4d, Point2d, Point3d, Point4d, Range3d, Transform, Vector3d } from "@bentley/geometry-core";
import { Arc3d, ClipPlaneContainment, Geometry, Matrix4d, Point2d, Point3d, Point4d, Range3d, Transform, Vector3d } from "@bentley/geometry-core";
import { BoundingSphere, ColorDef, ElementAlignedBox3d, Frustum, FrustumPlanes } from "@bentley/imodeljs-common";
import { IModelApp } from "../IModelApp";
import { IModelConnection } from "../IModelConnection";
Expand Down Expand Up @@ -400,6 +400,34 @@ export abstract class Tile {
return false;
}

private computePixelSizeScaleFactor(args: TileDrawArgs): number {
// Check to see if a model display transform with non-uniform scaling is being used.
const tf = args.context.viewport.view.getModelDisplayTransform(args.tree.modelId, Transform.createIdentity());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to obtain the model display transform vs just pulling the scale out of the TileDrawArgs' transform?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it this way to just pull out the model display transform rather than looking at the full model to world transform which may have other scaling in it.

const scale = [];
scale[0] = tf.matrix.getColumn(0).magnitude();
scale[1] = tf.matrix.getColumn(1).magnitude();
scale[2] = tf.matrix.getColumn(2).magnitude();
if (Math.abs(scale[0] - scale[1]) <= Geometry.smallMetricDistance && Math.abs(scale[0] - scale[2]) <= Geometry.smallMetricDistance)
return 1;
// If the component with the largest scale is not the same as the component with the largest tile range use it to adjust the pixel size.
const rangeDiag = args.tree.range.diagonal();
let maxS = 0;
let maxR = 0;
if (scale[0] > scale[1]) {
maxS = (scale[0] > scale[2] ? 0 : 2);
} else {
maxS = (scale[1] > scale[2] ? 1 : 2);
}
if (rangeDiag.x > rangeDiag.y) {
maxR = (rangeDiag.x > rangeDiag.z ? 0 : 2);
} else {
maxR = (rangeDiag.y > rangeDiag.z ? 1 : 2);
}
if (maxS !== maxR)
return scale[maxS];
return 1;
}

/** Determine the visibility of this tile according to the specified args. */
public computeVisibility(args: TileDrawArgs): TileVisibility {
// NB: We test for region culling before isDisplayable - otherwise we will never unload children of undisplayed tiles when
Expand All @@ -418,7 +446,8 @@ export abstract class Tile {
return TileVisibility.Visible;
}

const pixelSize = args.getPixelSize(this);
const scale = this.computePixelSizeScaleFactor(args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you avoid computing this for every tile by, e.g., computing in TileDrawArgs constructor and storing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I was wondering if I should do something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const pixelSize = args.getPixelSize(this) * scale;
const maxSize = this.maximumSize * args.tileSizeModifier;

return pixelSize > maxSize ? TileVisibility.TooCoarse : TileVisibility.Visible;
Expand Down