mbspc: write decent default map220 texdef

This commit is contained in:
Garux
2024-12-20 16:28:26 +05:00
parent de622a9cc0
commit fbf88ecefb
3 changed files with 24 additions and 11 deletions
+20 -7
View File
@@ -684,6 +684,20 @@ get_shader_ptr(int bidx, int sidx)
}
qboolean g_bsp2map220;
static void WriteDefaultTexDef( FILE *fp, const vec3_t normal ){
if( g_bsp2map220 ){ // " [ 1 0 0 0 ] [ 0 1 0 0 ] 0 1 1"
vec3_t vecs[2];
TextureAxisFromPlane(normal, vecs[0], vecs[1]);
fprintf(fp, " [ %g %g %g 0 ] [ %g %g %g 0 ] 0 1 1",
vecs[0][0], vecs[0][1], vecs[0][2],
vecs[1][0], vecs[1][1], vecs[1][2] );
}
else{
fprintf( fp, " 0 0 0 1 1" );
}
}
//===========================================================================
//
// Parameter: -
@@ -699,7 +713,6 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
winding_t *w;
side_t *s;
plane_t *plane;
const char* defAlign = g_bsp2map220? "[ 1 0 0 0 ] [ 0 1 0 0 ] 0 1 1" : "0 0 0 1 1";
if (noliquids)
{
@@ -796,7 +809,7 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
Log_Write("brush->contents = %d\n", brush->contents);
}
fprintf( fp, " %s", defAlign );
WriteDefaultTexDef( fp, plane->normal );
if ( loadedmaptype == MAPTYPE_QUAKE3 )
fprintf( fp, " 0 0 0" );
@@ -816,7 +829,7 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
fprintf(fp, "generic/misc/red");
}
fprintf( fp, " %s", defAlign );
WriteDefaultTexDef( fp, plane->normal );
}
else if (loadedmaptype == MAPTYPE_QUAKE3)
{
@@ -847,7 +860,8 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
}
}
fprintf( fp, " %s 0 0 0", defAlign );
WriteDefaultTexDef( fp, plane->normal );
fprintf( fp, " 0 0 0" );
}
else
@@ -858,7 +872,7 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin)
scale[0] = 1 / VectorNormalize2(ti->vecs[0], vecs[0]);
scale[1] = 1 / VectorNormalize2(ti->vecs[1], vecs[1]);
//
TextureAxisFromPlane(plane, axis[0], axis[1]);
TextureAxisFromPlane(plane->normal, axis[0], axis[1]);
//calculate texture shift done by entity origin
originshift[0] = DotProduct(origin, axis[0]);
originshift[1] = DotProduct(origin, axis[1]);
@@ -926,7 +940,6 @@ qboolean WriteOriginBrush(FILE *fp, vec3_t origin)
float dist;
int i, s;
winding_t *w;
const char* defAlign = g_bsp2map220? "[ 1 0 0 0 ] [ 0 1 0 0 ] 0 1 1" : "0 0 0 1 1";
fprintf(fp, " {\n");
//
@@ -966,7 +979,7 @@ qboolean WriteOriginBrush(FILE *fp, vec3_t origin)
fprintf(fp, "origin");
}
fprintf( fp, " %s", defAlign );
WriteDefaultTexDef(fp, normal);
if ( loadedmaptype == MAPTYPE_QUAKE3 )
fprintf( fp, " 0 0 0" );
+1 -1
View File
@@ -423,7 +423,7 @@ extern textureref_t textureref[MAX_MAP_TEXTURES];
int FindMiptex(char *name);
int TexinfoForBrushTexture(plane_t *plane, brush_texture_t *bt, vec3_t origin);
void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv);
void TextureAxisFromPlane(const vec3_t normal, vec3_t xv, vec3_t yv);
//=============================================================================
// csg
+3 -3
View File
@@ -82,7 +82,7 @@ vec3_t baseaxis[18] =
{0,-1,0}, {1,0,0}, {0,0,-1} // north wall
};
void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv)
void TextureAxisFromPlane(const vec3_t normal, vec3_t xv, vec3_t yv)
{
int bestaxis;
vec_t dot,best;
@@ -93,7 +93,7 @@ void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv)
for (i=0 ; i<6 ; i++)
{
dot = DotProduct (pln->normal, baseaxis[i*3]);
dot = DotProduct (normal, baseaxis[i*3]);
if (dot > best)
{
best = dot;
@@ -128,7 +128,7 @@ int TexinfoForBrushTexture(plane_t *plane, brush_texture_t *bt, vec3_t origin)
memset (&tx, 0, sizeof(tx));
strcpy (tx.texture, bt->name);
TextureAxisFromPlane(plane, vecs[0], vecs[1]);
TextureAxisFromPlane(plane->normal, vecs[0], vecs[1]);
shift[0] = DotProduct (origin, vecs[0]);
shift[1] = DotProduct (origin, vecs[1]);