mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-03-18 00:42:13 +00:00
- fix last merge
This commit is contained in:
parent
61c11e513b
commit
2c12421160
3 changed files with 328 additions and 1198 deletions
|
@ -4001,6 +4001,70 @@ struct aim_t
|
|||
SetResult(thing_other, newtrace.thing_other);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// Finds where the trace exits an actor to check for hits from above/below
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
double ExitPoint(AActor *thing)
|
||||
{
|
||||
// The added check at the exit point only has some value if a 3D distance check is involved
|
||||
if (!(flags & ALF_CHECK3D)) return -1;
|
||||
|
||||
divline_t trace = { startpos.X, startpos.Y, aimtrace.X, aimtrace.Y };
|
||||
divline_t line;
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: // Top edge
|
||||
line.y = thing->Y() + thing->radius;
|
||||
if (trace.y > line.y) continue;
|
||||
line.x = thing->X() + thing->radius;
|
||||
line.dx = -thing->radius * 2;
|
||||
line.dy = 0;
|
||||
break;
|
||||
|
||||
case 1: // Right edge
|
||||
line.x = thing->X() + thing->radius;
|
||||
if (trace.x > line.x) continue;
|
||||
line.y = thing->Y() - thing->radius;
|
||||
line.dx = 0;
|
||||
line.dy = thing->radius * 2;
|
||||
break;
|
||||
|
||||
case 2: // Bottom edge
|
||||
line.y = thing->Y() - thing->radius;
|
||||
if (trace.y < line.y) continue;
|
||||
line.x = thing->X() - thing->radius;
|
||||
line.dx = thing->radius * 2;
|
||||
line.dy = 0;
|
||||
break;
|
||||
|
||||
case 3: // Left edge
|
||||
line.x = thing->X() - thing->radius;
|
||||
if (trace.x < line.x) continue;
|
||||
line.y = thing->Y() + thing->radius;
|
||||
line.dx = 0;
|
||||
line.dy = thing->radius * -2;
|
||||
break;
|
||||
}
|
||||
|
||||
// If it is, see if the trace crosses it
|
||||
if (P_PointOnDivlineSide(line.x, line.y, &trace) !=
|
||||
P_PointOnDivlineSide(line.x + line.dx, line.y + line.dy, &trace))
|
||||
{
|
||||
// It's a hit
|
||||
double frac = P_InterceptVector(&trace, &line);
|
||||
if (frac > 1.) frac = 1.;
|
||||
return frac;
|
||||
}
|
||||
}
|
||||
|
||||
return -1.;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
|
@ -4050,9 +4114,7 @@ struct aim_t
|
|||
intercept_t *in;
|
||||
|
||||
if (aimdebug)
|
||||
Printf("Start AimTraverse, start = %f,%f,%f, vect = %f,%f\n",
|
||||
startpos.X / 65536., startpos.Y / 65536., startpos.Z / 65536.,
|
||||
aimtrace.X / 65536., aimtrace.Y / 65536.);
|
||||
Printf("Start AimTraverse, start = %f,%f,%f, vect = %f,%f\n", startpos.X, startpos.Y, startpos.Z, aimtrace.X, aimtrace.Y);
|
||||
|
||||
while ((in = it.Next()))
|
||||
{
|
||||
|
@ -4209,7 +4271,6 @@ struct aim_t
|
|||
thingtoppitch = -VecToAngle(exitdist, th->Top() - shootz);
|
||||
if (thingtoppitch > bottompitch) continue;
|
||||
}
|
||||
else continue; // shot over the thing
|
||||
}
|
||||
else continue; // shot over the thing
|
||||
}
|
||||
|
@ -4228,9 +4289,9 @@ struct aim_t
|
|||
thingbottompitch = -VecToAngle(exitdist, th->Z() - shootz);
|
||||
if (thingbottompitch < toppitch) continue;
|
||||
}
|
||||
else continue; // shot over the thing
|
||||
}
|
||||
continue; // shot under the thing
|
||||
}
|
||||
|
||||
if (crossedffloors)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -47,22 +47,12 @@ namespace swrenderer
|
|||
if (tz < MINZ)
|
||||
return;
|
||||
|
||||
double tx = tr_x * thread->Viewport->viewpoint.Sin - tr_y * thread->Viewport->viewpoint.Cos;
|
||||
|
||||
// Flip for mirrors
|
||||
if (thread->Portal->MirrorFlags & RF_XFLIP)
|
||||
{
|
||||
tx = viewwidth - tx - 1;
|
||||
}
|
||||
|
||||
// too far off the side?
|
||||
double tx = tr_x * thread->Viewport->viewpoint.Sin - tr_y * thread->Viewport->viewpoint.Cos;
|
||||
if (fabs(tx / 64) > fabs(tz))
|
||||
return;
|
||||
|
||||
RenderModel *vis = thread->FrameMemory->NewObject<RenderModel>(x, y, z, smf, actor, float(1 / tz));
|
||||
vis->CurrentPortalUniq = thread->Portal->CurrentPortalUniq;
|
||||
vis->WorldToClip = thread->Viewport->WorldToClip;
|
||||
vis->MirrorWorldToClip = !!(thread->Portal->MirrorFlags & RF_XFLIP);
|
||||
thread->SpriteList->Push(vis);
|
||||
}
|
||||
|
||||
|
@ -74,7 +64,7 @@ namespace swrenderer
|
|||
|
||||
void RenderModel::Render(RenderThread *thread, short *cliptop, short *clipbottom, int minZ, int maxZ, Fake3DTranslucent clip3DFloor)
|
||||
{
|
||||
SWModelRenderer renderer(thread, clip3DFloor, &WorldToClip, MirrorWorldToClip);
|
||||
SWModelRenderer renderer(thread, clip3DFloor);
|
||||
renderer.RenderModel(x, y, z, smf, actor);
|
||||
}
|
||||
|
||||
|
@ -82,18 +72,17 @@ namespace swrenderer
|
|||
|
||||
void RenderHUDModel(RenderThread *thread, DPSprite *psp, float ofsx, float ofsy)
|
||||
{
|
||||
SWModelRenderer renderer(thread, Fake3DTranslucent(), &thread->Viewport->WorldToClip, false);
|
||||
SWModelRenderer renderer(thread, Fake3DTranslucent());
|
||||
renderer.RenderHUDModel(psp, ofsx, ofsy);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SWModelRenderer::SWModelRenderer(RenderThread *thread, Fake3DTranslucent clip3DFloor, Mat4f *worldToClip, bool mirrorWorldToClip)
|
||||
: Thread(thread), Clip3DFloor(clip3DFloor), WorldToClip(worldToClip), MirrorWorldToClip(mirrorWorldToClip)
|
||||
SWModelRenderer::SWModelRenderer(RenderThread *thread, Fake3DTranslucent clip3DFloor) : Thread(thread), Clip3DFloor(clip3DFloor)
|
||||
{
|
||||
}
|
||||
|
||||
void SWModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix)
|
||||
void SWModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix, bool mirrored)
|
||||
{
|
||||
ModelActor = actor;
|
||||
const_cast<VSMatrix &>(objectToWorldMatrix).copy(ObjectToWorld.Matrix);
|
||||
|
@ -134,13 +123,14 @@ namespace swrenderer
|
|||
|
||||
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES))
|
||||
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true);
|
||||
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, !(mirrored ^ MirrorWorldToClip));
|
||||
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, !mirrored);
|
||||
}
|
||||
|
||||
void SWModelRenderer::EndDrawModel(AActor *actor, FSpriteModelFrame *smf)
|
||||
{
|
||||
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] || !!(smf->flags & MDL_DONTCULLBACKFACES))
|
||||
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false);
|
||||
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, true);
|
||||
|
||||
ModelActor = nullptr;
|
||||
}
|
||||
|
@ -193,7 +183,7 @@ namespace swrenderer
|
|||
return objectToWorld;
|
||||
}
|
||||
|
||||
void SWModelRenderer::BeginDrawHUDModel(AActor *actor, const VSMatrix &objectToWorldMatrix)
|
||||
void SWModelRenderer::BeginDrawHUDModel(AActor *actor, const VSMatrix &objectToWorldMatrix, bool mirrored)
|
||||
{
|
||||
ModelActor = actor;
|
||||
const_cast<VSMatrix &>(objectToWorldMatrix).copy(ObjectToWorld.Matrix);
|
||||
|
@ -204,7 +194,7 @@ namespace swrenderer
|
|||
|
||||
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal])
|
||||
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, true);
|
||||
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, !(mirrored ^ MirrorWorldToClip));
|
||||
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, mirrored);
|
||||
}
|
||||
|
||||
void SWModelRenderer::EndDrawHUDModel(AActor *actor)
|
||||
|
@ -214,6 +204,7 @@ namespace swrenderer
|
|||
|
||||
if (actor->RenderStyle == LegacyRenderStyles[STYLE_Normal])
|
||||
PolyTriangleDrawer::SetTwoSided(Thread->DrawQueue, false);
|
||||
PolyTriangleDrawer::SetCullCCW(Thread->DrawQueue, true);
|
||||
}
|
||||
|
||||
void SWModelRenderer::SetInterpolation(double interpolation)
|
||||
|
@ -234,7 +225,7 @@ namespace swrenderer
|
|||
swapYZ.Matrix[2 + 1 * 4] = 1.0f;
|
||||
swapYZ.Matrix[3 + 3 * 4] = 1.0f;
|
||||
|
||||
PolyTriangleDrawer::SetTransform(Thread->DrawQueue, Thread->FrameMemory->NewObject<Mat4f>((*WorldToClip) * swapYZ * ObjectToWorld));
|
||||
PolyTriangleDrawer::SetTransform(Thread->DrawQueue, Thread->FrameMemory->NewObject<Mat4f>(Thread->Viewport->WorldToClip * swapYZ * ObjectToWorld));
|
||||
}
|
||||
|
||||
void SWModelRenderer::DrawArrays(int start, int count)
|
||||
|
|
Loading…
Reference in a new issue