mirror of
https://github.com/nzp-team/dquakeplus.git
synced 2024-11-22 11:51:21 +00:00
Merge pull request #15 from shpuld/feat/render-static-brush-models-with-world
Render static brush models with world
This commit is contained in:
commit
a4d4d31727
4 changed files with 127 additions and 43 deletions
|
@ -73,6 +73,8 @@ modelindex_t cl_modelindex[NUM_MODELINDEX];
|
|||
|
||||
int cl_numvisedicts;
|
||||
entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
int cl_numstaticbrushmodels;
|
||||
entity_t *cl_staticbrushmodels[MAX_VISEDICTS];
|
||||
|
||||
void CL_ClearTEnts (void);
|
||||
|
||||
|
@ -547,7 +549,7 @@ void CL_RelinkEntities (void)
|
|||
|
||||
|
||||
cl_numvisedicts = 0;
|
||||
|
||||
cl_numstaticbrushmodels = 0;
|
||||
//
|
||||
// interpolate player info
|
||||
//
|
||||
|
@ -591,6 +593,23 @@ void CL_RelinkEntities (void)
|
|||
continue;
|
||||
}
|
||||
|
||||
// shpuld: if brush model is at 0 with no angle changes, we can draw it with world
|
||||
if (ent->model->type == mod_brush && cl_numstaticbrushmodels < MAX_VISEDICTS)
|
||||
{
|
||||
if (ent->msg_origins[0][0] == 0 &&
|
||||
ent->msg_origins[0][1] == 0 &&
|
||||
ent->msg_origins[0][2] == 0 &&
|
||||
ent->msg_angles[0][0] == 0 &&
|
||||
ent->msg_angles[0][1] == 0 &&
|
||||
ent->msg_angles[0][2] == 0 &&
|
||||
(ent->rendermode == 0 || ent->rendermode == TEX_SOLID || ent->rendermode == TEX_TEXTURE))
|
||||
{
|
||||
cl_staticbrushmodels[cl_numstaticbrushmodels] = ent;
|
||||
cl_numstaticbrushmodels++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
VectorCopy (ent->origin, oldorg);
|
||||
|
||||
if (ent->forcelink)
|
||||
|
|
|
@ -332,6 +332,8 @@ void CL_NextDemo (void);
|
|||
#define MAX_VISEDICTS 256
|
||||
extern int cl_numvisedicts;
|
||||
extern entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
extern int cl_numstaticbrushmodels;
|
||||
extern entity_t *cl_staticbrushmodels[MAX_VISEDICTS];
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1063,8 +1063,7 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
|
|||
struct vertex
|
||||
{
|
||||
int uvs;
|
||||
char x, y, z;
|
||||
char _padding;
|
||||
int xyz;
|
||||
};
|
||||
|
||||
sceGuColor(GU_COLOR(lightcolor[0], lightcolor[1], lightcolor[2], 1.0f));
|
||||
|
@ -1116,17 +1115,11 @@ void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum)
|
|||
//prim = GU_TRIANGLES; //used for blubs' alternate BuildTris with one continual triangle list
|
||||
}
|
||||
//================================================================== fps: 50 ===============================================
|
||||
for (int start = vertex_index; vertex_index < (start + count); ++vertex_index)
|
||||
for (int start = vertex_index; vertex_index < (start + count); ++vertex_index, ++order, ++verts)
|
||||
{
|
||||
// texture coordinates come from the draw list
|
||||
out[vertex_index].uvs = order[0];
|
||||
order += 1;
|
||||
|
||||
out[vertex_index].x = verts->v[0];
|
||||
out[vertex_index].y = verts->v[1];
|
||||
out[vertex_index].z = verts->v[2];
|
||||
|
||||
++verts;
|
||||
out[vertex_index].xyz = ((int*)verts->v)[0]; // cast to int because trivertx is is 4 bytes
|
||||
}
|
||||
sceGuDrawArray(prim, GU_TEXTURE_16BIT | GU_VERTEX_8BIT, count, 0, &out[vertex_index - count]);
|
||||
|
||||
|
@ -1204,26 +1197,17 @@ void GL_DrawAliasBlendedFrame (aliashdr_t *paliashdr, int pose1, int pose2, floa
|
|||
//prim = GU_TRIANGLES; //used for blubs' alternate BuildTris with one continual triangle list
|
||||
}
|
||||
|
||||
for (int start = vertex_index; vertex_index < (start + count); ++vertex_index)
|
||||
for (int start = vertex_index; vertex_index < (start + count); ++vertex_index, ++order, ++verts1, ++verts2)
|
||||
{
|
||||
|
||||
// texture coordinates come from the draw list
|
||||
out[vertex_index].uvs = order[0];
|
||||
order += 1;
|
||||
|
||||
VectorSubtract(verts2->v, verts1->v, d);
|
||||
|
||||
// blend the vertex positions from each frame together
|
||||
point[0] = verts1->v[0] + (blend * d[0]);
|
||||
point[1] = verts1->v[1] + (blend * d[1]);
|
||||
point[2] = verts1->v[2] + (blend * d[2]);
|
||||
|
||||
out[vertex_index].x = point[0];
|
||||
out[vertex_index].y = point[1];
|
||||
out[vertex_index].z = point[2];
|
||||
|
||||
++verts1;
|
||||
++verts2;
|
||||
out[vertex_index].x = verts1->v[0] + (blend * d[0]);
|
||||
out[vertex_index].y = verts1->v[1] + (blend * d[1]);
|
||||
out[vertex_index].z = verts1->v[2] + (blend * d[2]);
|
||||
}
|
||||
sceGuDrawArray(prim, GU_TEXTURE_16BIT | GU_VERTEX_8BIT, count, 0, &out[vertex_index - count]);
|
||||
}
|
||||
|
|
|
@ -776,6 +776,7 @@ static void R_BlendLightmaps (void)
|
|||
sceGuDepthMask(GU_TRUE);
|
||||
sceGuEnable(GU_BLEND);
|
||||
sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_SRC_COLOR, 0, 0);
|
||||
sceGuDepthFunc(GU_EQUAL);
|
||||
|
||||
if(LIGHTMAP_BYTES == 1)
|
||||
VID_SetPaletteLM();
|
||||
|
@ -828,6 +829,7 @@ static void R_BlendLightmaps (void)
|
|||
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
|
||||
sceGuDepthMask (GU_FALSE);
|
||||
sceGuEnable(GU_DEPTH_TEST); // dr_mabuse1981: fix
|
||||
sceGuDepthFunc(GU_LEQUAL);
|
||||
}
|
||||
|
||||
int ClipFace (msurface_t * fa)
|
||||
|
@ -922,11 +924,6 @@ void R_RenderBrushPoly (msurface_t *fa)
|
|||
if (verts_count <= 0)
|
||||
return;
|
||||
|
||||
sceGuEnable(GU_ALPHA_TEST);
|
||||
sceGuAlphaFunc(GU_GREATER, 0xaa, 0xff);
|
||||
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
|
||||
sceGuColor(0xffffffff);
|
||||
|
||||
// motolegacy -- use our new texflag hack
|
||||
if (fa->flags & TEXFLAG_NODRAW)
|
||||
return;
|
||||
|
@ -987,8 +984,6 @@ dynamic:
|
|||
|
||||
}
|
||||
}
|
||||
sceGuAlphaFunc(GU_GREATER, 0, 0xff);
|
||||
sceGuDisable(GU_ALPHA_TEST);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1099,6 +1094,11 @@ static void DrawTextureChains (void)
|
|||
msurface_t *s;
|
||||
texture_t *t;
|
||||
|
||||
sceGuEnable(GU_ALPHA_TEST);
|
||||
sceGuAlphaFunc(GU_GREATER, 0xaa, 0xff);
|
||||
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
|
||||
sceGuColor(0xffffffff);
|
||||
|
||||
for (i=0 ; i<cl.worldmodel->numtextures ; i++)
|
||||
{
|
||||
t = cl.worldmodel->textures[i];
|
||||
|
@ -1127,6 +1127,9 @@ static void DrawTextureChains (void)
|
|||
t->texturechain = NULL;
|
||||
}
|
||||
|
||||
sceGuAlphaFunc(GU_GREATER, 0, 0xff);
|
||||
sceGuDisable(GU_ALPHA_TEST);
|
||||
|
||||
//EmitUnderWaterPolys (); //blubsremoved quartal
|
||||
//EmitDetailPolys ();
|
||||
|
||||
|
@ -1237,13 +1240,6 @@ void R_DrawBrushModel (entity_t *e)
|
|||
GU_COLOR(alpha2,alpha2,alpha2,alpha2));
|
||||
dlight = qfalse;
|
||||
}
|
||||
else if (ISSOLID(e))
|
||||
{
|
||||
sceGuEnable(GU_ALPHA_TEST);
|
||||
int c = (int)(e->renderamt * 255.0f);
|
||||
sceGuAlphaFunc(GU_GREATER, c, 0xff);
|
||||
dlight = qfalse;
|
||||
}
|
||||
else if (ISGLOW(e))
|
||||
{
|
||||
sceGuTexFunc(GU_TFX_MODULATE , GU_TCC_RGBA);
|
||||
|
@ -1251,12 +1247,23 @@ void R_DrawBrushModel (entity_t *e)
|
|||
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_FIX, 0, 0xFFFFFFFF);
|
||||
R_GlowSetupBegin(e);
|
||||
}
|
||||
// shpuld: these have been broken for who knows how long, both were treated as just fence
|
||||
// this is fine, but it's good to be more explicit about it in code, hence I'm commenting them out.
|
||||
/*
|
||||
else if (ISSOLID(e))
|
||||
{
|
||||
sceGuEnable(GU_ALPHA_TEST);
|
||||
int c = (int)(e->renderamt * 255.0f);
|
||||
sceGuAlphaFunc(GU_GREATER, c, 0xff);
|
||||
dlight = qfalse;
|
||||
}
|
||||
else if (ISTEXTURE(e))
|
||||
{
|
||||
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
|
||||
sceGuColor(GU_RGBA(255, 255, 255, (int)(e->renderamt * 255.0f)));
|
||||
dlight = qfalse;
|
||||
}
|
||||
*/
|
||||
else if (ISCOLOR(e))
|
||||
{
|
||||
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
|
||||
|
@ -1264,6 +1271,13 @@ void R_DrawBrushModel (entity_t *e)
|
|||
(int)(e->rendercolor[1] * 255.0f),
|
||||
(int)(e->rendercolor[2] * 255.0f), 255));
|
||||
}
|
||||
else
|
||||
{
|
||||
sceGuEnable(GU_ALPHA_TEST);
|
||||
sceGuAlphaFunc(GU_GREATER, 0xaa, 0xff);
|
||||
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
|
||||
sceGuColor(0xffffffff);
|
||||
}
|
||||
//Con_DPrintf("\n");
|
||||
//Con_DPrintf("render mode is: %i \n", (int)e->rendermode);
|
||||
//Con_DPrintf("render mask is: %i \n", (int)(e->renderamt * 255.0f));
|
||||
|
@ -1308,11 +1322,6 @@ void R_DrawBrushModel (entity_t *e)
|
|||
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
|
||||
sceGuDisable (GU_BLEND);
|
||||
}
|
||||
else if(ISSOLID(e))
|
||||
{
|
||||
sceGuAlphaFunc(GU_GREATER, 0, 0xff);
|
||||
sceGuDisable(GU_ALPHA_TEST);
|
||||
}
|
||||
else if(ISGLOW(e))
|
||||
{
|
||||
R_GlowSetupEnd(e);
|
||||
|
@ -1326,11 +1335,23 @@ void R_DrawBrushModel (entity_t *e)
|
|||
sceGuColor(0xffffffff);
|
||||
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
sceGuAlphaFunc(GU_GREATER, 0, 0xff);
|
||||
sceGuDisable(GU_ALPHA_TEST);
|
||||
}
|
||||
/*
|
||||
else if(ISSOLID(e))
|
||||
{
|
||||
sceGuAlphaFunc(GU_GREATER, 0, 0xff);
|
||||
sceGuDisable(GU_ALPHA_TEST);
|
||||
}
|
||||
else if(ISTEXTURE(e))
|
||||
{
|
||||
sceGuColor(0xffffffff);
|
||||
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
|
||||
}
|
||||
*/
|
||||
//dr_mabuse1981: commented out, this was the one who caused the epic lag
|
||||
//DrawFullBrightTextures (clmodel->surfaces, clmodel->numsurfaces);
|
||||
//dr_mabuse1981: commented out, this was the one who caused the epic lag
|
||||
|
@ -1477,6 +1498,62 @@ void R_RecursiveWorldNode (mnode_t *node)
|
|||
R_RecursiveWorldNode (node->children[!side]);
|
||||
}
|
||||
|
||||
void R_AddBrushModelToChains (entity_t * e)
|
||||
{
|
||||
model_t * clmodel = e->model;
|
||||
vec3_t mins, maxs;
|
||||
VectorAdd (e->origin, clmodel->mins, mins);
|
||||
VectorAdd (e->origin, clmodel->maxs, maxs);
|
||||
int frustum_check = R_FrustumCheckBox(mins, maxs);
|
||||
if (frustum_check < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
msurface_t * psurf = &clmodel->surfaces[clmodel->firstmodelsurface];
|
||||
|
||||
/*
|
||||
if (clmodel->firstmodelsurface != 0)
|
||||
{
|
||||
for (int k = 0; k < MAX_DLIGHTS; k++)
|
||||
{
|
||||
if ((cl_dlights[k].die < cl.time) ||
|
||||
(!cl_dlights[k].radius))
|
||||
continue;
|
||||
|
||||
R_MarkLights (&cl_dlights[k], 1<<k, clmodel->nodes + clmodel->hulls[0].firstclipnode);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for (int j = 0; j < clmodel->nummodelsurfaces; j++, psurf++)
|
||||
{
|
||||
// find which side of the node we are on
|
||||
mplane_t * pplane = psurf->plane;
|
||||
float dot = DotProduct (modelorg, pplane->normal) - pplane->dist;
|
||||
// draw the polygon
|
||||
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
|
||||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
|
||||
{
|
||||
psurf->flags &= ~SURF_NEEDSCLIPPING;
|
||||
psurf->flags |= SURF_NEEDSCLIPPING * (frustum_check > 1);
|
||||
|
||||
psurf->texturechain = psurf->texinfo->texture->texturechain;
|
||||
psurf->texinfo->texture->texturechain = psurf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void R_AddStaticBrushModelsToChains ()
|
||||
{
|
||||
// Con_Printf("static models %d\n", cl_numstaticbrushmodels);
|
||||
for (int i = 0; i < cl_numstaticbrushmodels; i++)
|
||||
{
|
||||
// if (i >= 1) return;
|
||||
R_AddBrushModelToChains(cl_staticbrushmodels[i]);
|
||||
}
|
||||
}
|
||||
|
||||
extern char skybox_name[32];
|
||||
/*
|
||||
=============
|
||||
|
@ -1503,6 +1580,8 @@ void R_DrawWorld (void)
|
|||
|
||||
R_RecursiveWorldNode (cl.worldmodel->nodes);
|
||||
|
||||
R_AddStaticBrushModelsToChains ();
|
||||
|
||||
DrawTextureChains ();
|
||||
|
||||
R_BlendLightmaps ();
|
||||
|
|
Loading…
Reference in a new issue