qbsp: fix texture offset on rotate_object, so they match in the editor. Added "-oldrottex" flag to revert to old behaviour. From txqbsp-xt.
This commit is contained in:
parent
05bddc62e9
commit
ed66ed112e
|
|
@ -62,6 +62,9 @@ Space between leakfile points (default 2)
|
||||||
Use different texture subdivision (default 240)
|
Use different texture subdivision (default 240)
|
||||||
.IP "\fB\-wadpath <dir>\fP"
|
.IP "\fB\-wadpath <dir>\fP"
|
||||||
Search this directory for wad files (default is cwd)
|
Search this directory for wad files (default is cwd)
|
||||||
|
.IP "\fB\-oldrottex\fP"
|
||||||
|
Use old method of texturing rotate_ brushes where the mapper aligns
|
||||||
|
textures for the object at (0 0 0).
|
||||||
|
|
||||||
.SH "SPECIAL TEXTURE NAMES"
|
.SH "SPECIAL TEXTURE NAMES"
|
||||||
.PP
|
.PP
|
||||||
|
|
|
||||||
20
qbsp/brush.c
20
qbsp/brush.c
|
|
@ -423,6 +423,26 @@ CreateBrushFaces(hullbrush_t *hullbrush, const vec3_t rotate_offset,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// account for texture offset, from txqbsp-xt
|
||||||
|
if (options.fixRotateObjTexture) {
|
||||||
|
const texinfo_t *texinfo = pWorldEnt->lumps[LUMP_TEXINFO].data;
|
||||||
|
texinfo_t texInfoNew;
|
||||||
|
vec3_t vecs[2];
|
||||||
|
int k, l;
|
||||||
|
|
||||||
|
memcpy(&texInfoNew, &texinfo[ mapface->texinfo ], sizeof(texInfoNew));
|
||||||
|
for (k=0; k<2; k++) {
|
||||||
|
for (l=0; l<3; l++) {
|
||||||
|
vecs[k][l] = texinfo[ mapface->texinfo ].vecs[k][l];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
texInfoNew.vecs[0][3] += DotProduct( rotate_offset, vecs[0] );
|
||||||
|
texInfoNew.vecs[1][3] += DotProduct( rotate_offset, vecs[1] );
|
||||||
|
|
||||||
|
mapface->texinfo = FindTexinfo( &texInfoNew );
|
||||||
|
}
|
||||||
|
|
||||||
VectorCopy(mapface->plane.normal, plane.normal);
|
VectorCopy(mapface->plane.normal, plane.normal);
|
||||||
VectorScale(mapface->plane.normal, mapface->plane.dist, point);
|
VectorScale(mapface->plane.normal, mapface->plane.dist, point);
|
||||||
VectorSubtract(point, rotate_offset, point);
|
VectorSubtract(point, rotate_offset, point);
|
||||||
|
|
|
||||||
23
qbsp/map.c
23
qbsp/map.c
|
|
@ -146,7 +146,7 @@ FindTexinfo
|
||||||
Returns a global texinfo number
|
Returns a global texinfo number
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
FindTexinfo(texinfo_t *texinfo)
|
FindTexinfo(texinfo_t *texinfo)
|
||||||
{
|
{
|
||||||
int index, j;
|
int index, j;
|
||||||
|
|
@ -187,6 +187,9 @@ FindTexinfo(texinfo_t *texinfo)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (index >= pWorldEnt->lumps[LUMP_TEXINFO].count)
|
||||||
|
Error("Internal error: didn't allocate enough texinfos?");
|
||||||
|
|
||||||
/* Allocate a new texinfo at the end of the array */
|
/* Allocate a new texinfo at the end of the array */
|
||||||
*target = *texinfo;
|
*target = *texinfo;
|
||||||
pWorldEnt->lumps[LUMP_TEXINFO].index++;
|
pWorldEnt->lumps[LUMP_TEXINFO].index++;
|
||||||
|
|
@ -691,9 +694,12 @@ PreParseFile(const char *buf)
|
||||||
*/
|
*/
|
||||||
map.maxmiptex = map.maxfaces + 100;
|
map.maxmiptex = map.maxfaces + 100;
|
||||||
map.miptex = AllocMem(MIPTEX, map.maxmiptex, true);
|
map.miptex = AllocMem(MIPTEX, map.maxmiptex, true);
|
||||||
|
|
||||||
|
/* Fixing textures on rotate_object requires an extra texinfo per face */
|
||||||
|
map.maxtexinfo = map.maxfaces * 2;
|
||||||
texinfo = &pWorldEnt->lumps[LUMP_TEXINFO];
|
texinfo = &pWorldEnt->lumps[LUMP_TEXINFO];
|
||||||
texinfo->data = AllocMem(BSP_TEXINFO, map.maxfaces, true);
|
texinfo->data = AllocMem(BSP_TEXINFO, map.maxtexinfo, true);
|
||||||
texinfo->count = map.maxfaces;
|
texinfo->count = map.maxtexinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -720,7 +726,6 @@ LoadMapFile(void)
|
||||||
parser_t parser;
|
parser_t parser;
|
||||||
char *buf;
|
char *buf;
|
||||||
int length;
|
int length;
|
||||||
void *pTemp;
|
|
||||||
struct lumpdata *texinfo;
|
struct lumpdata *texinfo;
|
||||||
mapentity_t *entity;
|
mapentity_t *entity;
|
||||||
|
|
||||||
|
|
@ -757,15 +762,7 @@ LoadMapFile(void)
|
||||||
// Message(msgWarning, warnNoPlayerCoop);
|
// Message(msgWarning, warnNoPlayerCoop);
|
||||||
|
|
||||||
texinfo = &pWorldEnt->lumps[LUMP_TEXINFO];
|
texinfo = &pWorldEnt->lumps[LUMP_TEXINFO];
|
||||||
if (texinfo->index > texinfo->count)
|
|
||||||
Error("Internal error: didn't allocate enough texinfos?");
|
|
||||||
else if (texinfo->index < texinfo->count) {
|
|
||||||
pTemp = texinfo->data;
|
|
||||||
texinfo->data = AllocMem(BSP_TEXINFO, texinfo->index, true);
|
|
||||||
memcpy(texinfo->data, pTemp, texinfo->index * MemSize[BSP_TEXINFO]);
|
|
||||||
FreeMem(pTemp, BSP_TEXINFO, texinfo->count);
|
|
||||||
texinfo->count = texinfo->index;
|
|
||||||
}
|
|
||||||
map.maxplanes = MAX_MAP_PLANES;
|
map.maxplanes = MAX_MAP_PLANES;
|
||||||
map.planes = AllocMem(PLANE, map.maxplanes, true);
|
map.planes = AllocMem(PLANE, map.maxplanes, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -381,6 +381,7 @@ PrintOptions(void)
|
||||||
" -leakdist [n] Space between leakfile points (default 2)\n"
|
" -leakdist [n] Space between leakfile points (default 2)\n"
|
||||||
" -subdivide [n] Use different texture subdivision (default 240)\n"
|
" -subdivide [n] Use different texture subdivision (default 240)\n"
|
||||||
" -wadpath <dir> Search this directory for wad files\n"
|
" -wadpath <dir> Search this directory for wad files\n"
|
||||||
|
" -oldrottex Use old rotate_ brush texturing aligned at (0 0 0)\n"
|
||||||
" sourcefile .MAP file to process\n"
|
" sourcefile .MAP file to process\n"
|
||||||
" destfile .BSP file to output\n");
|
" destfile .BSP file to output\n");
|
||||||
|
|
||||||
|
|
@ -450,6 +451,7 @@ ParseOptions(char *szOptions)
|
||||||
/* Default to the original Quake BSP Version... */
|
/* Default to the original Quake BSP Version... */
|
||||||
options.BSPVersion = BSPVERSION;
|
options.BSPVersion = BSPVERSION;
|
||||||
options.fTranswater = true;
|
options.fTranswater = true;
|
||||||
|
options.fixRotateObjTexture = true;
|
||||||
|
|
||||||
szEnd = szOptions + strlen(szOptions);
|
szEnd = szOptions + strlen(szOptions);
|
||||||
szTok = GetTok(szOptions, szEnd);
|
szTok = GetTok(szOptions, szEnd);
|
||||||
|
|
@ -522,7 +524,9 @@ ParseOptions(char *szOptions)
|
||||||
/* Remove trailing /, if any */
|
/* Remove trailing /, if any */
|
||||||
if (options.wadPath[strlen(options.wadPath) - 1] == '/')
|
if (options.wadPath[strlen(options.wadPath) - 1] == '/')
|
||||||
options.wadPath[strlen(options.wadPath) - 1] = 0;
|
options.wadPath[strlen(options.wadPath) - 1] = 0;
|
||||||
} else if (!strcasecmp(szTok, "?") || !strcasecmp(szTok, "help"))
|
} else if (!strcasecmp(szTok, "oldrottex")) {
|
||||||
|
options.fixRotateObjTexture = false;
|
||||||
|
} else if (!strcasecmp(szTok, "?") || !strcasecmp(szTok, "help"))
|
||||||
PrintOptions();
|
PrintOptions();
|
||||||
else
|
else
|
||||||
Error("Unknown option '%s'", szTok);
|
Error("Unknown option '%s'", szTok);
|
||||||
|
|
|
||||||
|
|
@ -447,6 +447,7 @@ typedef struct options_s {
|
||||||
bool fOldleak;
|
bool fOldleak;
|
||||||
bool fNopercent;
|
bool fNopercent;
|
||||||
bool forceGoodTree;
|
bool forceGoodTree;
|
||||||
|
bool fixRotateObjTexture;
|
||||||
int BSPVersion;
|
int BSPVersion;
|
||||||
int dxSubdivide;
|
int dxSubdivide;
|
||||||
int dxLeakDist;
|
int dxLeakDist;
|
||||||
|
|
@ -502,6 +503,7 @@ typedef struct mapdata_s {
|
||||||
int maxentities;
|
int maxentities;
|
||||||
int maxplanes;
|
int maxplanes;
|
||||||
int maxmiptex;
|
int maxmiptex;
|
||||||
|
int maxtexinfo;
|
||||||
|
|
||||||
/* Number of items currently used */
|
/* Number of items currently used */
|
||||||
int numfaces;
|
int numfaces;
|
||||||
|
|
@ -531,6 +533,7 @@ extern mapentity_t *pWorldEnt;
|
||||||
void LoadMapFile(void);
|
void LoadMapFile(void);
|
||||||
|
|
||||||
int FindMiptex(const char *name);
|
int FindMiptex(const char *name);
|
||||||
|
int FindTexinfo(texinfo_t *texinfo);
|
||||||
|
|
||||||
void PrintEntity(const mapentity_t *entity);
|
void PrintEntity(const mapentity_t *entity);
|
||||||
const char *ValueForKey(const mapentity_t *entity, const char *key);
|
const char *ValueForKey(const mapentity_t *entity, const char *key);
|
||||||
|
|
|
||||||
|
|
@ -726,6 +726,19 @@ FinishBSPFile(void)
|
||||||
planes->data = newdata;
|
planes->data = newdata;
|
||||||
planes->count = map.cTotal[LUMP_PLANES];
|
planes->count = map.cTotal[LUMP_PLANES];
|
||||||
|
|
||||||
|
// Shrink texinfo lump
|
||||||
|
{
|
||||||
|
struct lumpdata *texinfo;
|
||||||
|
void *pTemp;
|
||||||
|
|
||||||
|
texinfo = &pWorldEnt->lumps[LUMP_TEXINFO];
|
||||||
|
pTemp = texinfo->data;
|
||||||
|
texinfo->data = AllocMem(BSP_TEXINFO, texinfo->index, true);
|
||||||
|
memcpy(texinfo->data, pTemp, texinfo->index * MemSize[BSP_TEXINFO]);
|
||||||
|
FreeMem(pTemp, BSP_TEXINFO, texinfo->count);
|
||||||
|
texinfo->count = texinfo->index;
|
||||||
|
}
|
||||||
|
|
||||||
PrintBSPFileSizes();
|
PrintBSPFileSizes();
|
||||||
CleanBSPTexinfoFlags();
|
CleanBSPTexinfoFlags();
|
||||||
WriteBSPFile();
|
WriteBSPFile();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue