From 04e8f5ef630ccf41e166b1699186cb03884de268 Mon Sep 17 00:00:00 2001 From: Garux Date: Mon, 23 Oct 2017 23:20:15 +0300 Subject: [PATCH] * fix/improvement of arrows, showing direction of entity connections; now are definitely visible in all orthogonal projections :) --- plugins/entity/targetable.h | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/plugins/entity/targetable.h b/plugins/entity/targetable.h index 52a39425..9a775526 100644 --- a/plugins/entity/targetable.h +++ b/plugins/entity/targetable.h @@ -47,7 +47,7 @@ typedef std::set targetables_t; extern const char* g_targetable_nameKey; targetables_t* getTargetables( const char* targetname ); - +#if 0 class EntityConnectionLine : public OpenGLRenderable { public: @@ -84,7 +84,7 @@ void render( RenderStateFlags state ) const { glEnd(); } }; - +#endif class TargetedEntity { Targetable& m_targetable; @@ -185,31 +185,32 @@ TargetLinesPushBack( RenderablePointVector& targetLines, const Vector3& worldPos } void operator()( const Vector3& worldPosition ) const { Vector3 dir( worldPosition - m_worldPosition );//end - start - double len = vector3_length( dir ); + const double len = vector3_length( dir ); if ( len != 0 && m_volume.TestLine( segment_for_startend( m_worldPosition, worldPosition ) ) ) { m_targetLines.push_back( PointVertex( reinterpret_cast( m_worldPosition ) ) ); m_targetLines.push_back( PointVertex( reinterpret_cast( worldPosition ) ) ); - Vector3 mid( ( worldPosition + m_worldPosition ) * 0.5f ); + const Vector3 mid( ( worldPosition + m_worldPosition ) * .5f ); //vector3_normalise( dir ); - dir /= len; - Vector3 hack( 0.57735, 0.57735, 0.57735 ); + dir *= ( 1.0 / len ); + Vector3 hack( 0.57735f, 0.57735f, 0.57735f ); int maxI = 0; float max = 0; for ( int i = 0; i < 3 ; ++i ){ if ( dir[i] < 0 ){ - hack[i] *= -1; + hack[i] *= -1.f; } if ( fabs( dir[i] ) > max ){ maxI = i; + max = fabs( dir[i] ); } } - hack[maxI] *= -1; + hack[maxI] *= -1.f; - Vector3 ort( vector3_cross( dir, hack ) ); + const Vector3 ort( vector3_cross( dir, hack ) ); //vector3_normalise( ort ); - Vector3 wing1( mid - dir*12 + ort*6 ); - Vector3 wing2( wing1 - ort*12 ); + Vector3 wing1( mid - dir * 12.f + ort * 6.f ); + Vector3 wing2( wing1 - ort * 12.f ); if( len <= 512 || len > 768 ){ m_targetLines.push_back( PointVertex( reinterpret_cast( mid ) ) ); @@ -218,16 +219,16 @@ void operator()( const Vector3& worldPosition ) const { m_targetLines.push_back( PointVertex( reinterpret_cast( wing2 ) ) ); } if( len > 512 ){ - Vector3 wing1_delta( mid - wing1 ); - Vector3 wing2_delta( mid - wing2 ); - Vector3 point( m_worldPosition + dir*256 ); + const Vector3 wing1_delta( mid - wing1 ); + const Vector3 wing2_delta( mid - wing2 ); + Vector3 point( m_worldPosition + dir * 256.f ); wing1 = point - wing1_delta; wing2 = point - wing2_delta; m_targetLines.push_back( PointVertex( reinterpret_cast( point ) ) ); m_targetLines.push_back( PointVertex( reinterpret_cast( wing1 ) ) ); m_targetLines.push_back( PointVertex( reinterpret_cast( point ) ) ); m_targetLines.push_back( PointVertex( reinterpret_cast( wing2 ) ) ); - point = worldPosition - dir*256; + point = worldPosition - dir * 256.f; wing1 = point - wing1_delta; wing2 = point - wing2_delta; m_targetLines.push_back( PointVertex( reinterpret_cast( point ) ) );