Skip to content

Commit 4cacea8

Browse files
authored
Fix photostudio's distance calculation formula (#5759)
* Fix photostudio's distance calculation formula * Adjust a constant to compensate for the formula change * Calculate a proper value for the constant (rounded to 1.5 from 1.539)
1 parent fde2a5a commit 4cacea8

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

simulation_parameters/Constants.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ public static class Constants
15581558

15591559
public const float PHOTO_STUDIO_CAMERA_FOV = 70;
15601560
public const float PHOTO_STUDIO_CAMERA_HALF_ANGLE = PHOTO_STUDIO_CAMERA_FOV / 2.0f;
1561-
public const float PHOTO_STUDIO_CELL_RADIUS_MULTIPLIER = 0.80f;
1561+
public const float PHOTO_STUDIO_CELL_RADIUS_MULTIPLIER = 1.50f;
15621562

15631563
public const int RESOURCE_LOAD_TARGET_MIN_FPS = 60;
15641564
public const float RESOURCE_TIME_BUDGET_PER_FRAME = 1.0f / RESOURCE_LOAD_TARGET_MIN_FPS;

src/engine/PhotoStudio.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,9 @@ public static float CameraDistanceFromRadiusOfObject(float radius)
103103
if (radius <= 0)
104104
throw new ArgumentException("radius needs to be over 0");
105105

106-
// TODO: figure out if the camera FOV or FOV / 2 is the right thing to use here
107-
float angle = Constants.PHOTO_STUDIO_CAMERA_FOV;
106+
float angle = Constants.PHOTO_STUDIO_CAMERA_HALF_ANGLE;
108107

109-
// Some right angle triangle math that's hopefully right
110-
return MathF.Tan(MathUtils.DEGREES_TO_RADIANS * angle) * radius;
108+
return MathF.Tan(MathF.PI * 0.5f - MathUtils.DEGREES_TO_RADIANS * angle) * radius;
111109
}
112110

113111
public override void _Ready()

0 commit comments

Comments
 (0)