From e7f754505b360f7a78448fab71db2b66b8a6cb5c Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 18 Sep 2008 03:13:49 +0000 Subject: [PATCH] avoid second rendering pass when possible git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2679 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/protos.h | 1 + source/src/rendermodel.cpp | 7 ++++++- source/src/shadow.cpp | 16 ++++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/src/protos.h b/source/src/protos.h index f3f12b7f..93120a53 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -547,6 +547,7 @@ extern void updateaudio(); extern void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, float yaw, float pitch, float speed = 0, int basetime = 0, playerent *d = NULL, modelattach *a = NULL, float scale = 1.0f); extern void startmodelbatches(); extern void endmodelbatches(bool flush = true); +extern void clearmodelbatches(); extern mapmodelinfo &getmminfo(int i); extern int findanim(const char *name); extern void loadskin(const char *dir, const char *altdir, Texture *&skin); diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 8f53b52b..42e598e4 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -268,6 +268,11 @@ static int sorttranslucentmodels(const translucentmodel *x, const translucentmod return 0; } +void clearmodelbatches() +{ + numbatches = -1; +} + void endmodelbatches(bool flush) { vector translucent; @@ -318,7 +323,7 @@ void endmodelbatches(bool flush) } if(lastmodel) lastmodel->endrender(); } - if(flush) numbatches = -1; + if(flush) clearmodelbatches(); } void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, float yaw, float pitch, float speed, int basetime, playerent *d, modelattach *a, float scale) diff --git a/source/src/shadow.cpp b/source/src/shadow.cpp index e2b57f70..6d4e3206 100644 --- a/source/src/shadow.cpp +++ b/source/src/shadow.cpp @@ -374,15 +374,19 @@ void drawstencilshadows() renderbounceents(); endmodelbatches(false); - stenciling = 2; + if(shadowcasters) + { + stenciling = 2; - glStencilFunc(GL_ALWAYS, 0, ~0U); - glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); - glCullFace(GL_BACK); + glStencilFunc(GL_ALWAYS, 0, ~0U); + glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); + glCullFace(GL_BACK); - endmodelbatches(true); + endmodelbatches(true); - glCullFace(GL_FRONT); + glCullFace(GL_FRONT); + } + else clearmodelbatches(); } stenciling = 0;