Fix portals (and compiles again with gcc).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3604 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2010-08-29 13:49:43 +00:00
parent 9cbdfb7fd0
commit 9f29f8d97f
4 changed files with 47 additions and 31 deletions

View file

@ -1839,7 +1839,10 @@ void Surf_SetupFrame(void)
r_oldviewcluster = r_viewcluster; r_oldviewcluster = r_viewcluster;
r_oldviewcluster2 = r_viewcluster2; r_oldviewcluster2 = r_viewcluster2;
leaf = RMod_PointInLeaf (cl.worldmodel, r_origin); if (r_refdef.recurse)
leaf = RMod_PointInLeaf (cl.worldmodel, r_refdef.pvsorigin);
else
leaf = RMod_PointInLeaf (cl.worldmodel, r_origin);
r_viewcluster = r_viewcluster2 = leaf->cluster; r_viewcluster = r_viewcluster2 = leaf->cluster;
// check above and below so crossing solid water doesn't draw wrong // check above and below so crossing solid water doesn't draw wrong

View file

@ -219,7 +219,7 @@ void GLR_InitTextures (void);
void GLR_InitEfrags (void); void GLR_InitEfrags (void);
void GLR_RenderView (void); // must set r_refdef first void GLR_RenderView (void); // must set r_refdef first
// called whenever r_refdef or vid change // called whenever r_refdef or vid change
void R_DrawPortal(struct batch_s *batch); void R_DrawPortal(struct batch_s *batch, struct batch_s **blist);
void GLR_PreNewMap(void); void GLR_PreNewMap(void);
void GLR_NewMap (void); void GLR_NewMap (void);

View file

@ -2818,7 +2818,7 @@ static void BE_SubmitBatch(batch_t *batch)
} }
} }
static void BE_SubmitMeshesPortals(batch_t *worldlist, batch_t *dynamiclist) static void BE_SubmitMeshesPortals(batch_t **worldlist, batch_t *dynamiclist)
{ {
batch_t *batch, *old; batch_t *batch, *old;
int i; int i;
@ -2827,14 +2827,20 @@ static void BE_SubmitMeshesPortals(batch_t *worldlist, batch_t *dynamiclist)
{ {
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
for (batch = i?dynamiclist:worldlist; batch; batch = batch->next) for (batch = i?dynamiclist:worldlist[SHADER_SORT_PORTAL]; batch; batch = batch->next)
{ {
if (batch->meshes == batch->firstmesh) if (batch->meshes == batch->firstmesh)
continue; continue;
if (batch->buildmeshes)
batch->buildmeshes(batch);
else
batch->shader = R_TextureAnimation(batch->ent->framestate.g[FS_REG].frame[0], batch->texture)->shader;
/*draw already-drawn portals as depth-only, to ensure that their contents are not harmed*/ /*draw already-drawn portals as depth-only, to ensure that their contents are not harmed*/
BE_SelectMode(BEM_DEPTHONLY, 0); BE_SelectMode(BEM_DEPTHONLY, 0);
for (old = worldlist; old && old != batch; old = old->next) for (old = worldlist[SHADER_SORT_PORTAL]; old && old != batch; old = old->next)
{ {
if (old->meshes == old->firstmesh) if (old->meshes == old->firstmesh)
continue; continue;
@ -2851,9 +2857,7 @@ static void BE_SubmitMeshesPortals(batch_t *worldlist, batch_t *dynamiclist)
} }
BE_SelectMode(BEM_STANDARD, 0); BE_SelectMode(BEM_STANDARD, 0);
#if 0 R_DrawPortal(batch, worldlist);
R_DrawPortal(batch);
#endif
/*clear depth again*/ /*clear depth again*/
GL_ForceDepthWritable(); GL_ForceDepthWritable();
@ -2902,7 +2906,7 @@ void BE_SubmitMeshes (qboolean drawworld, batch_t **blist)
if (drawworld) if (drawworld)
{ {
if (i == SHADER_SORT_PORTAL && !r_noportals.ival && !r_refdef.recurse) if (i == SHADER_SORT_PORTAL && !r_noportals.ival && !r_refdef.recurse)
BE_SubmitMeshesPortals(model->batches[i], blist[i]); BE_SubmitMeshesPortals(model->batches, blist[i]);
BE_SubmitMeshesSortList(model->batches[i]); BE_SubmitMeshesSortList(model->batches[i]);
} }
@ -3154,23 +3158,26 @@ void BE_DrawWorld (qbyte *vis)
RSpeedLocals(); RSpeedLocals();
GL_DoSwap(); GL_DoSwap();
if (shaderstate.wmesh > shaderstate.maxwmesh) if (!r_refdef.recurse)
{ {
int newm = shaderstate.wmesh; if (shaderstate.wmesh > shaderstate.maxwmesh)
shaderstate.wmeshes = BZ_Realloc(shaderstate.wmeshes, newm * sizeof(*shaderstate.wmeshes)); {
memset(shaderstate.wmeshes + shaderstate.maxwmesh, 0, (newm - shaderstate.maxwmesh) * sizeof(*shaderstate.wmeshes)); int newm = shaderstate.wmesh;
shaderstate.maxwmesh = newm; shaderstate.wmeshes = BZ_Realloc(shaderstate.wmeshes, newm * sizeof(*shaderstate.wmeshes));
} memset(shaderstate.wmeshes + shaderstate.maxwmesh, 0, (newm - shaderstate.maxwmesh) * sizeof(*shaderstate.wmeshes));
if (shaderstate.wbatch > shaderstate.maxwbatches) shaderstate.maxwmesh = newm;
{ }
int newm = shaderstate.wbatch; if (shaderstate.wbatch > shaderstate.maxwbatches)
shaderstate.wbatches = BZ_Realloc(shaderstate.wbatches, newm * sizeof(*shaderstate.wbatches)); {
memset(shaderstate.wbatches + shaderstate.maxwbatches, 0, (newm - shaderstate.maxwbatches) * sizeof(*shaderstate.wbatches)); int newm = shaderstate.wbatch;
shaderstate.maxwbatches = newm; shaderstate.wbatches = BZ_Realloc(shaderstate.wbatches, newm * sizeof(*shaderstate.wbatches));
} memset(shaderstate.wbatches + shaderstate.maxwbatches, 0, (newm - shaderstate.maxwbatches) * sizeof(*shaderstate.wbatches));
shaderstate.maxwbatches = newm;
}
shaderstate.wmesh = 0; shaderstate.wmesh = 0;
shaderstate.wbatch = 0; shaderstate.wbatch = 0;
}
BE_GenModelBatches(batches); BE_GenModelBatches(batches);
shaderstate.curentity = NULL; shaderstate.curentity = NULL;

View file

@ -1276,13 +1276,14 @@ static void TransformDir(vec3_t in, vec3_t planea[3], vec3_t viewa[3], vec3_t re
VectorMA(result, d, viewa[i], result); VectorMA(result, d, viewa[i], result);
} }
} }
void R_DrawPortal(batch_t *batch, batch_t *blist) void R_DrawPortal(batch_t *batch, batch_t **blist)
{ {
entity_t *view; entity_t *view;
GLdouble glplane[4]; GLdouble glplane[4];
plane_t plane; plane_t plane;
refdef_t oldrefdef; refdef_t oldrefdef;
mesh_t *mesh = batch->mesh[batch->firstmesh]; mesh_t *mesh = batch->mesh[batch->firstmesh];
int sort;
if (r_refdef.recurse) if (r_refdef.recurse)
return; return;
@ -1323,7 +1324,7 @@ void R_DrawPortal(batch_t *batch, batch_t *blist)
/*calculate where the surface is meant to be*/ /*calculate where the surface is meant to be*/
VectorCopy(mesh->normals_array[0], paxis[0]); VectorCopy(mesh->normals_array[0], paxis[0]);
PerpendicularVector(paxis[1], paxis[1]); PerpendicularVector(paxis[1], paxis[0]);
CrossProduct(paxis[0], paxis[1], paxis[2]); CrossProduct(paxis[0], paxis[1], paxis[2]);
d = DotProduct(view->origin, plane.normal) - plane.dist; d = DotProduct(view->origin, plane.normal) - plane.dist;
VectorMA(view->origin, -d, paxis[0], porigin); VectorMA(view->origin, -d, paxis[0], porigin);
@ -1352,7 +1353,8 @@ void R_DrawPortal(batch_t *batch, batch_t *blist)
/*FIXME: the batch stuff should be done in renderscene*/ /*FIXME: the batch stuff should be done in renderscene*/
/*fixup the first mesh index*/ /*fixup the first mesh index*/
for (batch = blist; batch; batch = batch->next) for (sort = 0; sort < SHADER_SORT_COUNT; sort++)
for (batch = blist[sort]; batch; batch = batch->next)
{ {
batch->firstmesh = batch->meshes; batch->firstmesh = batch->meshes;
} }
@ -1370,7 +1372,8 @@ void R_DrawPortal(batch_t *batch, batch_t *blist)
R_RenderScene(); R_RenderScene();
qglDisable(GL_CLIP_PLANE0); qglDisable(GL_CLIP_PLANE0);
for (batch = blist; batch; batch = batch->next) for (sort = 0; sort < SHADER_SORT_COUNT; sort++)
for (batch = blist[sort]; batch; batch = batch->next)
{ {
batch->firstmesh = 0; batch->firstmesh = 0;
} }
@ -1827,9 +1830,6 @@ void GLR_RenderView (void)
R_RenderScene (); R_RenderScene ();
} }
if (r_bloom.ival)
R_BloomBlend();
// qglDisable(GL_FOG); // qglDisable(GL_FOG);
if (r_speeds.ival) if (r_speeds.ival)
@ -1850,6 +1850,9 @@ void GLR_RenderView (void)
if (r_refdef.flags & Q2RDF_NOWORLDMODEL) if (r_refdef.flags & Q2RDF_NOWORLDMODEL)
return; return;
if (r_bloom.ival)
R_BloomBlend();
// SCENE POST PROCESSING // SCENE POST PROCESSING
// we check if we need to use any shaders - currently it's just waterwarp // we check if we need to use any shaders - currently it's just waterwarp
if ((r_waterwarp.value>0 && r_viewleaf && r_viewleaf->contents <= Q1CONTENTS_WATER)) if ((r_waterwarp.value>0 && r_viewleaf && r_viewleaf->contents <= Q1CONTENTS_WATER))
@ -1863,6 +1866,9 @@ void GLR_RenderView (void)
if (gl_motionblur.value>0 && gl_motionblur.value < 1 && qglCopyTexImage2D) if (gl_motionblur.value>0 && gl_motionblur.value < 1 && qglCopyTexImage2D)
R_RenderMotionBlur(); R_RenderMotionBlur();
if (qglGetError())
Con_Printf("GL Error drawing post processing\n");
} }
#endif #endif