|
@@ -89,23 +89,7 @@ class Mesh extends Object {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- var absPos = getAbsPos();
|
|
|
|
- var worldCenter = absPos.getPosition();
|
|
|
|
- var worldScale = absPos.getScale();
|
|
|
|
- var worldRadius = bounds.dimension() * hxd.Math.max( worldScale.x, hxd.Math.max(worldScale.y, worldScale.z) ) / 2.0;
|
|
|
|
-
|
|
|
|
- var cameraRight = ctx.camera.getRight();
|
|
|
|
- var cameraUp = ctx.camera.getUp();
|
|
|
|
- var cameraTopLeft = (cameraUp - cameraRight).normalized();
|
|
|
|
- var worldTopLeft = worldCenter + cameraTopLeft * worldRadius;
|
|
|
|
- var worldBottomRight = worldCenter - cameraTopLeft * worldRadius;
|
|
|
|
-
|
|
|
|
- var screenTopLeft = ctx.camera.projectInline( worldTopLeft.x, worldTopLeft.y, worldTopLeft.z, 1.0, 1.0, false );
|
|
|
|
- var screenBottomRight = ctx.camera.projectInline( worldBottomRight.x, worldBottomRight.y, worldBottomRight.z, 1.0, 1.0, false );
|
|
|
|
-
|
|
|
|
- var screenArea = hxd.Math.max( screenBottomRight.x - screenTopLeft.x, screenBottomRight.y - screenTopLeft.y );
|
|
|
|
-
|
|
|
|
- curScreenRatio = screenArea * screenArea;
|
|
|
|
|
|
+ curScreenRatio = screenRatio(getAbsPos(), bounds, ctx.camera);
|
|
|
|
|
|
if ( inheritLod )
|
|
if ( inheritLod )
|
|
ctx.forcedScreenRatio = curScreenRatio;
|
|
ctx.forcedScreenRatio = curScreenRatio;
|
|
@@ -148,4 +132,22 @@ class Mesh extends Object {
|
|
return this.primitive = prim;
|
|
return this.primitive = prim;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static function screenRatio(absPos : h3d.Matrix, bounds : h3d.col.Bounds, camera : h3d.Camera) {
|
|
|
|
+ var worldCenter = absPos.getPosition();
|
|
|
|
+ var worldScale = absPos.getScale();
|
|
|
|
+ var worldRadius = bounds.dimension() * hxd.Math.max( worldScale.x, hxd.Math.max(worldScale.y, worldScale.z) ) / 2.0;
|
|
|
|
+
|
|
|
|
+ var cameraRight = camera.getRight();
|
|
|
|
+ var cameraUp = camera.getUp();
|
|
|
|
+ var cameraTopLeft = (cameraUp - cameraRight).normalized();
|
|
|
|
+ var worldTopLeft = worldCenter + cameraTopLeft * worldRadius;
|
|
|
|
+ var worldBottomRight = worldCenter - cameraTopLeft * worldRadius;
|
|
|
|
+
|
|
|
|
+ var screenTopLeft = camera.projectInline( worldTopLeft.x, worldTopLeft.y, worldTopLeft.z, 1.0, 1.0, false );
|
|
|
|
+ var screenBottomRight = camera.projectInline( worldBottomRight.x, worldBottomRight.y, worldBottomRight.z, 1.0, 1.0, false );
|
|
|
|
+
|
|
|
|
+ var screenArea = hxd.Math.max( screenBottomRight.x - screenTopLeft.x, screenBottomRight.y - screenTopLeft.y );
|
|
|
|
+
|
|
|
|
+ return screenArea * screenArea;
|
|
|
|
+ }
|
|
}
|
|
}
|