Convert voxels to models only when starting or changing to Polymost.

Analogously to the way models are processed in a deferred manner for Polymer.

git-svn-id: https://svn.eduke32.com/eduke32@4836 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-12-26 17:29:53 +00:00
parent bd93fd2aab
commit 584ed7982a
2 changed files with 40 additions and 2 deletions

View file

@ -124,6 +124,9 @@ static void drawpixel_safe(void *s, char a)
//void loadvoxel(int32_t voxindex) { UNREFERENCED_PARAMATER(voxindex); } //void loadvoxel(int32_t voxindex) { UNREFERENCED_PARAMATER(voxindex); }
int16_t tiletovox[MAXTILES]; int16_t tiletovox[MAXTILES];
int32_t usevoxels = 1; int32_t usevoxels = 1;
#ifdef USE_OPENGL
static char *voxfilenames[MAXVOXELS], g_haveVoxels=0; // for deferred voxel->model conversion
#endif
//#define kloadvoxel loadvoxel //#define kloadvoxel loadvoxel
int32_t novoxmips = 1; int32_t novoxmips = 1;
@ -11468,6 +11471,28 @@ static void initsmost(void)
nodesperline = tabledivide32_noinline(YSAVES, ydim); nodesperline = tabledivide32_noinline(YSAVES, ydim);
} }
#ifdef USE_OPENGL
static void PolymostProcessVoxels(void)
{
if (!g_haveVoxels)
return;
g_haveVoxels = 0;
OSD_Printf("Generating voxel models for Polymost. This may take a while...\n");
nextpage();
for (int32_t i=0; i<MAXVOXELS; i++)
{
if (voxfilenames[i])
{
voxmodels[i] = voxload(voxfilenames[i]);
DO_FREE_AND_NULL(voxfilenames[i]);
}
}
}
#endif
// //
// setgamemode // setgamemode
// //
@ -11546,6 +11571,9 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da
if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); } if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); }
#ifdef USE_OPENGL #ifdef USE_OPENGL
if (getrendermode() == REND_POLYMOST)
PolymostProcessVoxels();
if (getrendermode() >= REND_POLYMOST) if (getrendermode() >= REND_POLYMOST)
{ {
polymost_glreset(); polymost_glreset();
@ -12072,7 +12100,9 @@ int32_t qloadkvx(int32_t voxindex, const char *filename)
voxmodels[voxindex] = NULL; voxmodels[voxindex] = NULL;
} }
voxmodels[voxindex] = voxload(filename); Bfree(voxfilenames[voxindex]);
voxfilenames[voxindex] = Bstrdup(filename);
g_haveVoxels = 1;
#endif #endif
return 0; return 0;

View file

@ -1461,8 +1461,16 @@ static void M_PreMenu(MenuID_t cm)
#endif #endif
case MENU_VIDEOSETUP: case MENU_VIDEOSETUP:
ME_VIDEOSETUP_APPLY.disabled = ((xdim == resolution[newresolution].xdim && ydim == resolution[newresolution].ydim && getrendermode() == newrendermode && fullscreen == newfullscreen) || (newfullscreen ? !(resolution[newresolution].flags & RES_FS) : !(resolution[newresolution].flags & RES_WIN)) || (newrendermode != REND_CLASSIC && resolution[newresolution].bppmax <= 8)); {
const int32_t nr = newresolution;
ME_VIDEOSETUP_APPLY.disabled =
((xdim == resolution[nr].xdim && ydim == resolution[nr].ydim &&
getrendermode() == newrendermode && fullscreen == newfullscreen)
|| (newfullscreen ? !(resolution[nr].flags & RES_FS) : !(resolution[nr].flags & RES_WIN))
|| (newrendermode != REND_CLASSIC && resolution[nr].bppmax <= 8));
break; break;
}
case MENU_SOUND: case MENU_SOUND:
case MENU_SOUND_INGAME: case MENU_SOUND_INGAME: