diff --git a/src/engine/Camera.cpp b/src/engine/Camera.cpp index 1ba43dd..2cfbd65 100644 --- a/src/engine/Camera.cpp +++ b/src/engine/Camera.cpp @@ -75,7 +75,7 @@ namespace fgl::engine frustum = translation_matrix * base_frustum; return; } - else + else [[unlikely]] return; } diff --git a/src/engine/Camera.hpp b/src/engine/Camera.hpp index 6a2db38..3a728ca 100644 --- a/src/engine/Camera.hpp +++ b/src/engine/Camera.hpp @@ -65,43 +65,43 @@ namespace fgl::engine WorldCoordinate getFrustumPosition() const; - const Frustum< CoordinateSpace::Model >& getBaseFrustum() const { return base_frustum; } + inline const Frustum< CoordinateSpace::Model >& getBaseFrustum() const { return base_frustum; } //! Returns the frustum of the camera in world space - const Frustum< CoordinateSpace::World >& getFrustumBounds() const { return frustum; } + inline const Frustum< CoordinateSpace::World >& getFrustumBounds() const { return frustum; } - const Matrix< MatrixType::CameraToScreen >& getProjectionMatrix() const { return projection_matrix; } + inline const Matrix< MatrixType::CameraToScreen >& getProjectionMatrix() const { return projection_matrix; } - const Matrix< MatrixType::WorldToCamera > getViewMatrix() const { return view_matrix; } + inline const Matrix< MatrixType::WorldToCamera >& getViewMatrix() const { return view_matrix; } - const Matrix< MatrixType::WorldToScreen > getProjectionViewMatrix() const + inline Matrix< MatrixType::WorldToScreen > getProjectionViewMatrix() const { assert( projection_matrix != constants::MAT4_IDENTITY ); return projection_matrix * view_matrix; } - const glm::mat4 getInverseViewMatrix() const { return glm::inverse( view_matrix ); } + inline glm::mat4 getInverseViewMatrix() const { return glm::inverse( view_matrix ); } void setOrthographicProjection( float left, float right, float top, float bottom, float near, float far ); void setPerspectiveProjection( float fovy, float aspect, float near, float far ); - const Coordinate< CoordinateSpace::World > getPosition() const + inline Coordinate< CoordinateSpace::World > getPosition() const { //Should maybe store the inverse view matrix return WorldCoordinate( inverse_view_matrix[ 3 ] ); } - const Vector getUp() const { return -getDown(); } + inline Vector getUp() const { return -getDown(); } - const Vector getRight() const { return Vector( glm::normalize( glm::vec3( inverse_view_matrix[ 0 ] ) ) ); } + inline Vector getRight() const { return Vector( glm::normalize( glm::vec3( inverse_view_matrix[ 0 ] ) ) ); } - const Vector getForward() const { return Vector( glm::normalize( glm::vec3( inverse_view_matrix[ 2 ] ) ) ); } + inline Vector getForward() const { return Vector( glm::normalize( glm::vec3( inverse_view_matrix[ 2 ] ) ) ); } - const Vector getLeft() const { return -getRight(); } + inline Vector getLeft() const { return -getRight(); } - const Vector getBackward() const { return -getForward(); } + inline Vector getBackward() const { return -getForward(); } - const Vector getDown() const { return Vector( glm::normalize( glm::vec3( inverse_view_matrix[ 1 ] ) ) ); } + inline Vector getDown() const { return Vector( glm::normalize( glm::vec3( inverse_view_matrix[ 1 ] ) ) ); } enum ViewMode { diff --git a/src/engine/FGL_DEFINES.hpp b/src/engine/FGL_DEFINES.hpp index a56bbf1..bffbe30 100644 --- a/src/engine/FGL_DEFINES.hpp +++ b/src/engine/FGL_DEFINES.hpp @@ -16,6 +16,16 @@ #define FGL_FORCE_INLINE_FLATTEN __attribute__( ( always_inline, flatten ) ) #define FGL_ASSUME( ... ) __attribute__( ( assume( __VA_ARGS__ ) ) ) +#define FGL_ALIGN( bytesize ) __attribute__( ( alligned( bitsize ) ) ) + +#define FGL_FUNC_CLEANUP( func ) __attribute__( ( cleanup( func ) ) ) + +//! Warns if the variable is used as a string (strlen) +#define FGL_NONSTRING_DATA __attribute__( ( nonstring ) ) + +//! Warns if the structure field is not alligned with a set number of bytes +#define FGL_STRICT_ALIGNMENT( bytesize ) __attribute__( ( warn_if_not_aligned( bytesize ) ) ) + #endif #else diff --git a/src/engine/universe_constants.hpp b/src/engine/universe_constants.hpp index 39444e8..1729f70 100644 --- a/src/engine/universe_constants.hpp +++ b/src/engine/universe_constants.hpp @@ -9,7 +9,7 @@ namespace fgl::engine::uconstants { - //! How fast an object falls with zero air resistance per second + //! How fast an increases speed with zero air resistance per second (ms/s/s) constexpr float EARTH_GRAVITY { 9.80665f }; } // namespace fgl::engine::uconstants