Hardware renderer: Fix polyobjects
This commit is contained in:
parent
a4a529bdb5
commit
0bcf89679e
|
@ -677,7 +677,7 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
|
||||||
return grtex;
|
return grtex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lactozilla
|
// HWR_RenderPlane and HWR_RenderPolyObjectPlane need this to get the flat dimensions from a patch.
|
||||||
lumpnum_t gr_patchflat;
|
lumpnum_t gr_patchflat;
|
||||||
|
|
||||||
static void HWR_LoadPatchFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
static void HWR_LoadPatchFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||||
|
|
|
@ -3172,6 +3172,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
INT32 i;
|
INT32 i;
|
||||||
float flatxref,flatyref;
|
float flatxref,flatyref;
|
||||||
float fflatwidth, fflatheight;
|
float fflatwidth, fflatheight;
|
||||||
|
INT32 flatflag;
|
||||||
|
boolean texflat = true;
|
||||||
size_t len;
|
size_t len;
|
||||||
float scrollx = 0.0f, scrolly = 0.0f;
|
float scrollx = 0.0f, scrolly = 0.0f;
|
||||||
angle_t angle = 0;
|
angle_t angle = 0;
|
||||||
|
@ -3231,22 +3233,25 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gr_patchflat && R_CheckIfPatch(gr_patchflat)) // Just in case?
|
flatflag = ((INT32)fflatwidth)-1;
|
||||||
{
|
|
||||||
patch = (patch_t *)W_CacheLumpNum(gr_patchflat, PU_STATIC);
|
|
||||||
fflatwidth = patch->width;
|
|
||||||
fflatheight = patch->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (texturenum != 0 && texturenum != -1)
|
if (texturenum != 0 && texturenum != -1)
|
||||||
{
|
{
|
||||||
fflatwidth = textures[texturenum]->width;
|
fflatwidth = textures[texturenum]->width;
|
||||||
fflatheight = textures[texturenum]->height;
|
fflatheight = textures[texturenum]->height;
|
||||||
}
|
}
|
||||||
|
else if (gr_patchflat && R_CheckIfPatch(gr_patchflat)) // Just in case?
|
||||||
|
{
|
||||||
|
patch = (patch_t *)W_CacheLumpNum(gr_patchflat, PU_STATIC);
|
||||||
|
fflatwidth = SHORT(patch->width);
|
||||||
|
fflatheight = SHORT(patch->height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
texflat = false;
|
||||||
|
|
||||||
// reference point for flat texture coord for each vertex around the polygon
|
// reference point for flat texture coord for each vertex around the polygon
|
||||||
flatxref = (float)((polysector->origVerts[0].x % llrint(fflatwidth)) / fflatwidth);
|
flatxref = (float)((polysector->origVerts[0].x & (~flatflag)) / fflatwidth);
|
||||||
flatyref = (float)((polysector->origVerts[0].y % llrint(fflatheight)) / fflatheight);
|
flatyref = (float)((polysector->origVerts[0].y & (~flatflag)) / fflatheight);
|
||||||
|
|
||||||
// transform
|
// transform
|
||||||
v3d = planeVerts;
|
v3d = planeVerts;
|
||||||
|
@ -3300,15 +3305,26 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
|
|
||||||
for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++)
|
for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++)
|
||||||
{
|
{
|
||||||
// Hurdler: add scrolling texture on floor/ceiling
|
// Go from the polysector's original vertex locations
|
||||||
v3d->sow = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) - flatxref + scrollx); // Go from the polysector's original vertex locations
|
// Means the flat is offset based on the original vertex locations
|
||||||
v3d->tow = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly); // Means the flat is offset based on the original vertex locations
|
if (texflat)
|
||||||
|
{
|
||||||
|
v3d->sow = (float)(FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) + scrollx;
|
||||||
|
v3d->tow = -(float)(FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v3d->sow = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) - flatxref + scrollx);
|
||||||
|
v3d->tow = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly);
|
||||||
|
}
|
||||||
|
|
||||||
// Need to rotate before translate
|
// Need to rotate before translate
|
||||||
if (angle) // Only needs to be done if there's an altered angle
|
if (angle) // Only needs to be done if there's an altered angle
|
||||||
{
|
{
|
||||||
tempxsow = FLOAT_TO_FIXED(v3d->sow);
|
tempxsow = FLOAT_TO_FIXED(v3d->sow);
|
||||||
tempytow = FLOAT_TO_FIXED(v3d->tow);
|
tempytow = FLOAT_TO_FIXED(v3d->tow);
|
||||||
|
if (texflat)
|
||||||
|
tempytow = -tempytow;
|
||||||
v3d->sow = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));
|
v3d->sow = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));
|
||||||
v3d->tow = (FIXED_TO_FLOAT(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle))));
|
v3d->tow = (FIXED_TO_FLOAT(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -613,8 +613,11 @@ INT32 P_AddLevelFlatRuntime(const char *flatname)
|
||||||
|
|
||||||
// store the flat lump number
|
// store the flat lump number
|
||||||
levelflat->lumpnum = R_GetFlatNumForName(flatname);
|
levelflat->lumpnum = R_GetFlatNumForName(flatname);
|
||||||
// Lactozilla
|
|
||||||
levelflat->texturenum = R_CheckTextureNumForName(flatname);
|
levelflat->texturenum = R_CheckTextureNumForName(flatname);
|
||||||
|
levelflat->lasttexturenum = levelflat->texturenum;
|
||||||
|
|
||||||
|
levelflat->baselumpnum = LUMPERROR;
|
||||||
|
levelflat->basetexturenum = -1;
|
||||||
|
|
||||||
#ifndef ZDEBUG
|
#ifndef ZDEBUG
|
||||||
CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name);
|
CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name);
|
||||||
|
|
Loading…
Reference in New Issue