clean namedentity, forward declarations, ostream_write

This commit is contained in:
Garux 2018-02-22 18:56:53 +03:00
parent 327fa13d54
commit eae7ac024a
17 changed files with 26 additions and 122 deletions

View File

@ -22,12 +22,7 @@
#if !defined( INCLUDED_EDITABLE_H )
#define INCLUDED_EDITABLE_H
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
template<typename Element> class BasicVector4;
typedef BasicVector4<float> Vector4;
class Matrix4;
typedef Vector4 Quaternion;
#include "scenelib.h"

View File

@ -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<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
class Shader;
class RendererLight
@ -115,8 +113,6 @@ class Matrix4;
struct qtexture_t;
class ModuleObserver;
#include "generic/vector.h"
class Shader
{
public:

View File

@ -54,7 +54,6 @@ template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
template<typename Element> class BasicVector4;
typedef BasicVector4<float> Vector4;
class Matrix4;
typedef Vector4 Quaternion;
typedef Callback1<const Selectable&> SelectionChangeCallback;

View File

@ -42,10 +42,6 @@ enum
struct qtexture_t;
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
typedef Vector3 Colour3;
typedef unsigned char BlendFactor;
const BlendFactor BLEND_ZERO = 0;
const BlendFactor BLEND_ONE = 1;

View File

@ -120,8 +120,6 @@ virtual Type* findModule( const char* name ) = 0;
virtual void foreachModule( const Visitor& visitor ) = 0;
};
#include "debugging/debugging.h"
template<typename Type>
class ModuleRef
{

View File

@ -219,13 +219,9 @@ pointer m_indices;
pointer m_finish;
};
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
class Matrix4;
class VolumeTest;
typedef BasicVector3<double> DoubleVector3;
class SelectionTest
{
public:

View File

@ -205,8 +205,22 @@ typedef BasicVector2<float> Vector2;
/// \brief A 3-element vector stored in single-precision floating-point.
typedef BasicVector3<float> Vector3;
/// \brief A 3-element vector stored in double-precision floating-point.
typedef BasicVector3<double> DoubleVector3;
/// \brief A 4-element vector stored in single-precision floating-point.
typedef BasicVector4<float> Vector4;
template<typename TextOutputStreamType>
inline TextOutputStreamType& ostream_write( TextOutputStreamType& outputStream, const Vector3& v ){
return outputStream << '(' << v.x() << ' ' << v.y() << ' ' << v.z() << ')';
}
template<typename TextOutputStreamType>
TextOutputStreamType& ostream_write( TextOutputStreamType& t, const Vector4& v ){
return t << "[ " << v.x() << " " << v.y() << " " << v.z() << " " << v.w() << " ]";
}
#endif

View File

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

View File

@ -38,14 +38,6 @@
class Selector;
class SelectionTest;
class VolumeTest;
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
template<typename Element> class BasicVector4;
typedef BasicVector4<float> Vector4;
class Matrix4;
typedef Vector4 Quaternion;
class AABB;
class ComponentSelectionTestable
{

View File

@ -288,11 +288,6 @@ inline bool Tokeniser_nextTokenIsDigit( Tokeniser& tokeniser ){
return std::isdigit( c ) != 0;
}
template<typename TextOutputStreamType>
inline TextOutputStreamType& ostream_write( TextOutputStreamType& outputStream, const Vector3& v ){
return outputStream << '(' << v.x() << ' ' << v.y() << ' ' << v.z() << ')';
}

View File

@ -91,8 +91,6 @@ typedef MemberCaller1<NamedEntity, const char*, &NamedEntity::identifierChanged>
#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<float>( g_showNamesDist ) * static_cast<float>( 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<RenderableNamedEntity, const char*, &RenderableNamedEntity::identifierChanged> IdentifierChangedCaller;

View File

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

View File

@ -89,12 +89,6 @@ float Texdef_getDefaultTextureScale();
class texdef_t;
struct Winding;
template<typename Element> class BasicVector3;
typedef BasicVector3<float> Vector3;
typedef BasicVector3<double> DoubleVector3;
template<typename Element> class BasicVector4;
typedef BasicVector4<float> Vector4;
typedef Vector4 Quaternion;
class Matrix4;
class Plane3;

View File

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

View File

@ -523,8 +523,6 @@ AnglesEntry() : m_roll( 0 ), m_pitch( 0 ), m_yaw( 0 ){
}
};
typedef BasicVector3<double> DoubleVector3;
class AnglesAttribute : public EntityAttribute
{
CopiedString m_key;

View File

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

View File

@ -148,8 +148,6 @@ struct Winding
}
};
typedef BasicVector3<double> DoubleVector3;
class DoubleLine
{
public: