diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 815fed99a3..da1d698ba2 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -584,7 +584,8 @@ bool GLFlat::PutFlatCompat(bool fog) int list = list_indices[masked][foggy]; - gl_drawinfo->dldrawlists[list].AddFlat(this); + auto newflat = gl_drawinfo->drawlists[list].NewFlat(); + *newflat = *this; return true; } diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index c67c794682..88a6b3d8ec 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -285,8 +285,8 @@ SortNode * GLDrawList::FindSortWall(SortNode * head) //========================================================================== void GLDrawList::SortPlaneIntoPlane(SortNode * head,SortNode * sort) { - GLFlat * fh=&flats[drawitems[head->itemindex].index]; - GLFlat * fs=&flats[drawitems[sort->itemindex].index]; + GLFlat * fh= flats[drawitems[head->itemindex].index]; + GLFlat * fs= flats[drawitems[sort->itemindex].index]; if (fh->z==fs->z) head->AddToEqual(sort); @@ -304,7 +304,7 @@ void GLDrawList::SortPlaneIntoPlane(SortNode * head,SortNode * sort) //========================================================================== void GLDrawList::SortWallIntoPlane(SortNode * head, SortNode * sort) { - GLFlat * fh = &flats[drawitems[head->itemindex].index]; + GLFlat * fh = flats[drawitems[head->itemindex].index]; GLWall * ws = walls[drawitems[sort->itemindex].index]; bool ceiling = fh->z > r_viewpoint.Pos.Z; @@ -362,7 +362,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head, SortNode * sort) //========================================================================== void GLDrawList::SortSpriteIntoPlane(SortNode * head, SortNode * sort) { - GLFlat * fh = &flats[drawitems[head->itemindex].index]; + GLFlat * fh = flats[drawitems[head->itemindex].index]; GLSprite * ss = &sprites[drawitems[sort->itemindex].index]; bool ceiling = fh->z > r_viewpoint.Pos.Z; @@ -722,7 +722,7 @@ void GLDrawList::DoDraw(int pass, int i, bool trans) { case GLDIT_FLAT: { - GLFlat * f=&flats[drawitems[i].index]; + GLFlat * f= flats[drawitems[i].index]; RenderFlat.Clock(); f->Draw(pass, trans); RenderFlat.Unclock(); @@ -764,7 +764,7 @@ void GLDrawList::DoDrawSorted(SortNode * head) if (drawitems[head->itemindex].rendertype == GLDIT_FLAT) { - z = flats[drawitems[head->itemindex].index].z; + z = flats[drawitems[head->itemindex].index]->z; relation = z > r_viewpoint.Pos.Z ? 1 : -1; } @@ -878,7 +878,7 @@ void GLDrawList::DrawFlats(int pass) RenderFlat.Clock(); for(unsigned i=0;iDraw(pass, false); } RenderFlat.Unclock(); } @@ -924,8 +924,8 @@ void GLDrawList::SortFlats() { std::sort(drawitems.begin(), drawitems.end(), [=](const GLDrawItem &a, const GLDrawItem &b) { - GLFlat * w1 = &flats[a.index]; - GLFlat* w2 = &flats[b.index]; + GLFlat * w1 = flats[a.index]; + GLFlat* w2 = flats[b.index]; return w1->gltexture < w2->gltexture; }); } @@ -949,9 +949,11 @@ GLWall *GLDrawList::NewWall() // // //========================================================================== -void GLDrawList::AddFlat(GLFlat * flat) +GLFlat *GLDrawList::NewFlat() { - drawitems.Push(GLDrawItem(GLDIT_FLAT,flats.Push(*flat))); + auto flat = (GLFlat*)RenderDataAllocator.Alloc(sizeof(GLFlat)); + drawitems.Push(GLDrawItem(GLDIT_FLAT,flats.Push(flat))); + return flat; } //========================================================================== diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index c85648b6a3..b5f7522650 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -107,7 +107,7 @@ struct GLDrawList { //private: TArray walls; - TArray flats; + TArray flats; TArray sprites; TArray drawitems; int SortNodeStart; @@ -132,8 +132,7 @@ public: } GLWall *NewWall(); - //void AddWall(GLWall * wall); - void AddFlat(GLFlat * flat); + GLFlat *NewFlat(); void AddSprite(GLSprite * sprite); void Reset(); void SortWalls(); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index a3fe05c10d..769412d132 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -489,7 +489,8 @@ inline void GLFlat::PutFlat(bool fog) list = masked ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS; } dynlightindex = -1; // make sure this is always initialized to something proper. - gl_drawinfo->drawlists[list].AddFlat (this); + auto newflat = gl_drawinfo->drawlists[list].NewFlat(); + *newflat = *this; } //========================================================================== diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index e1f551b62a..0b15cddcbc 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -276,6 +276,17 @@ public: mDrawer = drawer; } + GLWall(const GLWall &other) + { + memcpy(this, &other, sizeof(GLWall)); + } + + GLWall & operator=(const GLWall &other) + { + memcpy(this, &other, sizeof(GLWall)); + return *this; + } + void Process(seg_t *seg, sector_t *frontsector, sector_t *backsector); void ProcessLowerMiniseg(seg_t *seg, sector_t *frontsector, sector_t *backsector); void Draw(int pass); @@ -349,6 +360,18 @@ public: void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside); void ProcessSector(sector_t * frontsector); void Draw(int pass, bool trans); + + GLFlat(const GLFlat &other) + { + memcpy(this, &other, sizeof(GLFlat)); + } + + GLFlat & operator=(const GLFlat &other) + { + memcpy(this, &other, sizeof(GLFlat)); + return *this; + } + };