Merge branch 'remove-vertex-z-mk2' into 'next'
Remove "z" from "vertex_t" See merge request STJr/SRB2!636
This commit is contained in:
commit
18ccdd855a
|
@ -157,15 +157,13 @@ static const char *const side_opt[] = {
|
||||||
enum vertex_e {
|
enum vertex_e {
|
||||||
vertex_valid = 0,
|
vertex_valid = 0,
|
||||||
vertex_x,
|
vertex_x,
|
||||||
vertex_y,
|
vertex_y
|
||||||
vertex_z
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *const vertex_opt[] = {
|
static const char *const vertex_opt[] = {
|
||||||
"valid",
|
"valid",
|
||||||
"x",
|
"x",
|
||||||
"y",
|
"y",
|
||||||
"z",
|
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
enum ffloor_e {
|
enum ffloor_e {
|
||||||
|
@ -970,9 +968,6 @@ static int vertex_get(lua_State *L)
|
||||||
case vertex_y:
|
case vertex_y:
|
||||||
lua_pushfixed(L, vertex->y);
|
lua_pushfixed(L, vertex->y);
|
||||||
return 1;
|
return 1;
|
||||||
case vertex_z:
|
|
||||||
lua_pushfixed(L, vertex->z);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,68 +78,37 @@ void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/// Similar to FV3_ClosestPointOnLine() except it actually works.
|
||||||
// P_ClosestPointOnLine3D
|
void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *Line, vector3_t *result)
|
||||||
// Finds the closest point on a given line to the supplied point IN 3D!!!
|
|
||||||
//
|
|
||||||
void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, vertex_t *result)
|
|
||||||
{
|
{
|
||||||
fixed_t startx = line->v1->x;
|
const vector3_t* v1 = &Line[0];
|
||||||
fixed_t starty = line->v1->y;
|
const vector3_t* v2 = &Line[1];
|
||||||
fixed_t startz = line->v1->z;
|
vector3_t c, V, n;
|
||||||
fixed_t dx = line->dx;
|
fixed_t t, d;
|
||||||
fixed_t dy = line->dy;
|
FV3_SubEx(v2, v1, &V);
|
||||||
fixed_t dz = line->v2->z - line->v1->z;
|
FV3_SubEx(p, v1, &c);
|
||||||
|
|
||||||
// Determine t (the length of the vector from <20>Line[0]<5D> to <20>p<EFBFBD>)
|
d = R_PointToDist2(0, v2->z, R_PointToDist2(v2->x, v2->y, v1->x, v1->y), v1->z);
|
||||||
fixed_t cx, cy, cz;
|
FV3_Copy(&n, &V);
|
||||||
fixed_t vx, vy, vz;
|
FV3_Divide(&n, d);
|
||||||
fixed_t magnitude;
|
|
||||||
fixed_t t;
|
|
||||||
|
|
||||||
//Sub (p, &Line[0], &c);
|
t = FV3_Dot(&n, &c);
|
||||||
cx = x - startx;
|
|
||||||
cy = y - starty;
|
|
||||||
cz = z - startz;
|
|
||||||
|
|
||||||
//Sub (&Line[1], &Line[0], &V);
|
|
||||||
vx = dx;
|
|
||||||
vy = dy;
|
|
||||||
vz = dz;
|
|
||||||
|
|
||||||
//Normalize (&V, &V);
|
|
||||||
magnitude = R_PointToDist2(0, line->v2->z, R_PointToDist2(line->v2->x, line->v2->y, startx, starty), startz);
|
|
||||||
vx = FixedDiv(vx, magnitude);
|
|
||||||
vy = FixedDiv(vy, magnitude);
|
|
||||||
vz = FixedDiv(vz, magnitude);
|
|
||||||
|
|
||||||
t = (FixedMul(vx, cx) + FixedMul(vy, cy) + FixedMul(vz, cz));
|
|
||||||
|
|
||||||
// Set closest point to the end if it extends past -Red
|
// Set closest point to the end if it extends past -Red
|
||||||
if (t <= 0)
|
if (t <= 0)
|
||||||
{
|
{
|
||||||
result->x = line->v1->x;
|
FV3_Copy(result, v1);
|
||||||
result->y = line->v1->y;
|
|
||||||
result->z = line->v1->z;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (t >= magnitude)
|
else if (t >= d)
|
||||||
{
|
{
|
||||||
result->x = line->v2->x;
|
FV3_Copy(result, v2);
|
||||||
result->y = line->v2->y;
|
|
||||||
result->z = line->v2->z;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the point between <20>Line[0]<5D> and <20>Line[1]<5D>
|
FV3_Mul(&n, t);
|
||||||
vx = FixedMul(vx, t);
|
|
||||||
vy = FixedMul(vy, t);
|
|
||||||
vz = FixedMul(vz, t);
|
|
||||||
|
|
||||||
//Add (&Line[0], &V, out);
|
FV3_AddEx(v1, &n, result);
|
||||||
result->x = startx + vx;
|
|
||||||
result->y = starty + vy;
|
|
||||||
result->z = startz + vz;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2,
|
||||||
|
|
||||||
FUNCMATH fixed_t P_AproxDistance(fixed_t dx, fixed_t dy);
|
FUNCMATH fixed_t P_AproxDistance(fixed_t dx, fixed_t dy);
|
||||||
void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result);
|
void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result);
|
||||||
void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, vertex_t *result);
|
void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *line, vector3_t *result);
|
||||||
INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line);
|
INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line);
|
||||||
void P_MakeDivline(line_t *li, divline_t *dl);
|
void P_MakeDivline(line_t *li, divline_t *dl);
|
||||||
void P_CameraLineOpening(line_t *plinedef);
|
void P_CameraLineOpening(line_t *plinedef);
|
||||||
|
|
|
@ -846,7 +846,6 @@ static void P_LoadVertices(UINT8 *data)
|
||||||
{
|
{
|
||||||
v->x = SHORT(mv->x)<<FRACBITS;
|
v->x = SHORT(mv->x)<<FRACBITS;
|
||||||
v->y = SHORT(mv->y)<<FRACBITS;
|
v->y = SHORT(mv->y)<<FRACBITS;
|
||||||
v->z = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1575,7 +1574,6 @@ static void P_LoadTextmap(void)
|
||||||
{
|
{
|
||||||
// Defaults.
|
// Defaults.
|
||||||
vt->x = vt->y = INT32_MAX;
|
vt->x = vt->y = INT32_MAX;
|
||||||
vt->z = 0;
|
|
||||||
|
|
||||||
TextmapParse(vertexesPos[i], i, ParseTextmapVertexParameter);
|
TextmapParse(vertexesPos[i], i, ParseTextmapVertexParameter);
|
||||||
|
|
||||||
|
|
43
src/p_spec.c
43
src/p_spec.c
|
@ -5038,8 +5038,7 @@ DoneSection2:
|
||||||
mobj_t *waypointlow = NULL;
|
mobj_t *waypointlow = NULL;
|
||||||
mobj_t *mo2;
|
mobj_t *mo2;
|
||||||
mobj_t *closest = NULL;
|
mobj_t *closest = NULL;
|
||||||
line_t junk;
|
vector3_t p, line[2], resulthigh, resultlow;
|
||||||
vertex_t v1, v2, resulthigh, resultlow;
|
|
||||||
mobj_t *highest = NULL;
|
mobj_t *highest = NULL;
|
||||||
|
|
||||||
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ROPEHANG)
|
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ROPEHANG)
|
||||||
|
@ -5186,38 +5185,34 @@ DoneSection2:
|
||||||
// Next, we need to find the closest point on the line between each set, and determine which one we're
|
// Next, we need to find the closest point on the line between each set, and determine which one we're
|
||||||
// closest to.
|
// closest to.
|
||||||
|
|
||||||
|
p.x = player->mo->x;
|
||||||
|
p.y = player->mo->y;
|
||||||
|
p.z = player->mo->z;
|
||||||
|
|
||||||
// Waypointmid and Waypointlow:
|
// Waypointmid and Waypointlow:
|
||||||
if (waypointlow)
|
if (waypointlow)
|
||||||
{
|
{
|
||||||
v1.x = waypointmid->x;
|
line[0].x = waypointmid->x;
|
||||||
v1.y = waypointmid->y;
|
line[0].y = waypointmid->y;
|
||||||
v1.z = waypointmid->z;
|
line[0].z = waypointmid->z;
|
||||||
v2.x = waypointlow->x;
|
line[1].x = waypointlow->x;
|
||||||
v2.y = waypointlow->y;
|
line[1].y = waypointlow->y;
|
||||||
v2.z = waypointlow->z;
|
line[1].z = waypointlow->z;
|
||||||
junk.v1 = &v1;
|
|
||||||
junk.v2 = &v2;
|
|
||||||
junk.dx = v2.x - v1.x;
|
|
||||||
junk.dy = v2.y - v1.y;
|
|
||||||
|
|
||||||
P_ClosestPointOnLine3D(player->mo->x, player->mo->y, player->mo->z, &junk, &resultlow);
|
P_ClosestPointOnLine3D(&p, line, &resultlow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Waypointmid and Waypointhigh:
|
// Waypointmid and Waypointhigh:
|
||||||
if (waypointhigh)
|
if (waypointhigh)
|
||||||
{
|
{
|
||||||
v1.x = waypointmid->x;
|
line[0].x = waypointmid->x;
|
||||||
v1.y = waypointmid->y;
|
line[0].y = waypointmid->y;
|
||||||
v1.z = waypointmid->z;
|
line[0].z = waypointmid->z;
|
||||||
v2.x = waypointhigh->x;
|
line[1].x = waypointhigh->x;
|
||||||
v2.y = waypointhigh->y;
|
line[1].y = waypointhigh->y;
|
||||||
v2.z = waypointhigh->z;
|
line[1].z = waypointhigh->z;
|
||||||
junk.v1 = &v1;
|
|
||||||
junk.v2 = &v2;
|
|
||||||
junk.dx = v2.x - v1.x;
|
|
||||||
junk.dy = v2.y - v1.y;
|
|
||||||
|
|
||||||
P_ClosestPointOnLine3D(player->mo->x, player->mo->y, player->mo->z, &junk, &resulthigh);
|
P_ClosestPointOnLine3D(&p, line, &resulthigh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3D support now available. Disregard the previous notice here. -Red
|
// 3D support now available. Disregard the previous notice here. -Red
|
||||||
|
|
|
@ -83,7 +83,7 @@ typedef struct extracolormap_s
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
fixed_t x, y, z;
|
fixed_t x, y;
|
||||||
} vertex_t;
|
} vertex_t;
|
||||||
|
|
||||||
// Forward of linedefs, for sectors.
|
// Forward of linedefs, for sectors.
|
||||||
|
|
Loading…
Reference in New Issue