From eae7ac024aaeb2fa6afb8742e676a9b60b7b5bb2 Mon Sep 17 00:00:00 2001 From: Garux Date: Thu, 22 Feb 2018 18:56:53 +0300 Subject: [PATCH] clean namedentity, forward declarations, ostream_write --- include/editable.h | 5 ---- include/irender.h | 6 +--- include/iselection.h | 1 - include/ishaders.h | 4 --- include/modulesystem.h | 2 -- include/selectable.h | 4 --- libs/generic/vector.h | 14 +++++++++ libs/math/matrix.h | 6 +--- libs/scenelib.h | 8 ------ libs/stringio.h | 5 ---- plugins/entity/namedentity.h | 55 ++++-------------------------------- radiant/brush.h | 12 -------- radiant/brush_primit.h | 6 ---- radiant/csg.h | 8 +++--- radiant/entityinspector.cpp | 2 -- radiant/selection.cpp | 8 ------ radiant/winding.h | 2 -- 17 files changed, 26 insertions(+), 122 deletions(-) diff --git a/include/editable.h b/include/editable.h index 39e1174d..3c5524a3 100644 --- a/include/editable.h +++ b/include/editable.h @@ -22,12 +22,7 @@ #if !defined( INCLUDED_EDITABLE_H ) #define INCLUDED_EDITABLE_H -template class BasicVector3; -typedef BasicVector3 Vector3; -template class BasicVector4; -typedef BasicVector4 Vector4; class Matrix4; -typedef Vector4 Quaternion; #include "scenelib.h" diff --git a/include/irender.h b/include/irender.h index 7b93ec13..c5109f6e 100644 --- a/include/irender.h +++ b/include/irender.h @@ -24,6 +24,7 @@ #include "generic/constant.h" #include "generic/callbackfwd.h" +#include "generic/vector.h" // Rendering states to sort by. @@ -60,9 +61,6 @@ typedef unsigned int RenderStateFlags; class AABB; class Matrix4; -template class BasicVector3; -typedef BasicVector3 Vector3; - class Shader; class RendererLight @@ -115,8 +113,6 @@ class Matrix4; struct qtexture_t; class ModuleObserver; -#include "generic/vector.h" - class Shader { public: diff --git a/include/iselection.h b/include/iselection.h index fc9351d6..a2b00275 100644 --- a/include/iselection.h +++ b/include/iselection.h @@ -54,7 +54,6 @@ template class BasicVector3; typedef BasicVector3 Vector3; template class BasicVector4; typedef BasicVector4 Vector4; -class Matrix4; typedef Vector4 Quaternion; typedef Callback1 SelectionChangeCallback; diff --git a/include/ishaders.h b/include/ishaders.h index cfd6e0fc..326e25c7 100644 --- a/include/ishaders.h +++ b/include/ishaders.h @@ -42,10 +42,6 @@ enum struct qtexture_t; -template class BasicVector3; -typedef BasicVector3 Vector3; -typedef Vector3 Colour3; - typedef unsigned char BlendFactor; const BlendFactor BLEND_ZERO = 0; const BlendFactor BLEND_ONE = 1; diff --git a/include/modulesystem.h b/include/modulesystem.h index 8b1913fb..d3578ac4 100644 --- a/include/modulesystem.h +++ b/include/modulesystem.h @@ -120,8 +120,6 @@ virtual Type* findModule( const char* name ) = 0; virtual void foreachModule( const Visitor& visitor ) = 0; }; -#include "debugging/debugging.h" - template class ModuleRef { diff --git a/include/selectable.h b/include/selectable.h index 605ba7b1..44012f12 100644 --- a/include/selectable.h +++ b/include/selectable.h @@ -219,13 +219,9 @@ pointer m_indices; pointer m_finish; }; -template class BasicVector3; -typedef BasicVector3 Vector3; class Matrix4; class VolumeTest; -typedef BasicVector3 DoubleVector3; - class SelectionTest { public: diff --git a/libs/generic/vector.h b/libs/generic/vector.h index ea1e3bdb..1a5863df 100644 --- a/libs/generic/vector.h +++ b/libs/generic/vector.h @@ -205,8 +205,22 @@ typedef BasicVector2 Vector2; /// \brief A 3-element vector stored in single-precision floating-point. typedef BasicVector3 Vector3; +/// \brief A 3-element vector stored in double-precision floating-point. +typedef BasicVector3 DoubleVector3; + /// \brief A 4-element vector stored in single-precision floating-point. typedef BasicVector4 Vector4; +template +inline TextOutputStreamType& ostream_write( TextOutputStreamType& outputStream, const Vector3& v ){ + return outputStream << '(' << v.x() << ' ' << v.y() << ' ' << v.z() << ')'; +} + +template +TextOutputStreamType& ostream_write( TextOutputStreamType& t, const Vector4& v ){ + return t << "[ " << v.x() << " " << v.y() << " " << v.z() << " " << v.w() << " ]"; +} + + #endif diff --git a/libs/math/matrix.h b/libs/math/matrix.h index ee577ff6..386104f1 100644 --- a/libs/math/matrix.h +++ b/libs/math/matrix.h @@ -1156,13 +1156,9 @@ inline void matrix4_pivoted_transform_by_euler_xyz_degrees( Matrix4& self, const matrix4_translate_by_vec3( self, vector3_negated( pivotpoint ) ); } - template inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const Matrix4& m ){ - return ostream << "[ " << m[0] << " " << m[1] << " " << m[2] << " " << m[3] << " ]*[ " - << m[4] << " " << m[5] << " " << m[6] << " " << m[7] << " ]*[ " - << m[8] << " " << m[9] << " " << m[10] << " " << m[11] << " ]*[ " - << m[12] << " " << m[13] << " " << m[14] << " " << m[15] << " ]"; + return ostream << m.x() << " " << m.y() << " " << m.z() << " " << m.t(); } #endif diff --git a/libs/scenelib.h b/libs/scenelib.h index 0785baec..91dab80a 100644 --- a/libs/scenelib.h +++ b/libs/scenelib.h @@ -38,14 +38,6 @@ class Selector; class SelectionTest; -class VolumeTest; -template class BasicVector3; -typedef BasicVector3 Vector3; -template class BasicVector4; -typedef BasicVector4 Vector4; -class Matrix4; -typedef Vector4 Quaternion; -class AABB; class ComponentSelectionTestable { diff --git a/libs/stringio.h b/libs/stringio.h index 83572e2f..022706bb 100644 --- a/libs/stringio.h +++ b/libs/stringio.h @@ -288,11 +288,6 @@ inline bool Tokeniser_nextTokenIsDigit( Tokeniser& tokeniser ){ return std::isdigit( c ) != 0; } -template -inline TextOutputStreamType& ostream_write( TextOutputStreamType& outputStream, const Vector3& v ){ - return outputStream << '(' << v.x() << ' ' << v.y() << ' ' << v.z() << ')'; -} - diff --git a/plugins/entity/namedentity.h b/plugins/entity/namedentity.h index af8e1698..07739889 100644 --- a/plugins/entity/namedentity.h +++ b/plugins/entity/namedentity.h @@ -91,8 +91,6 @@ typedef MemberCaller1 #include "renderable.h" -//#include "pivot.h" -//#include "math/frustum.h" #include "cullable.h" class RenderableNamedEntity : public OpenGLRenderable { @@ -117,7 +115,6 @@ public: } RenderableNamedEntity( NamedEntity& named, const Vector3& position, const char* exclude = 0 ) : m_named( named ), m_position( position ), m_tex( 0 ), m_exclude( exclude ) { -// construct_textures( g_showTargetNames ? m_named.name() : m_named.classname() ); construct_textures( m_named.name() ); m_named.attach( IdentifierChangedCaller( *this ) ); } @@ -182,76 +179,37 @@ public: setMode( selected, childSelected ); if( volume.fill() ){ -// globalOutputStream() << localToWorld << " localToWorld\n"; -// globalOutputStream() << volume.GetModelview() << " modelview\n"; -// globalOutputStream() << volume.GetProjection() << " Projection\n"; -// globalOutputStream() << volume.GetViewport() << " Viewport\n"; - //Matrix4 viewproj = matrix4_multiplied_by_matrix4( volume.GetProjection(), volume.GetModelview() ); const Matrix4& viewproj = volume.GetViewMatrix(); - //Vector3 viewer = vector4_to_vector3( viewer_from_viewproj( viewproj ) ); const Vector3 pos_in_world = matrix4_transformed_point( localToWorld, m_position ); - if( viewproj[3] * pos_in_world[0] + viewproj[7] * pos_in_world[1] + viewproj[11] * pos_in_world[2] + viewproj[15] < 3e-5 ) //z < 0: behind nearplane + if( viewproj[3] * pos_in_world[0] + viewproj[7] * pos_in_world[1] + viewproj[11] * pos_in_world[2] + viewproj[15] < 3e-5 ) //w < 0: behind nearplane return; if( m_nameMode == eNameNormal && vector3_length_squared( pos_in_world - volume.getViewer() ) > static_cast( g_showNamesDist ) * static_cast( g_showNamesDist ) ) return; - - //globalOutputStream() << viewer[0] << " " << viewer[1] << " " << viewer[2] << " Viewer\n"; - //globalOutputStream() << m_position[0] << " " << m_position[1] << " " << m_position[2] << " m_position\n"; - //globalOutputStream() << pos_in_world[0] << " " << pos_in_world[1] << " " << pos_in_world[2] << " pos_in_world\n"; } - Vector4 position( m_position, 1.f ); - -#if 0 -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " position\n"; - matrix4_transform_vector4( localToWorld, position ); -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " localToWorld\n"; - matrix4_transform_vector4( volume.GetModelview(), position ); -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " Modelview\n"; - matrix4_transform_vector4( volume.GetProjection(), position ); -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " Projection\n"; - position[0] /= position[3]; - position[1] /= position[3]; - position[2] /= position[3]; -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " Projection division\n"; - matrix4_transform_vector4( volume.GetViewport(), position ); -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " Viewport\n"; - -#else - //Matrix4 object2screen = volume.GetProjection(); Matrix4 object2screen( volume.GetViewMatrix() ); - //matrix4_multiply_by_matrix4( object2screen, volume.GetModelview() ); matrix4_multiply_by_matrix4( object2screen, localToWorld ); -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " position\n"; matrix4_transform_vector4( object2screen, position ); -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " Projection\n"; +// globalOutputStream() << position << " Projection\n"; position[0] /= position[3]; position[1] /= position[3]; position[2] /= position[3]; -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " Projection division\n"; +// globalOutputStream() << position << " Projection division\n"; matrix4_transform_vector4( volume.GetViewport(), position ); -// globalOutputStream() << position[0] << " " << position[1] << " " << position[2] << " " << position[3] << " Viewport\n"; -#endif - - //globalOutputStream() << volume.GetViewport()[0] << " " << volume.GetViewport()[5] << " Viewport size\n"; - +// globalOutputStream() << position << " Viewport\n"; +// globalOutputStream() << volume.GetViewport()[0] << " " << volume.GetViewport()[5] << " Viewport size\n"; m_screenPos[0] = position[0]; m_screenPos[1] = position[1]; - //globalOutputStream() << m_screenPos[0] << " " << m_screenPos[1] << "\n"; +// globalOutputStream() << m_screenPos[0] << " " << m_screenPos[1] << "\n"; renderer.PushState(); -// Pivot2World_viewplaneSpace( m_localToWorld, localToWorld, volume.GetModelview(), volume.GetProjection(), volume.GetViewport() ); - renderer.Highlight( Renderer::ePrimitive, false ); renderer.Highlight( Renderer::eFace, false ); renderer.SetState( getShader(), Renderer::eWireframeOnly ); renderer.SetState( getShader(), Renderer::eFullMaterials ); -// m_localToWorld = volume.GetViewport(); -// matrix4_full_invert( m_localToWorld ); - renderer.addRenderable( *this, g_matrix4_identity ); renderer.PopState(); @@ -262,7 +220,6 @@ public: } void identifierChanged( const char* value ){ delete_textures(); -// construct_textures( g_showTargetNames ? value : m_named.classname() ); construct_textures( value ); } typedef MemberCaller1 IdentifierChangedCaller; diff --git a/radiant/brush.h b/radiant/brush.h index 9aee6583..16fcdd5a 100644 --- a/radiant/brush.h +++ b/radiant/brush.h @@ -73,18 +73,6 @@ const unsigned int BRUSH_DETAIL_MASK = ( 1 << BRUSH_DETAIL_FLAG ); #define BRUSH_DEGENERATE_DEBUG 0 -inline void print_vector3( const Vector3& v ){ - globalOutputStream() << "( " << v.x() << " " << v.y() << " " << v.z() << " )\n"; -} - -inline void print_3x3( const Matrix4& m ){ - globalOutputStream() << "( " << m.xx() << " " << m.xy() << " " << m.xz() << " ) " - << "( " << m.yx() << " " << m.yy() << " " << m.yz() << " ) " - << "( " << m.zx() << " " << m.zy() << " " << m.zz() << " )\n"; -} - - - inline bool texdef_sane( const texdef_t& texdef ){ return fabs( texdef.shift[0] ) < ( 1 << 16 ) && fabs( texdef.shift[1] ) < ( 1 << 16 ); diff --git a/radiant/brush_primit.h b/radiant/brush_primit.h index f0ff98fe..37bdf26b 100644 --- a/radiant/brush_primit.h +++ b/radiant/brush_primit.h @@ -89,12 +89,6 @@ float Texdef_getDefaultTextureScale(); class texdef_t; struct Winding; -template class BasicVector3; -typedef BasicVector3 Vector3; -typedef BasicVector3 DoubleVector3; -template class BasicVector4; -typedef BasicVector4 Vector4; -typedef Vector4 Quaternion; class Matrix4; class Plane3; diff --git a/radiant/csg.h b/radiant/csg.h index e176422d..51e31eeb 100644 --- a/radiant/csg.h +++ b/radiant/csg.h @@ -22,10 +22,10 @@ #if !defined( INCLUDED_CSG_H ) #define INCLUDED_CSG_H -void CSG_MakeRoom( void ); -void CSG_Subtract( void ); -void CSG_Merge( void ); -void CSG_Tool( void ); +void CSG_MakeRoom(); +void CSG_Subtract(); +void CSG_Merge(); +void CSG_Tool(); namespace scene { diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index f298838f..1bee7102 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -523,8 +523,6 @@ AnglesEntry() : m_roll( 0 ), m_pitch( 0 ), m_yaw( 0 ){ } }; -typedef BasicVector3 DoubleVector3; - class AnglesAttribute : public EntityAttribute { CopiedString m_key; diff --git a/radiant/selection.cpp b/radiant/selection.cpp index 3b433919..a8b41389 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -52,14 +52,6 @@ #include "grid.h" -TextOutputStream& ostream_write( TextOutputStream& t, const Vector4& v ){ - return t << "[ " << v.x() << " " << v.y() << " " << v.z() << " " << v.w() << " ]"; -} - -TextOutputStream& ostream_write( TextOutputStream& t, const Matrix4& m ){ - return t << "[ " << m.x() << " " << m.y() << " " << m.z() << " " << m.t() << " ]"; -} - struct Pivot2World { Matrix4 m_worldSpace; diff --git a/radiant/winding.h b/radiant/winding.h index f1ce97b9..924e84bf 100644 --- a/radiant/winding.h +++ b/radiant/winding.h @@ -148,8 +148,6 @@ struct Winding } }; -typedef BasicVector3 DoubleVector3; - class DoubleLine { public: