From 584ed7982aa649118d466e874d4551b514b7ca53 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 26 Dec 2014 17:29:53 +0000 Subject: [PATCH] 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 --- polymer/eduke32/build/src/engine.c | 32 +++++++++++++++++++++++++++++- polymer/eduke32/source/menus.c | 10 +++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index e0a58a99c..b5404372b 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -124,6 +124,9 @@ static void drawpixel_safe(void *s, char a) //void loadvoxel(int32_t voxindex) { UNREFERENCED_PARAMATER(voxindex); } int16_t tiletovox[MAXTILES]; int32_t usevoxels = 1; +#ifdef USE_OPENGL +static char *voxfilenames[MAXVOXELS], g_haveVoxels=0; // for deferred voxel->model conversion +#endif //#define kloadvoxel loadvoxel int32_t novoxmips = 1; @@ -11468,6 +11471,28 @@ static void initsmost(void) 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>1); } #ifdef USE_OPENGL + if (getrendermode() == REND_POLYMOST) + PolymostProcessVoxels(); + if (getrendermode() >= REND_POLYMOST) { polymost_glreset(); @@ -12072,7 +12100,9 @@ int32_t qloadkvx(int32_t voxindex, const char *filename) voxmodels[voxindex] = NULL; } - voxmodels[voxindex] = voxload(filename); + Bfree(voxfilenames[voxindex]); + voxfilenames[voxindex] = Bstrdup(filename); + g_haveVoxels = 1; #endif return 0; diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 4f6d88ef9..c8e391a13 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -1461,8 +1461,16 @@ static void M_PreMenu(MenuID_t cm) #endif 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; + } case MENU_SOUND: case MENU_SOUND_INGAME: