diff --git a/src/engine/render/octarender.cpp b/src/engine/render/octarender.cpp index f2c0963fe..8255bd097 100644 --- a/src/engine/render/octarender.cpp +++ b/src/engine/render/octarender.cpp @@ -517,13 +517,12 @@ namespace va->maxvert += va->voffset; } - va->matbuf = nullptr; + va->matbuf.clear(); va->matsurfs = matsurfs.size(); va->matmask = 0; if(va->matsurfs) { - va->matbuf = new materialsurface[matsurfs.size()]; - std::memcpy(va->matbuf, matsurfs.data(), matsurfs.size()*sizeof(materialsurface)); + va->matbuf = matsurfs; for(materialsurface &m : matsurfs) { if(m.visible == MatSurf_EditOnly) @@ -2397,10 +2396,6 @@ void destroyva(vtxarray *va, bool reparent) { delete[] va->decalelems; } - if(va->matbuf) - { - delete[] va->matbuf; - } delete va; } diff --git a/src/engine/render/octarender.h b/src/engine/render/octarender.h index 2c5333ac3..e140b1c7e 100644 --- a/src/engine/render/octarender.h +++ b/src/engine/render/octarender.h @@ -56,7 +56,7 @@ struct vtxarray GLuint vbuf, ebuf, skybuf, decalbuf; // VBOs ushort minvert, maxvert; // DRE info elementset *texelems, *decalelems; // List of element indices sets (range) per texture - materialsurface *matbuf; // buffer of material surfaces + std::vector matbuf; int verts, tris, texs, diff --git a/src/engine/render/stain.cpp b/src/engine/render/stain.cpp index 5dfade2c2..d24703c7a 100644 --- a/src/engine/render/stain.cpp +++ b/src/engine/render/stain.cpp @@ -710,11 +710,10 @@ class stainrenderer void findmaterials(vtxarray *va) { - materialsurface *matbuf = va->matbuf; int matsurfs = va->matsurfs; for(int i = 0; i < matsurfs; ++i) { - materialsurface &m = matbuf[i]; + materialsurface &m = va->matbuf[i]; if(!IS_CLIPPED(m.material&MatFlag_Volume)) { i += m.skip; @@ -731,7 +730,7 @@ class stainrenderer r = R[dim]; for(;;) { - materialsurface &m = matbuf[i]; + materialsurface &m = va->matbuf[i]; if(m.o[dim] >= bbmin[dim] && m.o[dim] <= bbmax[dim] && m.o[c] + m.csize >= bbmin[c] && m.o[c] <= bbmax[c] && m.o[r] + m.rsize >= bbmin[r] && m.o[r] <= bbmax[r]) @@ -743,7 +742,7 @@ class stainrenderer { break; } - materialsurface &n = matbuf[i+1]; + materialsurface &n = va->matbuf[i+1]; if(n.material != m.material || n.orient != m.orient) { break; diff --git a/src/engine/world/material.cpp b/src/engine/world/material.cpp index a1b8e6158..38cc3987b 100644 --- a/src/engine/world/material.cpp +++ b/src/engine/world/material.cpp @@ -1152,7 +1152,7 @@ void setupmaterials(int start, int len) } for(int i = start; i < len; i++) { - const vtxarray *va = valist[i]; + vtxarray *va = valist[i]; //only modifies va->matbuf entries of valist materialsurface *skip = nullptr; for(int j = 0; j < va -> matsurfs; ++j) {