Some cleanup

This commit is contained in:
2024-04-21 09:39:45 -04:00
parent 8c3eda0e37
commit 8856f33704
4 changed files with 25 additions and 15 deletions

View File

@@ -75,7 +75,7 @@ namespace fgl::engine
frustum = translation_matrix * base_frustum;
return;
}
else
else [[unlikely]]
return;
}

View File

@@ -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
{

View File

@@ -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

View File

@@ -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