@@ -405,32 +405,32 @@ real_t Projection::get_z_far() const {
405405 // NOTE: This assumes z-facing near and far planes, i.e. that :
406406 // - the matrix is a projection across z-axis (i.e. is invertible and columns[0][1], [0][3], [1][0] and [1][3] == 0)
407407 // - near and far planes are z-facing (i.e. columns[0][2] and [1][2] == 0)
408- return ( columns[3 ][3 ] - columns[3 ][2 ]) / (columns[2 ][3 ] - columns[2 ][2 ]);
408+ return Math::abs (( columns[3 ][3 ] + Math::abs ( columns[3 ][2 ])) / (columns[2 ][3 ] + Math::abs ( columns[2 ][2 ])) );
409409}
410410
411411real_t Projection::get_z_near () const {
412412 // NOTE: This assumes z-facing near and far planes, i.e. that :
413413 // - the matrix is a projection across z-axis (i.e. is invertible and columns[0][1], [0][3], [1][0] and [1][3] == 0)
414414 // - near and far planes are z-facing (i.e. columns[0][2] and [1][2] == 0)
415- return ( columns[3 ][3 ] + columns[3 ][2 ]) / (columns[2 ][3 ] + columns[2 ][2 ]);
415+ return Math::abs (( columns[3 ][3 ] - Math::abs ( columns[3 ][2 ])) / (columns[2 ][3 ] - Math::abs ( columns[2 ][2 ])) );
416416}
417417
418418Vector2 Projection::get_viewport_half_extents () const {
419419 // NOTE: This assumes a symmetrical frustum, i.e. that :
420420 // - the matrix is a projection across z-axis (i.e. is invertible and columns[0][1], [0][3], [1][0] and [1][3] == 0)
421421 // - the projection plane is rectangular (i.e. columns[0][2] and [1][2] == 0 if columns[2][3] != 0)
422422 // - there is no offset / skew (i.e. columns[2][0] == columns[2][1] == 0)
423- real_t w = - get_z_near () * columns[2 ][3 ] + columns[3 ][3 ];
424- return Vector2 (w / columns[0 ][0 ], w / columns[1 ][1 ]);
423+ real_t w = get_z_near () * Math::abs ( columns[2 ][3 ]) + columns[3 ][3 ];
424+ return Vector2 (w / columns[0 ][0 ], w / Math::abs ( columns[1 ][1 ]) );
425425}
426426
427427Vector2 Projection::get_far_plane_half_extents () const {
428428 // NOTE: This assumes a symmetrical frustum, i.e. that :
429429 // - the matrix is a projection across z-axis (i.e. is invertible and columns[0][1], [0][3], [1][0] and [1][3] == 0)
430430 // - the projection plane is rectangular (i.e. columns[0][2] and [1][2] == 0 if columns[2][3] != 0)
431431 // - there is no offset / skew (i.e. columns[2][0] == columns[2][1] == 0)
432- real_t w = - get_z_far () * columns[2 ][3 ] + columns[3 ][3 ];
433- return Vector2 (w / columns[0 ][0 ], w / columns[1 ][1 ]);
432+ real_t w = get_z_far () * Math::abs ( columns[2 ][3 ]) + columns[3 ][3 ];
433+ return Vector2 (w / columns[0 ][0 ], w / Math::abs ( columns[1 ][1 ]) );
434434}
435435
436436bool Projection::get_endpoints (const Transform3D &p_transform, Vector3 *p_8points) const {
@@ -859,7 +859,7 @@ real_t Projection::get_aspect() const {
859859 // NOTE: This assumes a rectangular projection plane, i.e. that :
860860 // - the matrix is a projection across z-axis (i.e. is invertible and columns[0][1], [0][3], [1][0] and [1][3] == 0)
861861 // - the projection plane is rectangular (i.e. columns[0][2] and [1][2] == 0 if columns[2][3] != 0)
862- return columns[1 ][1 ] / columns[0 ][0 ];
862+ return Math::abs ( columns[1 ][1 ] / columns[0 ][0 ]) ;
863863}
864864
865865int Projection::get_pixels_per_meter (int p_for_pixel_width) const {
0 commit comments