Voxel VBO load/free adjustments and re-arranging. Fixed KV6 pivots.

parent 5bdb0cd7
......@@ -8082,6 +8082,8 @@ static void PolymostProcessVoxels(void)
voxmodels[i] = voxload(voxfilenames[i]);
voxmodels[i]->scale = voxscale[i] * (1.f / 65536.f);
voxvboalloc(voxmodels[i]);
free(voxfilenames[i]);
voxfilenames[i] = NULL;
}
......
......@@ -2397,6 +2397,9 @@ static int32_t isolid(int32_t x, int32_t y, int32_t z)
void voxvboalloc(voxmodel_t* vm)
{
if (!r_vbos)
return;
const float phack[2] = { 0, 1.f / 256.f };
bglGenBuffersARB(1, &vm->vbo);
bglGenBuffersARB(1, &vm->vboindex);
......@@ -2442,8 +2445,12 @@ void voxvboalloc(voxmodel_t* vm)
void voxvbofree(voxmodel_t* vm)
{
if (!vm->vbo)
return;
bglDeleteBuffersARB(1, &vm->vbo);
bglDeleteBuffersARB(1, &vm->vboindex);
vm->vbo = 0;
}
static voxmodel_t *vox2poly()
......@@ -2659,9 +2666,6 @@ skindidntfit:
}
free(shp); free(zbit); free(bx0);
if (r_vbos)
voxvboalloc(gvox);
return(gvox);
}
......@@ -2798,9 +2802,9 @@ static int32_t loadkv6(const char *filnam)
kread(fil,&voxsiz.x,4); voxsiz.x = B_LITTLE32(voxsiz.x);
kread(fil,&voxsiz.y,4); voxsiz.y = B_LITTLE32(voxsiz.y);
kread(fil,&voxsiz.z,4); voxsiz.z = B_LITTLE32(voxsiz.z);
kread(fil,&i,4); xpiv = (float)(B_LITTLE32(i));
kread(fil,&i,4); ypiv = (float)(B_LITTLE32(i));
kread(fil,&i,4); zpiv = (float)(B_LITTLE32(i));
kread(fil, &i, 4); i = B_LITTLE32(i); xpiv = *(float*)&i;
kread(fil, &i, 4); i = B_LITTLE32(i); ypiv = *(float*)&i;
kread(fil, &i, 4); i = B_LITTLE32(i); zpiv = *(float*)&i;
kread(fil,&numvoxs,4); numvoxs = B_LITTLE32(numvoxs);
ylen = (uint16_t *)malloc(voxsiz.x*voxsiz.y*sizeof(int16_t));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment