diff --git a/src/OpenGl/OpenGl_ShaderStates.cxx b/src/OpenGl/OpenGl_ShaderStates.cxx index 2aeaf2655a..c6b03f2c2d 100755 --- a/src/OpenGl/OpenGl_ShaderStates.cxx +++ b/src/OpenGl/OpenGl_ShaderStates.cxx @@ -45,28 +45,17 @@ void OpenGl_ProjectionState::Set (const OpenGl_Mat4& theProjectionMatrix) myInverseNeedUpdate = true; } -// ======================================================================= -// function : ProjectionMatrix -// purpose : Returns current projection matrix -// ======================================================================= -const OpenGl_Mat4& OpenGl_ProjectionState::ProjectionMatrix() const -{ - return myProjectionMatrix; -} - // ======================================================================= // function : ProjectionMatrixInverse // purpose : Returns inverse of current projection matrix // ======================================================================= const OpenGl_Mat4& OpenGl_ProjectionState::ProjectionMatrixInverse() const { - if (!myInverseNeedUpdate) + if (myInverseNeedUpdate) { - return myProjectionMatrixInverse; + myInverseNeedUpdate = false; + myProjectionMatrix.Inverted (myProjectionMatrixInverse); } - - myProjectionMatrix.Inverted (myProjectionMatrixInverse); - return myProjectionMatrixInverse; } @@ -90,28 +79,17 @@ void OpenGl_ModelWorldState::Set (const OpenGl_Mat4& theModelWorldMatrix) myInverseNeedUpdate = true; } -// ======================================================================= -// function : ModelWorldMatrix -// purpose : Returns current model-world matrix -// ======================================================================= -const OpenGl_Mat4& OpenGl_ModelWorldState::ModelWorldMatrix() const -{ - return myModelWorldMatrix; -} - // ======================================================================= // function : ModelWorldMatrixInverse // purpose : Returns inverse of current model-world matrix // ======================================================================= const OpenGl_Mat4& OpenGl_ModelWorldState::ModelWorldMatrixInverse() const { - if (!myInverseNeedUpdate) + if (myInverseNeedUpdate) { - return myModelWorldMatrix; + myInverseNeedUpdate = false; + myModelWorldMatrix.Inverted (myModelWorldMatrixInverse); } - - myModelWorldMatrix.Inverted (myModelWorldMatrixInverse); - return myModelWorldMatrixInverse; } @@ -135,28 +113,17 @@ void OpenGl_WorldViewState::Set (const OpenGl_Mat4& theWorldViewMatrix) myInverseNeedUpdate = true; } -// ======================================================================= -// function : WorldViewMatrix -// purpose : Returns current world-view matrix -// ======================================================================= -const OpenGl_Mat4& OpenGl_WorldViewState::WorldViewMatrix() const -{ - return myWorldViewMatrix; -} - // ======================================================================= // function : WorldViewMatrixInverse // purpose : Returns inverse of current world-view matrix // ======================================================================= const OpenGl_Mat4& OpenGl_WorldViewState::WorldViewMatrixInverse() const { - if (!myInverseNeedUpdate) + if (myInverseNeedUpdate) { - return myWorldViewMatrix; + myInverseNeedUpdate = false; + myWorldViewMatrix.Inverted (myWorldViewMatrixInverse); } - - myWorldViewMatrix.Inverted (myWorldViewMatrixInverse); - return myWorldViewMatrixInverse; } diff --git a/src/OpenGl/OpenGl_ShaderStates.hxx b/src/OpenGl/OpenGl_ShaderStates.hxx index bebd349cbc..9f25334615 100755 --- a/src/OpenGl/OpenGl_ShaderStates.hxx +++ b/src/OpenGl/OpenGl_ShaderStates.hxx @@ -53,7 +53,7 @@ public: Standard_EXPORT void Set (const OpenGl_Mat4& theProjectionMatrix); //! Returns current projection matrix. - Standard_EXPORT const OpenGl_Mat4& ProjectionMatrix() const; + const OpenGl_Mat4& ProjectionMatrix() const { return myProjectionMatrix; } //! Returns inverse of current projection matrix. Standard_EXPORT const OpenGl_Mat4& ProjectionMatrixInverse() const; @@ -62,7 +62,7 @@ private: OpenGl_Mat4 myProjectionMatrix; //!< OCCT projection matrix mutable OpenGl_Mat4 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix - bool myInverseNeedUpdate; //!< Is inversed matrix outdated? + mutable bool myInverseNeedUpdate; //!< Is inversed matrix outdated? }; @@ -78,7 +78,7 @@ public: Standard_EXPORT void Set (const OpenGl_Mat4& theModelWorldMatrix); //! Returns current model-world matrix. - Standard_EXPORT const OpenGl_Mat4& ModelWorldMatrix() const; + const OpenGl_Mat4& ModelWorldMatrix() const { return myModelWorldMatrix; } //! Returns inverse of current model-world matrix. Standard_EXPORT const OpenGl_Mat4& ModelWorldMatrixInverse() const; @@ -87,7 +87,7 @@ private: OpenGl_Mat4 myModelWorldMatrix; //!< OCCT model-world matrix mutable OpenGl_Mat4 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix - bool myInverseNeedUpdate; //!< Is inversed matrix outdated? + mutable bool myInverseNeedUpdate; //!< Is inversed matrix outdated? }; @@ -103,7 +103,7 @@ public: Standard_EXPORT void Set (const OpenGl_Mat4& theWorldViewMatrix); //! Returns current world-view matrix. - Standard_EXPORT const OpenGl_Mat4& WorldViewMatrix() const; + const OpenGl_Mat4& WorldViewMatrix() const { return myWorldViewMatrix; } //! Returns inverse of current world-view matrix. Standard_EXPORT const OpenGl_Mat4& WorldViewMatrixInverse() const; @@ -112,7 +112,7 @@ private: OpenGl_Mat4 myWorldViewMatrix; //!< OCCT world-view matrix mutable OpenGl_Mat4 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix - bool myInverseNeedUpdate; //!< Is inversed matrix outdated? + mutable bool myInverseNeedUpdate; //!< Is inversed matrix outdated? };