From bd93fd2aab856fc18fa6f696e6662d47c5e2b518 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 26 Dec 2014 17:29:52 +0000 Subject: [PATCH] A couple of miscellaneous cleanups. defs.c: sync some dup'd code for 'definevoxel' and 'voxel' DEF tokens. engine.c: factor out PolymerProcessModels(). git-svn-id: https://svn.eduke32.com/eduke32@4835 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/defs.c | 20 +++++++-- polymer/eduke32/build/src/engine.c | 72 ++++++++++++++++-------------- 2 files changed, 54 insertions(+), 38 deletions(-) diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index 65a8c0ee8..8da871279 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -920,7 +920,7 @@ static int32_t defsparser(scriptfile *script) if (EDUKE32_PREDICT_FALSE(nextvoxid == MAXVOXELS)) { - initprintf("Maximum number of voxels already defined.\n"); + initprintf("Maximum number of voxels (%d) already defined.\n", MAXVOXELS); break; } @@ -1421,9 +1421,21 @@ static int32_t defsparser(scriptfile *script) { "scale", T_SCALE }, }; - if (EDUKE32_PREDICT_FALSE(scriptfile_getstring(script,&fn))) break; //voxel filename - if (EDUKE32_PREDICT_FALSE(nextvoxid == MAXVOXELS)) { initprintf("Maximum number of voxels already defined.\n"); break; } - if (EDUKE32_PREDICT_FALSE(qloadkvx(nextvoxid, fn))) { initprintf("Failure loading voxel file \"%s\"\n",fn); break; } + if (EDUKE32_PREDICT_FALSE(scriptfile_getstring(script,&fn))) + break; //voxel filename + + if (EDUKE32_PREDICT_FALSE(nextvoxid == MAXVOXELS)) + { + initprintf("Maximum number of voxels (%d) already defined.\n", MAXVOXELS); + break; + } + + if (EDUKE32_PREDICT_FALSE(qloadkvx(nextvoxid, fn))) + { + initprintf("Failure loading voxel file \"%s\"\n",fn); + break; + } + lastvoxid = nextvoxid++; if (scriptfile_getbraces(script,&modelend)) break; diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index a9b049e2e..e0a58a99c 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -17682,6 +17682,35 @@ int32_t screencapture(const char *filename, char inverseit, const char *versions } +#ifdef POLYMER +static void PolymerProcessModels(void) +{ + // potentially deferred MD3 postprocessing + for (int32_t i=0; imdnum==3 && ((md3model_t *)models[i])->head.surfs[0].geometry == NULL) + { + static int32_t warned=0; + + if (!warned) + { + OSD_Printf("Post-processing MD3 models for Polymer. This may take a while...\n"); + nextpage(); + warned = 1; + } + + if (!md3postload_polymer((md3model_t *)models[i])) + OSD_Printf("INTERNAL ERROR: mdmodel %s failed postprocessing!\n", + ((md3model_t *)models[i])->head.nam); + + if (((md3model_t *)models[i])->head.surfs[0].geometry == NULL) + OSD_Printf("INTERNAL ERROR: wtf?\n"); + } +// else +// OSD_Printf("mdmodel %d already postprocessed.\n", i); + } +} +#endif // // setrendermode @@ -17689,42 +17718,20 @@ int32_t screencapture(const char *filename, char inverseit, const char *versions int32_t setrendermode(int32_t renderer) { UNREFERENCED_PARAMETER(renderer); + #ifdef USE_OPENGL - if (bpp == 8) renderer = 0; + if (bpp == 8) + renderer = REND_CLASSIC; # ifdef POLYMER - else renderer = min(4,max(3,renderer)); + else + renderer = clamp(renderer, REND_POLYMOST, REND_POLYMER); - if (renderer == 4) + if (renderer == REND_POLYMER) { - int32_t i; - - // potentially deferred MD3 postprocessing - for (i=0; imdnum==3 && ((md3model_t *)models[i])->head.surfs[0].geometry == NULL) - { - static int32_t warned=0; - - if (!warned) - { - OSD_Printf("Post-processing MD3 models for Polymer. This can take a while...\n"); - nextpage(); - warned = 1; - } - - if (!md3postload_polymer((md3model_t *)models[i])) - OSD_Printf("INTERNAL ERROR: mdmodel %s failed postprocessing!\n", - ((md3model_t *)models[i])->head.nam); - - if (((md3model_t *)models[i])->head.surfs[0].geometry == NULL) - OSD_Printf("INTERNAL ERROR: wtf?\n"); - } -// else -// OSD_Printf("mdmodel %d already postprocessed.\n", i); - } + PolymerProcessModels(); if (!polymer_init()) - renderer = 3; + renderer = REND_POLYMOST; } else if (getrendermode() == REND_POLYMER) // going from Polymer to another renderer { @@ -17732,8 +17739,6 @@ int32_t setrendermode(int32_t renderer) G_Polymer_UnInit(); polymer_uninit(); } -# else - else renderer = 3; # endif basepalreset = 1; @@ -17752,7 +17757,7 @@ int32_t setrendermode(int32_t renderer) #ifdef USE_OPENGL void setrollangle(int32_t rolla) { - gtang = (float) rolla * PI * (1.f/1024.f); + gtang = (float)rolla * PI * (1.f/1024.f); } #endif @@ -17796,7 +17801,6 @@ void invalidatetile(int16_t tilenume, int32_t pal, int32_t how) if (getrendermode() == REND_POLYMER) polymer_invalidateartmap(tilenume); #endif - } #endif }