Skip to content

Commit

Permalink
Increase a bit range for orthographic projection near/far, to be sure
Browse files Browse the repository at this point in the history
to include stuff at the edge
  • Loading branch information
michaliskambi committed Aug 13, 2022
1 parent 0f9b8b2 commit 4f7d901
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/transform/castletransform_camera.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,11 @@ function TCastleCamera.InternalProjection(const BoxEvent: TBox3DEvent; const Vie
Box := BoxEvent();
GetWorldView(Pos, Dir, Up);
Box.DirectionDistances(Pos, Dir, MinBoxDistance, MaxBoxDistance);
{ Multiply by 1.1, just to make it a bit larger to avoid imprecision at max depth }
MaxBoxDistance := MaxBoxDistance * 1.1;
{ Make the range MinBoxDistance...MaxBoxDistance slightly larger,
to avoid cutting things due to imprecision when they lie exactly on the min/max distance.
Testcase: trees in isometric_game when observer sprite has Exists=false. }
MinBoxDistance := MinBoxDistance - 1;
MaxBoxDistance := (MaxBoxDistance + 1) * 1.1;
end;

var
Expand Down Expand Up @@ -1301,13 +1304,13 @@ begin
{
WritelnLogMultiline('Projection', Format(
'ProjectionType: %s' + NL +
'Perspective Field of View (in degrees): %f x %f' + NL +
'Perspective Field of View (Angles in degrees): %f x %f' + NL +
'Orthographic Dimensions: %s' + NL +
'Near: %f' + NL +
'Far: %f', [
ProjectionTypeToStr(Result.ProjectionType),
Result.PerspectiveAngles.X,
Result.PerspectiveAngles.Y,
RadToDeg(Result.PerspectiveAnglesRad.X),
RadToDeg(Result.PerspectiveAnglesRad.Y),
Result.Dimensions.ToString,
Result.ProjectionNear,
Result.ProjectionFar
Expand Down

0 comments on commit 4f7d901

Please sign in to comment.