fix up 3dmodels
those things werent affected by setting smth in spriteoffsets also cleans up the code alot taken from srb2s model plus branch https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1840
This commit is contained in:
1 parent
7be1c58ba5
commit
355a1c2046
5 files changed
+36
-66
No files matched your search
@@ -46,7 +46,9 @@ EXPORT void HWRAPI(ClearMipMapCache) (void);
|
||||
EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
|
||||
|
||||
//Hurdler: added for new development
|
||||
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface);
|
||||
|
||||
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, FSurfaceInfo *Surface);
|
||||
|
||||
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model);
|
||||
EXPORT void HWRAPI(SetTransform) (FTransform *stransform);
|
||||
EXPORT INT32 HWRAPI(GetTextureUsed) (void);
|
||||
|
||||
@@ -194,7 +194,7 @@ FTransform atransform;
|
||||
|
||||
// Float variants of viewx, viewy, viewz, etc.
|
||||
static float gr_viewx, gr_viewy, gr_viewz;
|
||||
static float gr_viewsin, gr_viewcos;
|
||||
float gr_viewsin, gr_viewcos;
|
||||
|
||||
static fixed_t dup_viewx, dup_viewy, dup_viewz;
|
||||
|
||||
@@ -5074,6 +5074,7 @@ void HWR_ProjectSprite(mobj_t *thing)
|
||||
spr_offset = rotsprite->leftoffset << FRACBITS;
|
||||
spr_topoffset = rotsprite->topoffset << FRACBITS;
|
||||
spr_topoffset += FEETADJUST;
|
||||
|
||||
// flip -> rotate, not rotate -> flip
|
||||
flip = 0;
|
||||
}
|
||||
@@ -5129,13 +5130,13 @@ void HWR_ProjectSprite(mobj_t *thing)
|
||||
|
||||
if (thing->eflags & MFE_VERTICALFLIP)
|
||||
{
|
||||
gz = FIXED_TO_FLOAT(interp.z+thing->height) - FIXED_TO_FLOAT(spr_topoffset) * this_yscale;
|
||||
gzt = gz + FIXED_TO_FLOAT(spr_height) * this_yscale;
|
||||
gz = FIXED_TO_FLOAT(interp.z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale);
|
||||
gzt = gz + (FIXED_TO_FLOAT(spr_height) * this_yscale);
|
||||
}
|
||||
else
|
||||
{
|
||||
gzt = FIXED_TO_FLOAT(interp.z) + FIXED_TO_FLOAT(spr_topoffset) * this_yscale;
|
||||
gz = gzt - FIXED_TO_FLOAT(spr_height) * this_yscale;
|
||||
gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spr_topoffset) * this_yscale);
|
||||
gz = gzt - (FIXED_TO_FLOAT(spr_height) * this_yscale);
|
||||
}
|
||||
|
||||
if (thing->subsector->sector->cullheight)
|
||||
@@ -5177,10 +5178,10 @@ void HWR_ProjectSprite(mobj_t *thing)
|
||||
vis->spriteyscale = spriteyscale;
|
||||
vis->spritexoffset = FIXED_TO_FLOAT(spr_offset);
|
||||
vis->spriteyoffset = FIXED_TO_FLOAT(spr_topoffset);
|
||||
//vis->patchlumpnum = sprframe->lumppat[rot];
|
||||
|
||||
#ifdef ROTSPRITE
|
||||
if (rotsprite)
|
||||
vis->gpatch = (GLPatch_t *)rotsprite;
|
||||
vis->gpatch = (GLPatch_t *)rotsprite;
|
||||
else
|
||||
#endif
|
||||
vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE);
|
||||
@@ -5345,7 +5346,6 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||
vis->z2 = z2;
|
||||
vis->tz = tz;
|
||||
vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST
|
||||
//vis->patchlumpnum = sprframe->lumppat[rot];
|
||||
vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE);
|
||||
vis->flip = flip;
|
||||
vis->mobj = (mobj_t *)thing;
|
||||
|
||||
@@ -45,6 +45,7 @@ extern unsigned msaa;
|
||||
extern boolean a2c;
|
||||
|
||||
extern FTransform atransform;
|
||||
extern float gr_viewsin, gr_viewcos;
|
||||
|
||||
// Performance stats
|
||||
extern ps_metric_t ps_hw_nodesorttime;
|
||||
|
||||
+16
-8
@@ -1144,7 +1144,6 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
spriteinfo_t *sprinfo;
|
||||
INT32 rollfactor = 0;
|
||||
angle_t ang;
|
||||
float finalscale;
|
||||
interpmobjstate_t interp;
|
||||
|
||||
if (R_UsingFrameInterpolation() && !paused)
|
||||
@@ -1204,7 +1203,6 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
finalscale = md2->scale;
|
||||
//Hurdler: arf, I don't like that implementation at all... too much crappy
|
||||
gpatch = md2->grpatch;
|
||||
if (!gpatch || ((!gpatch->mipmap->grInfo.format || !gpatch->mipmap->downloaded) && !gpatch->notfound))
|
||||
@@ -1386,18 +1384,28 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
|
||||
}
|
||||
#endif
|
||||
|
||||
// SRB2CBTODO: MD2 scaling support
|
||||
finalscale *= FIXED_TO_FLOAT(interp.scale);
|
||||
|
||||
|
||||
|
||||
p.flip = atransform.flip;
|
||||
#ifdef USE_FTRANSFORM_MIRROR
|
||||
p.mirror = atransform.mirror; // from Kart
|
||||
#endif
|
||||
|
||||
HWD.pfnSetShader(4); // model shader
|
||||
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, &Surf);
|
||||
{
|
||||
float this_scale = FIXED_TO_FLOAT(interp.scale);
|
||||
|
||||
float xs = this_scale * FIXED_TO_FLOAT(interp.spritexscale);
|
||||
float ys = this_scale * FIXED_TO_FLOAT(interp.spriteyscale);
|
||||
|
||||
float ox = xs * FIXED_TO_FLOAT(interp.spritexoffset);
|
||||
float oy = ys * FIXED_TO_FLOAT(interp.spriteyoffset);
|
||||
|
||||
// offset perpendicular to the camera angle
|
||||
p.x -= ox * gr_viewsin;
|
||||
p.y += ox * gr_viewcos;
|
||||
p.z += oy;
|
||||
|
||||
HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, &Surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3040,67 +3040,26 @@ EXPORT void HWRAPI(CreateModelVBOs) (model_t *model)
|
||||
|
||||
#define BUFFER_OFFSET(i) ((char*)(i))
|
||||
|
||||
static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface)
|
||||
static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, FSurfaceInfo *Surface)
|
||||
{
|
||||
static GLRGBAFloat poly = {0,0,0,0};
|
||||
static GLRGBAFloat tint = {0,0,0,0};
|
||||
static GLRGBAFloat fade = {0,0,0,0};
|
||||
|
||||
const float radians = (float)(M_PIl / 180.0f);
|
||||
float pol = 0.0f;
|
||||
float scalex, scaley, scalez;
|
||||
float sprxscale, spryscale;
|
||||
float scalediffx, scalediffy;
|
||||
int dfx, dfy;
|
||||
float rollradian;
|
||||
float scalecosx, scalesinx, scalecosy, scalesiny;
|
||||
|
||||
boolean useTinyFrames;
|
||||
|
||||
int i;
|
||||
|
||||
sprxscale = pos->spritexscale;
|
||||
spryscale = pos->spriteyscale;
|
||||
|
||||
rollradian = 0;
|
||||
|
||||
rollradian = (pos->rollangle)*radians;
|
||||
|
||||
// Affect input model scaling
|
||||
hscale *= 0.5f;
|
||||
vscale *= 0.5f;
|
||||
scalex = hscale;
|
||||
scaley = vscale;
|
||||
scalez = hscale;
|
||||
|
||||
// this is hilariously insane but it's late as fuck and I can't be inclined to care
|
||||
scalediffx = (sprxscale*scale) - scale;
|
||||
scalediffy = (spryscale*scale) - scale;
|
||||
|
||||
scale *= 0.5f;
|
||||
sprxscale *= 1.5f;
|
||||
spryscale *= 1.5f;
|
||||
|
||||
scalediffx *= 0.5f;
|
||||
scalediffy *= 0.5f;
|
||||
|
||||
|
||||
dfx = 1;
|
||||
dfy = 1;
|
||||
|
||||
if (scalediffx < 0)
|
||||
dfx = -1;
|
||||
if (scalediffy < 0)
|
||||
dfy = -1;
|
||||
|
||||
|
||||
scalecosx = (fabs(scalediffx*cos(rollradian))*dfx);
|
||||
scalesinx = (fabs(scalediffx*sin(rollradian))*dfx);
|
||||
|
||||
|
||||
scalecosy = (fabs(scalediffy*sin(rollradian))*dfy);
|
||||
scalesiny = (fabs(scalediffy*cos(rollradian))*dfy);
|
||||
|
||||
// "sprite accurate" model scaling, so that stretchy things don't look all that funky from any angle not the default
|
||||
scalex = scale+scalecosx+scalecosy;
|
||||
scaley = scale+scalesinx+scalesiny;
|
||||
scalez = scale+scalecosx+scalecosy;
|
||||
|
||||
if (duration > 0.0 && tics >= 0.0) // don't interpolate if instantaneous or infinite in length
|
||||
{
|
||||
float newtime = (duration - tics); // + 1;
|
||||
@@ -3293,9 +3252,9 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float
|
||||
// -----------------+
|
||||
// HWRAPI DrawModel : Draw a model
|
||||
// -----------------+
|
||||
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface)
|
||||
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, FSurfaceInfo *Surface)
|
||||
{
|
||||
DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, scale, flipped, Surface);
|
||||
DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, Surface);
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
|
||||
Reference in new issue
Block a user