* calculate fov against max of 3D viewport width, height for consistency
This commit is contained in:
parent
3bb51ba6b9
commit
6e42edd1cb
|
|
@ -215,8 +215,13 @@ const float camera_t::near_z = 1.f;
|
|||
camera_draw_mode camera_t::draw_mode = cd_texture;
|
||||
|
||||
inline Matrix4 projection_for_camera( float near_z, float far_z, float fieldOfView, int width, int height ){
|
||||
const float half_width = static_cast<float>( near_z * tan( degrees_to_radians( fieldOfView * 0.5 ) ) );
|
||||
const float half_height = half_width * ( static_cast<float>( height ) / static_cast<float>( width ) );
|
||||
float half_width = static_cast<float>( near_z * tan( degrees_to_radians( fieldOfView * 0.5 ) ) );
|
||||
const bool swap = height > width;
|
||||
if( swap )
|
||||
std::swap( width, height );
|
||||
float half_height = half_width * ( static_cast<float>( height ) / static_cast<float>( width ) );
|
||||
if( swap )
|
||||
std::swap( half_width, half_height );
|
||||
|
||||
return matrix4_frustum(
|
||||
-half_width,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user