mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 23:49:19 +02:00
Every module unit now includes the standard headers it uses. Declarations reaching a unit only through an imported module's global module fragment are reachable but not visible, so ADL misses the free operators older libstdc++ declares beside a type - reproduced on ubuntu 24.04 (libstdc++ 13), where gl/vao.cpp could not compare vector iterators. Also drops a stale editor/editorSettings.hpp from the MSVC source list, which broke the Windows configure step, silences the deliberate include-in-purview warning in the glm wrapper, and removes GCC support: clang or MSVC only.
61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
module;
|
|
#include <vector>
|
|
#include <iterator>
|
|
#include "glad/glad.h"
|
|
#include "vehicle/DynObj_macros.h"
|
|
|
|
module eu07.rendering.openglcamera;
|
|
import eu07.simcore;
|
|
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
opengl_camera::update_frustum( glm::mat4 const &Projection, glm::mat4 const &Modelview ) {
|
|
|
|
m_frustum.calculate( Projection, Modelview );
|
|
// cache inverse tranformation matrix
|
|
// NOTE: transformation is done only to camera-centric space
|
|
m_inversetransformation = glm::inverse( Projection * glm::mat4{ glm::mat3{ Modelview } } );
|
|
// calculate frustum corners
|
|
m_frustumpoints = ndcfrustumshapepoints;
|
|
transform_to_world(
|
|
std::begin( m_frustumpoints ),
|
|
std::end( m_frustumpoints ) );
|
|
}
|
|
|
|
// returns true if specified object is within camera frustum, false otherwise
|
|
bool
|
|
opengl_camera::visible( scene::bounding_area const &Area ) const {
|
|
|
|
return ( m_frustum.sphere_inside( Area.center, Area.radius ) > 0.f );
|
|
}
|
|
|
|
bool
|
|
opengl_camera::visible( TDynamicObject const *Dynamic ) const {
|
|
|
|
// sphere test is faster than AABB, so we'll use it here
|
|
// we're giving vehicles some extra padding, to allow for things like shared bogeys extending past the main body
|
|
return ( m_frustum.sphere_inside( Dynamic->GetPosition(), Dynamic->radius() * 1.25 ) > 0.0f );
|
|
}
|
|
|
|
// debug helper, draws shape of frustum in world space
|
|
void
|
|
opengl_camera::draw( glm::vec3 const &Offset ) const {
|
|
|
|
::glBegin( GL_LINES );
|
|
for( auto const pointindex : frustumshapepoinstorder ) {
|
|
::glVertex3fv( glm::value_ptr( glm::vec3{ m_frustumpoints[ pointindex ] } - Offset ) );
|
|
}
|
|
::glEnd();
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|