Skip to content

Fix some scaling corner cases#362

Merged
oitel merged 10 commits intomasterfrom
view_matrix_fixes
Aug 12, 2022
Merged

Fix some scaling corner cases#362
oitel merged 10 commits intomasterfrom
view_matrix_fixes

Conversation

@oitel
Copy link
Contributor

@oitel oitel commented Aug 12, 2022

No description provided.

@oitel oitel requested review from Fedr and Grantim August 12, 2022 13:14
constexpr T normSq() const noexcept { return x.lengthSq() + y.lengthSq() + z.lengthSq() + w.lengthSq(); }
constexpr T norm() const noexcept { return std::sqrt( normSq() ); }
/// computes submatrix
constexpr Matrix3<T> submatrix( int i, int j ) const noexcept;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better name submatrix3 and explain what is i and j in the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

{
auto norm = normTemp.norm();
assert( std::isnormal( norm ) );
normTemp /= norm;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can be here if norm == 0, so we should check this before division

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::isnormal checks for zero either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but assert is only in Debug, but we need a check for Release as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

namespace
{

constexpr float cMaxObjectScale = 1e9;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constexpr float cMaxObjectScaleSq = 1e9f;

and please add some comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

namespace
{

/// maximum supported distance to rotation pivot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

distance -> distance square

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

if ( xf_ == xf )
return;
xf_ = xf;
if ( Matrix4( xf ).det() == 0 )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xf.A.det() == 0 is faster here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@oitel oitel merged commit f697676 into master Aug 12, 2022
@oitel oitel deleted the view_matrix_fixes branch August 12, 2022 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants