- added a TStaticArray class that allows safe access to resizable static data (like the sectors, linedefs, etc.) for the VM.
- used this to replace the line list in Sector because that gets already used and implemented proper bounds checks for this type of array.
This commit is contained in:
parent
b31b6589e7
commit
1a16f664e4
24 changed files with 455 additions and 232 deletions
|
|
@ -201,10 +201,8 @@ void P_SetSlope (secplane_t *plane, bool setCeil, int xyangi, int zangi, const D
|
|||
|
||||
void P_VavoomSlope(sector_t * sec, int id, const DVector3 &pos, int which)
|
||||
{
|
||||
for (int i=0;i<sec->linecount;i++)
|
||||
for(auto l : sec->Lines)
|
||||
{
|
||||
line_t * l=sec->lines[i];
|
||||
|
||||
if (l->args[0]==id)
|
||||
{
|
||||
DVector3 v1, v2, cross;
|
||||
|
|
@ -306,16 +304,16 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt,
|
|||
for (int i = 0; i < numsectors; i++)
|
||||
{
|
||||
sector_t *sec = §ors[i];
|
||||
if (sec->linecount != 3) continue; // only works with triangular sectors
|
||||
if (sec->Lines.Size() != 3) continue; // only works with triangular sectors
|
||||
|
||||
DVector3 vt1, vt2, vt3, cross;
|
||||
DVector3 vec1, vec2;
|
||||
int vi1, vi2, vi3;
|
||||
|
||||
vi1 = int(sec->lines[0]->v1 - vertexes);
|
||||
vi2 = int(sec->lines[0]->v2 - vertexes);
|
||||
vi3 = (sec->lines[1]->v1 == sec->lines[0]->v1 || sec->lines[1]->v1 == sec->lines[0]->v2)?
|
||||
int(sec->lines[1]->v2 - vertexes) : int(sec->lines[1]->v1 - vertexes);
|
||||
vi1 = int(sec->Lines[0]->v1 - vertexes);
|
||||
vi2 = int(sec->Lines[0]->v2 - vertexes);
|
||||
vi3 = (sec->Lines[1]->v1 == sec->Lines[0]->v1 || sec->Lines[1]->v1 == sec->Lines[0]->v2)?
|
||||
int(sec->Lines[1]->v2 - vertexes) : int(sec->Lines[1]->v1 - vertexes);
|
||||
|
||||
vt1 = DVector3(vertexes[vi1].fPos(), 0);
|
||||
vt2 = DVector3(vertexes[vi2].fPos(), 0);
|
||||
|
|
@ -332,7 +330,7 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt,
|
|||
vt2.Z = h2? *h2 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
|
||||
vt3.Z = h3? *h3 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling);
|
||||
|
||||
if (P_PointOnLineSidePrecise(vertexes[vi3].fX(), vertexes[vi3].fY(), sec->lines[0]) == 0)
|
||||
if (P_PointOnLineSidePrecise(vertexes[vi3].fX(), vertexes[vi3].fY(), sec->Lines[0]) == 0)
|
||||
{
|
||||
vec1 = vt2 - vt3;
|
||||
vec2 = vt1 - vt3;
|
||||
|
|
@ -451,9 +449,7 @@ static void P_AlignPlane(sector_t *sec, line_t *line, int which)
|
|||
{
|
||||
sector_t *refsec;
|
||||
double bestdist;
|
||||
vertex_t *refvert = (*sec->lines)->v1; // Shut up, GCC
|
||||
int i;
|
||||
line_t **probe;
|
||||
vertex_t *refvert = sec->Lines[0]->v1; // Shut up, GCC
|
||||
|
||||
if (line->backsector == NULL)
|
||||
return;
|
||||
|
|
@ -461,22 +457,22 @@ static void P_AlignPlane(sector_t *sec, line_t *line, int which)
|
|||
// Find furthest vertex from the reference line. It, along with the two ends
|
||||
// of the line, will define the plane.
|
||||
bestdist = 0;
|
||||
for (i = sec->linecount * 2, probe = sec->lines; i > 0; i--)
|
||||
for (auto ln : sec->Lines)
|
||||
{
|
||||
double dist;
|
||||
vertex_t *vert;
|
||||
|
||||
if (i & 1)
|
||||
vert = (*probe++)->v2;
|
||||
else
|
||||
vert = (*probe)->v1;
|
||||
dist = fabs((line->v1->fY() - vert->fY()) * line->Delta().X -
|
||||
(line->v1->fX() - vert->fX()) * line->Delta().Y);
|
||||
|
||||
if (dist > bestdist)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
bestdist = dist;
|
||||
refvert = vert;
|
||||
double dist;
|
||||
vertex_t *vert;
|
||||
|
||||
vert = i == 0 ? ln->v1 : ln->v2;
|
||||
dist = fabs((line->v1->fY() - vert->fY()) * line->Delta().X -
|
||||
(line->v1->fX() - vert->fX()) * line->Delta().Y);
|
||||
|
||||
if (dist > bestdist)
|
||||
{
|
||||
bestdist = dist;
|
||||
refvert = vert;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue