-void BrushPrimitFaceToFace(face_t *face)
-{
- // we have parsed brush primitives and need conversion back to standard format
- // NOTE: converting back is a quick hack, there's some information lost and we can't do anything about it
- // FIXME: if we normalize the texture matrix to a standard 2x2 size, we end up with wrong scaling
- // I tried various tweaks, no luck .. seems shifting is lost
- brushprimit_texdef_t aux;
- ConvertTexMatWithQTexture( &face->brushprimit_texdef, face->d_texture, &aux, NULL );
- TexMatToFakeTexCoords( aux.coords, face->texdef.shift, &face->texdef.rotate, face->texdef.scale );
- face->texdef.scale[0]/=2.0;
- face->texdef.scale[1]/=2.0;
+void BrushPrimitFaceToFace( face_t *f ){
+#if 0
+ // we have parsed brush primitives and need conversion back to standard format
+ // NOTE: converting back is a quick hack, there's some information lost and we can't do anything about it
+ // FIXME: if we normalize the texture matrix to a standard 2x2 size, we end up with wrong scaling
+ // I tried various tweaks, no luck .. seems shifting is lost
+ brushprimit_texdef_t aux;
+ ConvertTexMatWithQTexture( &face->brushprimit_texdef, face->d_texture, &aux, NULL );
+ TexMatToFakeTexCoords( aux.coords, face->texdef.shift, &face->texdef.rotate, face->texdef.scale );
+ face->texdef.scale[0] /= 2.0;
+ face->texdef.scale[1] /= 2.0;
+#else
+ // new method by divVerent@alientrap.org: Shift and scale no longer get lost when opening a BP map in texdef mode.
+ vec3_t texX,texY;
+ vec3_t proj;
+ vec_t ST[3][5];
+
+ ComputeAxisBase( f->plane.normal,texX,texY );
+ VectorCopy( f->plane.normal,proj );
+ VectorScale( proj,f->plane.dist,proj );
+ VectorCopy( proj,ST[0] );
+ VectorCopy( texX,ST[1] );
+ VectorAdd( ST[1],proj,ST[1] );
+ VectorCopy( texY,ST[2] );
+ VectorAdd( ST[2],proj,ST[2] );
+
+ ST[0][3] = f->brushprimit_texdef.coords[0][2];
+ ST[0][4] = f->brushprimit_texdef.coords[1][2];
+ ST[1][3] = f->brushprimit_texdef.coords[0][0] + ST[0][3];
+ ST[1][4] = f->brushprimit_texdef.coords[1][0] + ST[0][4];
+ ST[2][3] = f->brushprimit_texdef.coords[0][1] + ST[0][3];
+ ST[2][4] = f->brushprimit_texdef.coords[1][1] + ST[0][4];
+
+ Face_TexdefFromTextureCoordinates( ST[0], ST[1], ST[2], f->d_texture, f );
+#endif