- }
-}
-
-inline void Texdef_fromTransform(texdef_t& texdef, float width, float height, const Matrix4& transform)
-{
- texdef.scale[0] = static_cast<float>((1.0 / vector2_length(Vector2(transform[0], transform[4]))) / width);
- texdef.scale[1] = static_cast<float>((1.0 / vector2_length(Vector2(transform[1], transform[5]))) / height);
-
- texdef.rotate = static_cast<float>(-radians_to_degrees(arctangent_yx(-transform[4], transform[0])));
-
- if(texdef.rotate == -180.0f)
- {
- texdef.rotate = 180.0f;
- }
-
- texdef.shift[0] = transform[12] * width;
- texdef.shift[1] = transform[13] * height;
-
- // If the 2d cross-product of the x and y axes is positive, one of the axes has a negative scale.
- if(vector2_cross(Vector2(transform[0], transform[4]), Vector2(transform[1], transform[5])) > 0)
- {
- if(texdef.rotate >= 180.0f)
- {
- texdef.rotate -= 180.0f;
- texdef.scale[0] = -texdef.scale[0];
- }
- else
- {
- texdef.scale[1] = -texdef.scale[1];
- }
- }
- //globalOutputStream() << "fromTransform: " << texdef.shift[0] << " " << texdef.shift[1] << " " << texdef.scale[0] << " " << texdef.scale[1] << " " << texdef.rotate << "\n";
-}
-
-inline void BPTexdef_fromTransform(brushprimit_texdef_t& bp_texdef, const Matrix4& transform)
-{
- bp_texdef.coords[0][0] = transform.xx();
- bp_texdef.coords[0][1] = transform.yx();
- bp_texdef.coords[0][2] = transform.tx();
- bp_texdef.coords[1][0] = transform.xy();
- bp_texdef.coords[1][1] = transform.yy();
- bp_texdef.coords[1][2] = transform.ty();
-}
-
-inline void Texdef_fromTransform(TextureProjection& projection, float width, float height, const Matrix4& transform)
-{
- ASSERT_MESSAGE((transform[0] != 0 || transform[4] != 0)
- && (transform[1] != 0 || transform[5] != 0), "invalid texture matrix");
-
- if(g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES)
- {
- BPTexdef_fromTransform(projection.m_brushprimit_texdef, transform);
- }
- else
- {
- Texdef_fromTransform(projection.m_texdef, width, height, transform);
- }
-}
-
-inline void Texdef_normalise(texdef_t& texdef, float width, float height)
-{
- // it may be useful to also normalise the rotation here, if this function is used elsewhere.
- texdef.shift[0] = float_mod(texdef.shift[0], width);
- texdef.shift[1] = float_mod(texdef.shift[1], height);
- //globalOutputStream() << "normalise: " << texdef.shift[0] << " " << texdef.shift[1] << " " << texdef.scale[0] << " " << texdef.scale[1] << " " << texdef.rotate << "\n";
-}
-
-inline void BPTexdef_normalise(brushprimit_texdef_t& bp_texdef, float width, float height)
-{
- bp_texdef.coords[0][2] = float_mod(bp_texdef.coords[0][2], width);
- bp_texdef.coords[1][2] = float_mod(bp_texdef.coords[1][2], height);
+ }
+}
+
+inline void Texdef_fromTransform( texdef_t& texdef, float width, float height, const Matrix4& transform ){
+ texdef.scale[0] = static_cast<float>( ( 1.0 / vector2_length( Vector2( transform[0], transform[4] ) ) ) / width );
+ texdef.scale[1] = static_cast<float>( ( 1.0 / vector2_length( Vector2( transform[1], transform[5] ) ) ) / height );
+
+ texdef.rotate = static_cast<float>( -radians_to_degrees( arctangent_yx( -transform[4], transform[0] ) ) );
+
+ if ( texdef.rotate == -180.0f ) {
+ texdef.rotate = 180.0f;
+ }
+
+ texdef.shift[0] = transform[12] * width;
+ texdef.shift[1] = transform[13] * height;
+
+ // If the 2d cross-product of the x and y axes is positive, one of the axes has a negative scale.
+ if ( vector2_cross( Vector2( transform[0], transform[4] ), Vector2( transform[1], transform[5] ) ) > 0 ) {
+ if ( texdef.rotate >= 180.0f ) {
+ texdef.rotate -= 180.0f;
+ texdef.scale[0] = -texdef.scale[0];
+ }
+ else
+ {
+ texdef.scale[1] = -texdef.scale[1];
+ }
+ }
+ //globalOutputStream() << "fromTransform: " << texdef.shift[0] << " " << texdef.shift[1] << " " << texdef.scale[0] << " " << texdef.scale[1] << " " << texdef.rotate << "\n";
+}
+
+inline void BPTexdef_fromTransform( brushprimit_texdef_t& bp_texdef, const Matrix4& transform ){
+ bp_texdef.coords[0][0] = transform.xx();
+ bp_texdef.coords[0][1] = transform.yx();
+ bp_texdef.coords[0][2] = transform.tx();
+ bp_texdef.coords[1][0] = transform.xy();
+ bp_texdef.coords[1][1] = transform.yy();
+ bp_texdef.coords[1][2] = transform.ty();
+}
+
+inline void Texdef_fromTransform( TextureProjection& projection, float width, float height, const Matrix4& transform ){
+ ASSERT_MESSAGE( ( transform[0] != 0 || transform[4] != 0 )
+ && ( transform[1] != 0 || transform[5] != 0 ), "invalid texture matrix" );
+
+ if ( g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES ) {
+ BPTexdef_fromTransform( projection.m_brushprimit_texdef, transform );
+ }
+ else
+ {
+ Texdef_fromTransform( projection.m_texdef, width, height, transform );
+ }
+}
+
+inline void Texdef_normalise( texdef_t& texdef, float width, float height ){
+ // it may be useful to also normalise the rotation here, if this function is used elsewhere.
+ texdef.shift[0] = float_mod( texdef.shift[0], width );
+ texdef.shift[1] = float_mod( texdef.shift[1], height );
+ //globalOutputStream() << "normalise: " << texdef.shift[0] << " " << texdef.shift[1] << " " << texdef.scale[0] << " " << texdef.scale[1] << " " << texdef.rotate << "\n";
+}
+
+inline void BPTexdef_normalise( brushprimit_texdef_t& bp_texdef, float width, float height ){
+ bp_texdef.coords[0][2] = float_mod( bp_texdef.coords[0][2], width );
+ bp_texdef.coords[1][2] = float_mod( bp_texdef.coords[1][2], height );