mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 11:39:19 +02:00
use glm instead of Math3D in rendering
This commit is contained in:
@@ -47,9 +47,6 @@ public:
|
|||||||
inline
|
inline
|
||||||
bool
|
bool
|
||||||
point_inside( float3 const &Point ) const { return point_inside( Point.x, Point.y, Point.z ); }
|
point_inside( float3 const &Point ) const { return point_inside( Point.x, Point.y, Point.z ); }
|
||||||
inline
|
|
||||||
bool
|
|
||||||
point_inside( Math3D::vector3 const &Point ) const { return point_inside( static_cast<float>( Point.x ), static_cast<float>( Point.y ), static_cast<float>( Point.z ) ); }
|
|
||||||
bool
|
bool
|
||||||
point_inside( float const X, float const Y, float const Z ) const;
|
point_inside( float const X, float const Y, float const Z ) const;
|
||||||
// tests if the sphere is in frustum, returns the distance between origin and sphere centre
|
// tests if the sphere is in frustum, returns the distance between origin and sphere centre
|
||||||
@@ -62,9 +59,6 @@ public:
|
|||||||
inline
|
inline
|
||||||
float
|
float
|
||||||
sphere_inside( float3 const &Center, float const Radius ) const { return sphere_inside( Center.x, Center.y, Center.z, Radius ); }
|
sphere_inside( float3 const &Center, float const Radius ) const { return sphere_inside( Center.x, Center.y, Center.z, Radius ); }
|
||||||
inline
|
|
||||||
float
|
|
||||||
sphere_inside( Math3D::vector3 const &Center, float const Radius ) const { return sphere_inside( static_cast<float>( Center.x ), static_cast<float>( Center.y ), static_cast<float>( Center.z ), Radius ); }
|
|
||||||
float
|
float
|
||||||
sphere_inside( float const X, float const Y, float const Z, float const Radius ) const;
|
sphere_inside( float const X, float const Y, float const Z, float const Radius ) const;
|
||||||
// returns true if specified cube is inside of the frustum. Size = half of the length
|
// returns true if specified cube is inside of the frustum. Size = half of the length
|
||||||
@@ -74,9 +68,6 @@ public:
|
|||||||
inline
|
inline
|
||||||
bool
|
bool
|
||||||
cube_inside( float3 const &Center, float const Size ) const { return cube_inside( Center.x, Center.y, Center.z, Size ); }
|
cube_inside( float3 const &Center, float const Size ) const { return cube_inside( Center.x, Center.y, Center.z, Size ); }
|
||||||
inline
|
|
||||||
bool
|
|
||||||
cube_inside( Math3D::vector3 const &Center, float const Size ) const { return cube_inside( static_cast<float>( Center.x ), static_cast<float>( Center.y ), static_cast<float>( Center.z ), Size ); }
|
|
||||||
bool
|
bool
|
||||||
cube_inside( float const X, float const Y, float const Z, float const Size ) const;
|
cube_inside( float const X, float const Y, float const Z, float const Size ) const;
|
||||||
|
|
||||||
|
|||||||
@@ -1266,7 +1266,7 @@ bool opengl33_renderer::Render_coupler_adapter( TDynamicObject *Dynamic, float c
|
|||||||
|
|
||||||
if( Dynamic->m_coupleradapters[ End ] == nullptr ) { return false; }
|
if( Dynamic->m_coupleradapters[ End ] == nullptr ) { return false; }
|
||||||
|
|
||||||
auto const position { Math3D::vector3 {
|
auto const position { glm::dvec3 {
|
||||||
0.f,
|
0.f,
|
||||||
Dynamic->MoverParameters->Couplers[ End ].adapter_height,
|
Dynamic->MoverParameters->Couplers[ End ].adapter_height,
|
||||||
( Dynamic->MoverParameters->Couplers[ End ].adapter_length + Dynamic->MoverParameters->Dim.L * 0.5 ) * ( End == end::front ? 1 : -1 ) } };
|
( Dynamic->MoverParameters->Couplers[ End ].adapter_length + Dynamic->MoverParameters->Dim.L * 0.5 ) * ( End == end::front ? 1 : -1 ) } };
|
||||||
@@ -2681,7 +2681,7 @@ void opengl33_renderer::Render(scene::shape_node const &Shape, bool const Ignore
|
|||||||
case rendermode::shadows:
|
case rendermode::shadows:
|
||||||
{
|
{
|
||||||
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
||||||
distancesquared = Math3D::SquareMagnitude((data.area.center - m_renderpass.viewport_camera.position()) / (double)Global.ZoomFactor) / Global.fDistanceFactor;
|
distancesquared = glm::length2((data.area.center - m_renderpass.viewport_camera.position()) / (double)Global.ZoomFactor) / Global.fDistanceFactor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case rendermode::reflections:
|
case rendermode::reflections:
|
||||||
@@ -3105,9 +3105,9 @@ bool opengl33_renderer::Render(TModel3d *Model, material_data const *Material, f
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool opengl33_renderer::Render(TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &A)
|
bool opengl33_renderer::Render(TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &A)
|
||||||
{
|
{
|
||||||
Math3D::vector3 Angle(A);
|
glm::dvec3 Angle(A); // TODO: Why copy?
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
::glTranslated(Position.x, Position.y, Position.z);
|
::glTranslated(Position.x, Position.y, Position.z);
|
||||||
if (Angle.y != 0.0)
|
if (Angle.y != 0.0)
|
||||||
@@ -3980,9 +3980,9 @@ bool opengl33_renderer::Render_Alpha(TModel3d *Model, material_data const *Mater
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool opengl33_renderer::Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &A)
|
bool opengl33_renderer::Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &A)
|
||||||
{
|
{
|
||||||
Math3D::vector3 Angle(A);
|
glm::dvec3 Angle(A); // TODO: Why copy?
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
::glTranslated(Position.x, Position.y, Position.z);
|
::glTranslated(Position.x, Position.y, Position.z);
|
||||||
if (Angle.y != 0.0)
|
if (Angle.y != 0.0)
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class opengl33_renderer : public gfx_renderer {
|
|||||||
void Render(scene::shape_node const &Shape, bool const Ignorerange);
|
void Render(scene::shape_node const &Shape, bool const Ignorerange);
|
||||||
void Render(TAnimModel *Instance);
|
void Render(TAnimModel *Instance);
|
||||||
bool Render(TDynamicObject *Dynamic);
|
bool Render(TDynamicObject *Dynamic);
|
||||||
bool Render(TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle);
|
bool Render(TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle);
|
||||||
bool Render(TModel3d *Model, material_data const *Material, float const Squaredistance);
|
bool Render(TModel3d *Model, material_data const *Material, float const Squaredistance);
|
||||||
void Render(TSubModel *Submodel);
|
void Render(TSubModel *Submodel);
|
||||||
void Render(TTrack *Track);
|
void Render(TTrack *Track);
|
||||||
@@ -280,7 +280,7 @@ class opengl33_renderer : public gfx_renderer {
|
|||||||
void Render_Alpha(TTraction *Traction);
|
void Render_Alpha(TTraction *Traction);
|
||||||
void Render_Alpha(scene::lines_node const &Lines);
|
void Render_Alpha(scene::lines_node const &Lines);
|
||||||
bool Render_Alpha(TDynamicObject *Dynamic);
|
bool Render_Alpha(TDynamicObject *Dynamic);
|
||||||
bool Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle);
|
bool Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle);
|
||||||
bool Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance);
|
bool Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance);
|
||||||
void Render_Alpha(TSubModel *Submodel);
|
void Render_Alpha(TSubModel *Submodel);
|
||||||
void Update_Lights(light_array &Lights);
|
void Update_Lights(light_array &Lights);
|
||||||
|
|||||||
@@ -867,7 +867,7 @@ bool opengl_renderer::Render_coupler_adapter( TDynamicObject *Dynamic, float con
|
|||||||
|
|
||||||
if( Dynamic->m_coupleradapters[ End ] == nullptr ) { return false; }
|
if( Dynamic->m_coupleradapters[ End ] == nullptr ) { return false; }
|
||||||
|
|
||||||
auto const position { Math3D::vector3 {
|
auto const position { glm::dvec3 {
|
||||||
0.f,
|
0.f,
|
||||||
Dynamic->MoverParameters->Couplers[ End ].adapter_height,
|
Dynamic->MoverParameters->Couplers[ End ].adapter_height,
|
||||||
( Dynamic->MoverParameters->Couplers[ End ].adapter_length + Dynamic->MoverParameters->Dim.L * 0.5 ) * ( End == end::front ? 1 : -1 ) } };
|
( Dynamic->MoverParameters->Couplers[ End ].adapter_length + Dynamic->MoverParameters->Dim.L * 0.5 ) * ( End == end::front ? 1 : -1 ) } };
|
||||||
@@ -2277,7 +2277,7 @@ opengl_renderer::Render( scene::shape_node const &Shape, bool const Ignorerange
|
|||||||
case rendermode::shadows:
|
case rendermode::shadows:
|
||||||
case rendermode::cabshadows: {
|
case rendermode::cabshadows: {
|
||||||
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
||||||
distancesquared = Math3D::SquareMagnitude( ( data.area.center - Global.pCamera.Pos ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor;
|
distancesquared = glm::length2( ( data.area.center - Global.pCamera.Pos ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case rendermode::reflections: {
|
case rendermode::reflections: {
|
||||||
@@ -2696,7 +2696,7 @@ opengl_renderer::Render( TModel3d *Model, material_data const *Material, float c
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
opengl_renderer::Render( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle ) {
|
opengl_renderer::Render( TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle ) {
|
||||||
|
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
::glTranslated( Position.x, Position.y, Position.z );
|
::glTranslated( Position.x, Position.y, Position.z );
|
||||||
@@ -3505,7 +3505,7 @@ opengl_renderer::Render_Alpha( TAnimModel *Instance ) {
|
|||||||
switch( m_renderpass.draw_mode ) {
|
switch( m_renderpass.draw_mode ) {
|
||||||
case rendermode::shadows: {
|
case rendermode::shadows: {
|
||||||
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
||||||
distancesquared = Math3D::SquareMagnitude( ( Instance->location() - Global.pCamera.Pos ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor;
|
distancesquared = glm::length2( ( Instance->location() - Global.pCamera.Pos ) / (double)Global.ZoomFactor ) / Global.fDistanceFactor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -3549,7 +3549,7 @@ opengl_renderer::Render_Alpha( TTraction *Traction ) {
|
|||||||
switch( m_renderpass.draw_mode ) {
|
switch( m_renderpass.draw_mode ) {
|
||||||
case rendermode::shadows: {
|
case rendermode::shadows: {
|
||||||
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
||||||
distancesquared = Math3D::SquareMagnitude( ( Traction->location() - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor;
|
distancesquared = glm::length2( ( Traction->location() - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -3613,7 +3613,7 @@ opengl_renderer::Render_Alpha( scene::lines_node const &Lines ) {
|
|||||||
switch( m_renderpass.draw_mode ) {
|
switch( m_renderpass.draw_mode ) {
|
||||||
case rendermode::shadows: {
|
case rendermode::shadows: {
|
||||||
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
// 'camera' for the light pass is the light source, but we need to draw what the 'real' camera sees
|
||||||
distancesquared = Math3D::SquareMagnitude( ( data.area.center - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor;
|
distancesquared = glm::length2( ( data.area.center - Global.pCamera.Pos ) / Global.ZoomFactor ) / Global.fDistanceFactor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -3769,7 +3769,7 @@ opengl_renderer::Render_Alpha( TModel3d *Model, material_data const *Material, f
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
opengl_renderer::Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle ) {
|
opengl_renderer::Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle ) {
|
||||||
|
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
::glTranslated( Position.x, Position.y, Position.z );
|
::glTranslated( Position.x, Position.y, Position.z );
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ private:
|
|||||||
bool
|
bool
|
||||||
Render( TDynamicObject *Dynamic );
|
Render( TDynamicObject *Dynamic );
|
||||||
bool
|
bool
|
||||||
Render( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle );
|
Render( TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle );
|
||||||
bool
|
bool
|
||||||
Render( TModel3d *Model, material_data const *Material, float const Squaredistance );
|
Render( TModel3d *Model, material_data const *Material, float const Squaredistance );
|
||||||
void
|
void
|
||||||
@@ -259,7 +259,7 @@ private:
|
|||||||
bool
|
bool
|
||||||
Render_Alpha( TDynamicObject *Dynamic );
|
Render_Alpha( TDynamicObject *Dynamic );
|
||||||
bool
|
bool
|
||||||
Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance, Math3D::vector3 const &Position, glm::vec3 const &Angle );
|
Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance, glm::dvec3 const &Position, glm::vec3 const &Angle );
|
||||||
bool
|
bool
|
||||||
Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance );
|
Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance );
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user