X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fbrush_primit.h;h=79d27f3e98c188e0be76d9da19bca09bd115d859;hb=abb0694de849b6a844eea71cf2b6a4c0def53af5;hp=0420b4dc552f3d7b4c2ba828a77b84b232f820ed;hpb=02a51890a3d97a0e937fbb11071cf7c41cc00aa9;p=xonotic%2Fnetradiant.git diff --git a/radiant/brush_primit.h b/radiant/brush_primit.h index 0420b4dc..79d27f3e 100644 --- a/radiant/brush_primit.h +++ b/radiant/brush_primit.h @@ -25,139 +25,113 @@ #include "math/vector.h" #include "itexdef.h" #include "debugging/debugging.h" - // Timo // new brush primitive texdef -struct brushprimit_texdef_t { - brushprimit_texdef_t() - { - coords[0][0] = 2.0f; - coords[0][1] = 0.f; - coords[0][2] = 0.f; - coords[1][0] = 0.f; - coords[1][1] = 2.0f; - coords[1][2] = 0.f; - } - - void removeScale(std::size_t width, std::size_t height) - { +struct brushprimit_texdef_t +{ + brushprimit_texdef_t(){ + coords[0][0] = 2.0f; + coords[0][1] = 0.f; + coords[0][2] = 0.f; + coords[1][0] = 0.f; + coords[1][1] = 2.0f; + coords[1][2] = 0.f; + } + void removeScale( std::size_t width, std::size_t height ){ #if 1 - coords[0][0] *= width; - coords[0][1] *= width; - coords[0][2] *= width; - coords[1][0] *= height; - coords[1][1] *= height; - coords[1][2] *= height; + coords[0][0] *= width; + coords[0][1] *= width; + coords[0][2] *= width; + coords[1][0] *= height; + coords[1][1] *= height; + coords[1][2] *= height; #endif - } - - void addScale(std::size_t width, std::size_t height) - { + } + void addScale( std::size_t width, std::size_t height ){ #if 1 - ASSERT_MESSAGE(width > 0, "shader-width is 0"); - ASSERT_MESSAGE(height > 0, "shader-height is 0"); - coords[0][0] /= width; - coords[0][1] /= width; - coords[0][2] /= width; - coords[1][0] /= height; - coords[1][1] /= height; - coords[1][2] /= height; + ASSERT_MESSAGE( width > 0, "shader-width is 0" ); + ASSERT_MESSAGE( height > 0, "shader-height is 0" ); + coords[0][0] /= width; + coords[0][1] /= width; + coords[0][2] /= width; + coords[1][0] /= height; + coords[1][1] /= height; + coords[1][2] /= height; #endif - } - - float coords[2][3]; + } + float coords[2][3]; }; -class TextureProjection { +class TextureProjection +{ public: - texdef_t m_texdef; - brushprimit_texdef_t m_brushprimit_texdef; - Vector3 m_basis_s; - Vector3 m_basis_t; - - TextureProjection() - { - } - - TextureProjection( - const texdef_t &texdef, - const brushprimit_texdef_t &brushprimit_texdef, - const Vector3 &basis_s, - const Vector3 &basis_t - ) : - m_texdef(texdef), - m_brushprimit_texdef(brushprimit_texdef), - m_basis_s(basis_s), - m_basis_t(basis_t) - { - } +texdef_t m_texdef; +brushprimit_texdef_t m_brushprimit_texdef; +Vector3 m_basis_s; +Vector3 m_basis_t; + +TextureProjection(){ +} +TextureProjection( + const texdef_t& texdef, + const brushprimit_texdef_t& brushprimit_texdef, + const Vector3& basis_s, + const Vector3& basis_t + ) : + m_texdef( texdef ), + m_brushprimit_texdef( brushprimit_texdef ), + m_basis_s( basis_s ), + m_basis_t( basis_t ){ +} }; float Texdef_getDefaultTextureScale(); class texdef_t; - struct Winding; - -template -class BasicVector3; - +template class BasicVector3; typedef BasicVector3 Vector3; - -template -class BasicVector4; - +template class BasicVector4; typedef BasicVector4 Vector4; typedef Vector4 Quaternion; - class Matrix4; - class Plane3; -void Normal_GetTransform(const Vector3 &normal, Matrix4 &transform); - -void TexDef_Construct_Default(TextureProjection &projection); - -void Texdef_Assign(TextureProjection &projection, const TextureProjection &other); - -void Texdef_Shift(TextureProjection &projection, float s, float t); - -void Texdef_Scale(TextureProjection &projection, float s, float t); - -void Texdef_Rotate(TextureProjection &projection, float angle); - -void Texdef_FitTexture(TextureProjection &projection, std::size_t width, std::size_t height, const Vector3 &normal, - const Winding &w, float s_repeat, float t_repeat); - -void -Texdef_EmitTextureCoordinates(const TextureProjection &projection, std::size_t width, std::size_t height, Winding &w, - const Vector3 &normal, const Matrix4 &localToWorld); +void Normal_GetTransform( const Vector3& normal, Matrix4& transform ); -void ShiftScaleRotate_fromFace(texdef_t &shiftScaleRotate, const TextureProjection &projection); +void TexDef_Construct_Default( TextureProjection& projection ); -void ShiftScaleRotate_toFace(const texdef_t &shiftScaleRotate, TextureProjection &projection); +void Texdef_Assign( TextureProjection& projection, const TextureProjection& other ); +void Texdef_Shift( TextureProjection& projection, float s, float t ); +void Texdef_Scale( TextureProjection& projection, float s, float t ); +void Texdef_Rotate( TextureProjection& projection, float angle ); +void Texdef_FitTexture( TextureProjection& projection, std::size_t width, std::size_t height, const Vector3& normal, const Winding& w, float s_repeat, float t_repeat ); +void Texdef_EmitTextureCoordinates( const TextureProjection& projection, std::size_t width, std::size_t height, Winding& w, const Vector3& normal, const Matrix4& localToWorld ); -void Texdef_transformLocked(TextureProjection &projection, std::size_t width, std::size_t height, const Plane3 &plane, - const Matrix4 &transform); +void ShiftScaleRotate_fromFace( texdef_t& shiftScaleRotate, const TextureProjection& projection ); +void ShiftScaleRotate_toFace( const texdef_t& shiftScaleRotate, TextureProjection& projection ); -void Texdef_normalise(TextureProjection &projection, float width, float height); +void Texdef_transformLocked( TextureProjection& projection, std::size_t width, std::size_t height, const Plane3& plane, const Matrix4& transform ); +void Texdef_normalise( TextureProjection& projection, float width, float height ); -enum TexdefTypeId { - TEXDEFTYPEID_QUAKE, - TEXDEFTYPEID_BRUSHPRIMITIVES, - TEXDEFTYPEID_HALFLIFE, +enum TexdefTypeId +{ + TEXDEFTYPEID_QUAKE, + TEXDEFTYPEID_BRUSHPRIMITIVES, + TEXDEFTYPEID_HALFLIFE, }; -struct bp_globals_t { - // tells if we are internally using brush primitive (texture coordinates and map format) - // this is a shortcut for IntForKey( g_qeglobals.d_project_entity, "brush_primit" ) - // NOTE: must keep the two ones in sync - TexdefTypeId m_texdefTypeId; +struct bp_globals_t +{ + // tells if we are internally using brush primitive (texture coordinates and map format) + // this is a shortcut for IntForKey( g_qeglobals.d_project_entity, "brush_primit" ) + // NOTE: must keep the two ones in sync + TexdefTypeId m_texdefTypeId; }; extern bp_globals_t g_bp_globals; extern float g_texdef_default_scale; -void ComputeAxisBase(const Vector3 &normal, Vector3 &texS, Vector3 &texT); +void ComputeAxisBase( const Vector3& normal, Vector3& texS, Vector3& texT ); #endif