-
Notifications
You must be signed in to change notification settings - Fork 208
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
Z scaling #937
Changes from 1 commit
2a001a6
581a421
5a41d6b
17374c1
26f9e49
48e2f41
e4c3ac1
5a5b2d9
a742f67
023c1fc
8e2638d
567b7fe
f09107e
1aa841e
9d3b718
dbc6969
325b952
dbce0b4
2609c68
1e78608
a8b328c
b033c23
ba5928b
d071d13
015c99d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
|
@@ -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()); | ||
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 | ||
|
@@ -418,7 +446,8 @@ export abstract class Tile { | |
return TileVisibility.Visible; | ||
} | ||
|
||
const pixelSize = args.getPixelSize(this); | ||
const scale = this.computePixelSizeScaleFactor(args); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I was wondering if I should do something like that. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.