- fixed: The vertex height updater was using the index buffer offsets to access the vertex buffer.

I missed this part when repurposing the vboindex members to store the index buffer offsets.
However, since both indices are needed, they need another set of variables.
This commit is contained in:
Christoph Oelckers 2018-05-24 00:01:56 +02:00
parent 23909d109f
commit 496e6e2e8f
8 changed files with 33 additions and 27 deletions

View File

@ -588,7 +588,7 @@ bool FDrawInfo::PutFlatCompat(GLFlat *flat, bool fog)
int list = list_indices[masked][foggy];
auto newflat = dldrawlists[list].NewFlat();
*newflat = *flat;
newflat->vboindex = -1; // don't use the vertex buffer with legacy lights to ensure all passes use the same render logic.
newflat->iboindex = -1; // don't use the vertex buffer with legacy lights to ensure all passes use the same render logic.
return true;
}

View File

@ -216,14 +216,14 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
{
if (processlights) SetupSectorLights(flat, GLPASS_ALL, &dli);
drawcalls.Clock();
glDrawElements(GL_TRIANGLES, vcount, GL_UNSIGNED_INT, GLRenderer->mVBO->GetIndexPointer() + flat->vboindex);
glDrawElements(GL_TRIANGLES, vcount, GL_UNSIGNED_INT, GLRenderer->mVBO->GetIndexPointer() + flat->iboindex);
drawcalls.Unclock();
flatvertices += vcount;
flatprimitives++;
}
else if (flat->vboindex >= 0)
else if (flat->iboindex >= 0)
{
int index = flat->vboindex;
int index = flat->iboindex;
for (int i=0; i<flat->sector->subsectorcount; i++)
{
subsector_t * sub = flat->sector->subsectors[i];

View File

@ -177,21 +177,22 @@ int FFlatVertexGenerator::CreateIndexedSectorVertices(sector_t *sec, const secpl
int FFlatVertexGenerator::CreateIndexedVertices(int h, sector_t *sec, const secplane_t &plane, int floor, TArray<FFlatVertexGenerator::FIndexGenerationInfo> &gen)
{
sec->vboindex[h] = vbo_shadowdata.Size();
// First calculate the vertices for the sector itself
sec->vboheight[h] = sec->GetPlaneTexZ(h);
sec->vboindex[h] = CreateIndexedSectorVertices(sec, plane, floor, gen[sec->Index()]);
sec->iboindex[h] = CreateIndexedSectorVertices(sec, plane, floor, gen[sec->Index()]);
// Next are all sectors using this one as heightsec
TArray<sector_t *> &fakes = sec->e->FakeFloor.Sectors;
for (unsigned g = 0; g<fakes.Size(); g++)
for (unsigned g = 0; g < fakes.Size(); g++)
{
sector_t *fsec = fakes[g];
fsec->vboindex[2 + h] = CreateIndexedSectorVertices(fsec, plane, false, gen[fsec->Index()]);
fsec->iboindex[2 + h] = CreateIndexedSectorVertices(fsec, plane, false, gen[fsec->Index()]);
}
// and finally all attached 3D floors
TArray<sector_t *> &xf = sec->e->XFloor.attached;
for (unsigned g = 0; g<xf.Size(); g++)
for (unsigned g = 0; g < xf.Size(); g++)
{
sector_t *fsec = xf[g];
F3DFloor *ffloor = Find3DFloor(fsec, sec);
@ -210,7 +211,7 @@ int FFlatVertexGenerator::CreateIndexedVertices(int h, sector_t *sec, const secp
}
}
sec->vbocount[h] = vbo_shadowdata.Size() - sec->vboindex[h];
return sec->vboindex[h];
return sec->iboindex[h];
}
@ -253,11 +254,11 @@ void FFlatVertexGenerator::CreateIndexedFlatVertices()
{
if (ff->top.model == &sec)
{
ff->top.vindex = sec.vboindex[ff->top.isceiling];
ff->top.vindex = sec.iboindex[ff->top.isceiling];
}
if (ff->bottom.model == &sec)
{
ff->bottom.vindex = sec.vboindex[ff->top.isceiling];
ff->bottom.vindex = sec.iboindex[ff->top.isceiling];
}
}
}

View File

@ -453,6 +453,10 @@ void HWDrawInfo::DoSubsector(subsector_t * sub)
if (sector->validcount != validcount)
{
if (sector->Index() == 62)
{
int a = 0;
}
mVBO->CheckUpdate(sector);
}

View File

@ -306,7 +306,7 @@ public:
bool stack;
bool ceiling;
uint8_t renderflags;
int vboindex;
int iboindex;
//int vboheight;
int dynlightindex;

View File

@ -234,7 +234,7 @@ sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
{
dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakefloor];
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::vbo_fakefloor];
dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor];
}
else if (s->MoreFlags & SECMF_FAKEFLOORONLY)
@ -260,7 +260,7 @@ sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
dest->floorplane = s->floorplane;
dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakefloor];
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::vbo_fakefloor];
dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor];
}
@ -272,7 +272,7 @@ sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
{
dest->SetTexture(sector_t::ceiling, s->GetTexture(sector_t::ceiling), false);
dest->SetPlaneTexZQuick(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakeceiling];
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::vbo_fakeceiling];
dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling];
}
}
@ -280,7 +280,7 @@ sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
{
dest->ceilingplane = s->ceilingplane;
dest->SetPlaneTexZQuick(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakeceiling];
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::vbo_fakeceiling];
dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling];
}
}
@ -294,10 +294,10 @@ sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
dest->ceilingplane=s->floorplane;
dest->ceilingplane.FlipVert();
dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::floor];
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::floor];
dest->vboheight[sector_t::floor] = sec->vboheight[sector_t::floor];
dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakefloor];
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::vbo_fakefloor];
dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::floor];
dest->ClearPortal(sector_t::ceiling);
@ -347,10 +347,10 @@ sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
dest->floorplane = s->ceilingplane;
dest->floorplane.FlipVert();
dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakeceiling];
dest->iboindex[sector_t::floor] = sec->iboindex[sector_t::vbo_fakeceiling];
dest->vboheight[sector_t::floor] = s->vboheight[sector_t::ceiling];
dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::ceiling];
dest->iboindex[sector_t::ceiling] = sec->iboindex[sector_t::ceiling];
dest->vboheight[sector_t::ceiling] = sec->vboheight[sector_t::ceiling];
dest->ClearPortal(sector_t::floor);

View File

@ -229,11 +229,11 @@ void GLFlat::SetFrom3DFloor(F3DFloor *rover, bool top, bool underside)
renderstyle = rover->flags&FF_ADDITIVETRANS? STYLE_Add : STYLE_Translucent;
if (plane.model->VBOHeightcheck(plane.isceiling))
{
vboindex = plane.vindex;
iboindex = plane.vindex;
}
else
{
vboindex = -1;
iboindex = -1;
}
}
@ -298,11 +298,11 @@ void GLFlat::ProcessSector(HWDrawInfo *di, sector_t * frontsector)
{
if (frontsector->VBOHeightcheck(sector_t::floor))
{
vboindex = frontsector->vboindex[sector_t::floor];
iboindex = frontsector->iboindex[sector_t::floor];
}
else
{
vboindex = -1;
iboindex = -1;
}
ceiling = false;
@ -358,11 +358,11 @@ void GLFlat::ProcessSector(HWDrawInfo *di, sector_t * frontsector)
{
if (frontsector->VBOHeightcheck(sector_t::ceiling))
{
vboindex = frontsector->vboindex[sector_t::ceiling];
iboindex = frontsector->iboindex[sector_t::ceiling];
}
else
{
vboindex = -1;
iboindex = -1;
}
ceiling = true;

View File

@ -1087,7 +1087,8 @@ public:
vbo_fakeceiling = ceiling+2,
};
int vboindex[4]; // VBO/IBO indices of the 4 planes this sector uses during rendering
int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering. This is only needed for updating plane heights.
int iboindex[4]; // IBO indices of the 4 planes this sector uses during rendering
double vboheight[2]; // Last calculated height for the 2 planes of this actual sector
int vbocount[2]; // Total count of vertices belonging to this sector's planes. This is used when a sector height changes and also contains all attached planes.
int ibocount; // number of indices per plane (identical for all planes.) If this is -1 the index buffer is not in use.