mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-17 18:21:40 +00:00
Woops, forgot to port collision as well.
This commit is contained in:
parent
e8d65f0b54
commit
14ff3906e1
1 changed files with 78 additions and 0 deletions
78
src/p_map.c
78
src/p_map.c
|
@ -469,6 +469,73 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
||||||
if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist)
|
if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist)
|
||||||
return true; // didn't hit it
|
return true; // didn't hit it
|
||||||
|
|
||||||
|
if (thing->flags & MF_PAPERCOLLISION) // CAUTION! Very easy to get stuck inside MF_SOLID objects. Giving the player MF_PAPERCOLLISION is a bad idea unless you know what you're doing.
|
||||||
|
{
|
||||||
|
fixed_t cosradius, sinradius;
|
||||||
|
vertex_t v1, v2; // fake vertexes
|
||||||
|
line_t junk; // fake linedef
|
||||||
|
cosradius = FixedMul(thing->radius, FINECOSINE(thing->angle>>ANGLETOFINESHIFT));
|
||||||
|
sinradius = FixedMul(thing->radius, FINESINE(thing->angle>>ANGLETOFINESHIFT));
|
||||||
|
|
||||||
|
v1.x = thing->x - cosradius;
|
||||||
|
v1.y = thing->y - sinradius;
|
||||||
|
v2.x = thing->x + cosradius;
|
||||||
|
v2.y = thing->y + sinradius;
|
||||||
|
|
||||||
|
junk.v1 = &v1;
|
||||||
|
junk.v2 = &v2;
|
||||||
|
junk.dx = v2.x - v1.x;
|
||||||
|
junk.dy = v2.y - v1.y;
|
||||||
|
|
||||||
|
if (tmthing->flags & MF_PAPERCOLLISION) // more strenuous checking to prevent clipping issues
|
||||||
|
{
|
||||||
|
INT32 check1, check2, check3, check4;
|
||||||
|
cosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT));
|
||||||
|
sinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT));
|
||||||
|
check1 = P_PointOnLineSide(tmx - cosradius, tmy - sinradius, &junk);
|
||||||
|
check2 = P_PointOnLineSide(tmx + cosradius, tmy + sinradius, &junk);
|
||||||
|
check3 = P_PointOnLineSide(tmx + tmthing->momx - cosradius, tmy + tmthing->momy - sinradius, &junk);
|
||||||
|
check4 = P_PointOnLineSide(tmx + tmthing->momx + cosradius, tmy + tmthing->momy + sinradius, &junk);
|
||||||
|
if ((check1 == check2) && (check2 == check3) && (check3 == check4))
|
||||||
|
return true; // the line doesn't cross between collider's start or end
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((P_PointOnLineSide(tmx - tmthing->radius, tmy - tmthing->radius, &junk)
|
||||||
|
== P_PointOnLineSide(tmx + tmthing->radius, tmy + tmthing->radius, &junk))
|
||||||
|
&& (P_PointOnLineSide(tmx + tmthing->radius, tmy - tmthing->radius, &junk)
|
||||||
|
== P_PointOnLineSide(tmx - tmthing->radius, tmy + tmthing->radius, &junk)))
|
||||||
|
return true; // the line doesn't cross between either pair of opposite corners
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (tmthing->flags & MF_PAPERCOLLISION)
|
||||||
|
{
|
||||||
|
fixed_t cosradius, sinradius;
|
||||||
|
vertex_t v1, v2; // fake vertexes
|
||||||
|
line_t junk; // fake linedef
|
||||||
|
|
||||||
|
cosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT));
|
||||||
|
sinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT));
|
||||||
|
|
||||||
|
v1.x = tmx - cosradius;
|
||||||
|
v1.y = tmy - sinradius;
|
||||||
|
v2.x = tmx + cosradius;
|
||||||
|
v2.y = tmy + sinradius;
|
||||||
|
|
||||||
|
junk.v1 = &v1;
|
||||||
|
junk.v2 = &v2;
|
||||||
|
junk.dx = v2.x - v1.x;
|
||||||
|
junk.dy = v2.y - v1.y;
|
||||||
|
|
||||||
|
// no need to check whether thing has MF_PAPERCOLLISION, since checked above
|
||||||
|
|
||||||
|
if ((P_PointOnLineSide(thing->x - thing->radius, thing->y - thing->radius, &junk)
|
||||||
|
== P_PointOnLineSide(thing->x + thing->radius, thing->y + thing->radius, &junk))
|
||||||
|
&& (P_PointOnLineSide(thing->x + thing->radius, thing->y - thing->radius, &junk)
|
||||||
|
== P_PointOnLineSide(thing->x - thing->radius, thing->y + thing->radius, &junk)))
|
||||||
|
return true; // the line doesn't cross between either pair of opposite corners
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_BLUA
|
#ifdef HAVE_BLUA
|
||||||
{
|
{
|
||||||
UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type
|
UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type
|
||||||
|
@ -1123,6 +1190,17 @@ static boolean PIT_CheckLine(line_t *ld)
|
||||||
if (P_BoxOnLineSide(tmbbox, ld) != -1)
|
if (P_BoxOnLineSide(tmbbox, ld) != -1)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag.
|
||||||
|
{
|
||||||
|
fixed_t cosradius, sinradius;
|
||||||
|
cosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT));
|
||||||
|
sinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT));
|
||||||
|
if (P_PointOnLineSide(tmx - cosradius, tmy - sinradius, ld)
|
||||||
|
== P_PointOnLineSide(tmx + cosradius, tmy + sinradius, ld))
|
||||||
|
return true; // the line doesn't cross between collider's start or end
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// A line has been hit
|
// A line has been hit
|
||||||
|
|
||||||
// The moving thing's destination position will cross
|
// The moving thing's destination position will cross
|
||||||
|
|
Loading…
Reference in a new issue