More stuff broken.

Added control over texture coords on particles. Switched them to batch based on common render state. Less state changes there now.
Inverted sorting, to aid depth culling.
fullbrights use vbos too now.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3261 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2009-07-11 20:56:09 +00:00
parent d0e156d4b5
commit b5ac90d523
9 changed files with 535 additions and 331 deletions

View File

@ -67,6 +67,7 @@ typedef struct particle_s
vec3_t rgb;
float alpha;
float scale;
float s1, t1, s2, t2;
vec3_t vel; //renderer uses for sparks
float angle;
@ -118,7 +119,8 @@ typedef struct skytris_s {
struct msurface_s *face;
} skytris_t;
//these are the details of each particle which are exposed at render time - things that are static
//these is the required render state for each particle
//dynamic per-particle stuff isn't important. only static state.
typedef struct {
enum {PT_NORMAL, PT_SPARK, PT_SPARKFAN, PT_TEXTUREDSPARK, PT_BEAM, PT_DECAL} type;
@ -161,7 +163,12 @@ typedef struct part_type_s {
float offsetspreadvert;
float randomvelvert;
float randscale;
float s1, t1, s2, t2;
float texsstride; //addition for s for each random slot.
int randsmax; //max times the stride can be added
plooks_t *slooks; //shared looks, so state switches don't apply between particles so much
plooks_t looks;
float spawntime;
@ -276,6 +283,8 @@ trailstate_t *trailstates;
int ts_cycle; // current cyclic index of trailstates
int r_numtrailstates;
static qboolean r_plooksdirty; //a particle effect was changed, reevaluate shared looks.
extern cvar_t r_bouncysparks;
extern cvar_t r_part_rain;
extern cvar_t r_bloodstains;
@ -377,6 +386,8 @@ static part_type_t *P_GetParticleType(char *name)
ptype->ramp = NULL;
ptype->particles = NULL;
ptype->beams = NULL;
r_plooksdirty = true;
return ptype;
}
@ -471,10 +482,17 @@ static void P_LoadTexture(part_type_t *ptype, qboolean warn)
if (!ptype->looks.texturenum)
{
//note that this could get messy if you depend upon vid_restart to reload your effect without re-execing it after.
ptype->s1 = 0;
ptype->t1 = 0;
ptype->s2 = 1;
ptype->t2 = 1;
ptype->randsmax = 1;
if (warn)
Con_DPrintf("Couldn't load texture %s for particle effect %s\n", ptype->texname, ptype->name);
if (strstr(ptype->texname, "glow") || strstr(ptype->texname, "ball"))
if (strstr(ptype->texname, "glow") || strstr(ptype->texname, "ball") || ptype->looks.type == PT_TEXTUREDSPARK)
ptype->looks.texturenum = balltexture;
else
ptype->looks.texturenum = explosiontexture;
@ -610,6 +628,10 @@ static void P_ParticleEffect_f(void)
ptype->rotationstartrand = M_PI-ptype->rotationstartmin;
ptype->spawnchance = 1;
ptype->randsmax = 1;
ptype->s2 = 1;
ptype->t2 = 1;
while(1)
{
buf = Cbuf_GetNext(Cmd_ExecLevel);
@ -632,6 +654,25 @@ static void P_ParticleEffect_f(void)
// parse speed
if (!strcmp(var, "texture"))
Q_strncpyz(ptype->texname, value, sizeof(ptype->texname));
else if (!strcmp(var, "tcoords"))
{
float tscale;
tscale = atof(Cmd_Argv(5));
if (tscale < 0)
tscale = 1;
ptype->s1 = atof(value)/tscale;
ptype->t1 = atof(Cmd_Argv(2))/tscale;
ptype->s2 = atof(Cmd_Argv(3))/tscale;
ptype->t2 = atof(Cmd_Argv(4))/tscale;
ptype->randsmax = atoi(Cmd_Argv(6));
ptype->texsstride = atof(Cmd_Argv(7));
if (ptype->randsmax < 1 || ptype->texsstride == 0)
ptype->randsmax = 1;
}
else if (!strcmp(var, "rotationstart"))
{
ptype->rotationstartmin = atof(value)*M_PI/180;
@ -1123,6 +1164,8 @@ static void P_ParticleEffect_f(void)
}
P_LoadTexture(ptype, true);
r_plooksdirty = true;
}
//assosiate a point effect with a model.
@ -2148,6 +2191,16 @@ static int PScript_RunParticleEffectState (vec3_t org, vec3_t dir, float count,
p->rotationspeed = ptype->rotationmin + frandom()*ptype->rotationrand;
p->angle = ptype->rotationstartmin + frandom()*ptype->rotationstartrand;
p->s1 = ptype->s1;
p->t1 = ptype->t1;
p->s2 = ptype->s2;
p->t2 = ptype->t2;
if (ptype->randsmax!=1)
{
m = ptype->texsstride * (rand()%ptype->randsmax);
p->s1 += m;
p->s2 += m;
}
if (ptype->colorindex >= 0)
{
@ -2873,6 +2926,17 @@ static void P_ParticleTrailDraw (vec3_t startpos, vec3_t end, part_type_t *ptype
p->rotationspeed = ptype->rotationmin + frandom()*ptype->rotationrand;
p->angle = ptype->rotationstartmin + frandom()*ptype->rotationstartrand;
p->s1 = ptype->s1;
p->t1 = ptype->t1;
p->s2 = ptype->s2;
p->t2 = ptype->t2;
if (ptype->randsmax!=1)
{
float offs;
offs = ptype->texsstride * (rand()%ptype->randsmax);
p->s1 += offs;
p->s2 += offs;
}
if (len < nrfirst || len >= nrlast)
{
@ -3161,13 +3225,13 @@ static void GL_DrawTexturedParticle(int count, particle_t **plist, plooks_t *typ
x = 0;
y = scale;
}
qglTexCoord2f(0,0);
qglTexCoord2f(p->s1,p->t1);
qglVertex3f (p->org[0] - x*pright[0] - y*pup[0], p->org[1] - x*pright[1] - y*pup[1], p->org[2] - x*pright[2] - y*pup[2]);
qglTexCoord2f(0,1);
qglTexCoord2f(p->s1,p->t2);
qglVertex3f (p->org[0] - y*pright[0] + x*pup[0], p->org[1] - y*pright[1] + x*pup[1], p->org[2] - y*pright[2] + x*pup[2]);
qglTexCoord2f(1,1);
qglTexCoord2f(p->s2,p->t2);
qglVertex3f (p->org[0] + x*pright[0] + y*pup[0], p->org[1] + x*pright[1] + y*pup[1], p->org[2] + x*pright[2] + y*pup[2]);
qglTexCoord2f(1,0);
qglTexCoord2f(p->s2,p->t1);
qglVertex3f (p->org[0] + y*pright[0] - x*pup[0], p->org[1] + y*pright[1] - x*pup[1], p->org[2] + y*pright[2] - x*pup[2]);
}
qglEnd();
@ -3183,7 +3247,6 @@ static void GL_DrawSketchParticle(int count, particle_t **plist, plooks_t *type)
int quant;
qglDisable(GL_TEXTURE_2D);
GL_Bind(type->texturenum);
// if (type->blendmode == BM_ADD) //addative
// glBlendFunc(GL_SRC_ALPHA, GL_ONE);
// else if (type->blendmode == BM_SUBTRACT) //subtractive
@ -3282,7 +3345,6 @@ static void GL_DrawLineSparkParticle(int count, particle_t **plist, plooks_t *ty
particle_t *p;
qglDisable(GL_TEXTURE_2D);
GL_Bind(type->texturenum);
APPLYBLEND(type->blendmode);
qglShadeModel(GL_SMOOTH);
qglBegin(GL_LINES);
@ -3332,10 +3394,10 @@ static void GL_DrawTexturedSparkParticle(int count, particle_t **plist, plooks_t
VectorNormalize(cr);
VectorMA(p->org, -p->scale/2, cr, point);
qglTexCoord2f(0, 0);
qglTexCoord2f(p->s1, p->t1);
qglVertex3fv(point);
VectorMA(p->org, p->scale/2, cr, point);
qglTexCoord2f(0, 1);
qglTexCoord2f(p->s1, p->t2);
qglVertex3fv(point);
@ -3346,10 +3408,10 @@ static void GL_DrawTexturedSparkParticle(int count, particle_t **plist, plooks_t
VectorNormalize(cr);
VectorMA(o2, p->scale/2, cr, point);
qglTexCoord2f(1, 1);
qglTexCoord2f(p->s2, p->t2);
qglVertex3fv(point);
VectorMA(o2, -p->scale/2, cr, point);
qglTexCoord2f(1, 0);
qglTexCoord2f(p->s2, p->t1);
qglVertex3fv(point);
}
qglEnd();
@ -3360,7 +3422,6 @@ static void GL_DrawSketchSparkParticle(int count, particle_t **plist, plooks_t *
particle_t *p;
qglDisable(GL_TEXTURE_2D);
GL_Bind(type->texturenum);
APPLYBLEND(type->blendmode);
qglShadeModel(GL_SMOOTH);
qglBegin(GL_LINES);
@ -3424,10 +3485,10 @@ static void GL_DrawParticleBeam_Textured(int count, beamseg_t **blist, plooks_t
ts = c->texture_s*q->angle + particletime*q->rotationspeed;
VectorMA(q->org, -q->scale, cr, point);
qglTexCoord2f(ts, 0);
qglTexCoord2f(ts, p->t1);
qglVertex3fv(point);
VectorMA(q->org, q->scale, cr, point);
qglTexCoord2f(ts, 1);
qglTexCoord2f(ts, p->t2);
qglVertex3fv(point);
qglColor4f(p->rgb[0],
@ -3441,10 +3502,10 @@ static void GL_DrawParticleBeam_Textured(int count, beamseg_t **blist, plooks_t
ts = b->texture_s*p->angle + particletime*p->rotationspeed;
VectorMA(p->org, p->scale, cr, point);
qglTexCoord2f(ts, 1);
qglTexCoord2f(ts, p->t2);
qglVertex3fv(point);
VectorMA(p->org, -p->scale, cr, point);
qglTexCoord2f(ts, 0);
qglTexCoord2f(ts, p->t1);
qglVertex3fv(point);
}
qglEnd();
@ -3463,7 +3524,6 @@ static void GL_DrawParticleBeam_Untextured(int count, beamseg_t **blist, plooks_
qglDisable(GL_TEXTURE_2D);
GL_Bind(type->texturenum);
APPLYBLEND(type->blendmode);
qglShadeModel(GL_SMOOTH);
qglBegin(GL_QUADS);
@ -3731,6 +3791,25 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t
int traces=r_particle_tracelimit.value;
int rampind;
if (r_plooksdirty)
{
int i, j;
for (i = 0; i < numparticletypes; i++)
{
//set the fallback
part_type[i].slooks = &part_type[i].looks;
for (j = i-1; j-- > 0;)
{
if (!memcmp(&part_type[i].looks, &part_type[j].looks, sizeof(plooks_t)))
{
part_type[i].slooks = part_type[j].slooks;
break;
}
}
}
r_plooksdirty = false;
}
pframetime = host_frametime;
if (cl.paused || r_secondaryview)
pframetime = 0;
@ -3881,7 +3960,7 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t
while ((p=type->particles))
{
if (pdraw)
RQ_AddDistReorder(pdraw, p, &type->looks, p->org);
RQ_AddDistReorder(pdraw, p, type->slooks, p->org);
// make sure emitter runs at least once
if (type->emit >= 0 && type->emitstart <= 0)
@ -3935,7 +4014,7 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t
VectorAdd(stop, oldorg, stop);
VectorScale(stop, 0.5, stop);
RQ_AddDistReorder(bdraw, b, &type->looks, stop);
RQ_AddDistReorder(bdraw, b, type->slooks, stop);
}
}
@ -4144,7 +4223,7 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t
}
if (pdraw)
RQ_AddDistReorder((void*)pdraw, p, &type->looks, p->org);
RQ_AddDistReorder((void*)pdraw, p, type->slooks, p->org);
}
// beams are dealt with here
@ -4204,7 +4283,7 @@ void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t
VectorAdd(stop, oldorg, stop);
VectorScale(stop, 0.5, stop);
RQ_AddDistReorder(bdraw, b, &type->looks, stop);
RQ_AddDistReorder(bdraw, b, type->slooks, stop);
}
}

View File

@ -6,9 +6,27 @@ char *particle_set_spikeset =
// and some others I probably forgot to mention
/////////////////////////////////////////////////
//rocket trails (derived from purplehaze's, with only minor tweeks)
"r_part rocketsmoke\n"
"{\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"step 8\n"
"scale 7.5\n"
"alpha 0.8\n"
"die 2\n"
"randomvel 3\n"
"rgb 10 10 10\n"
"blend modulate\n"
"spawnmode spiral\n"
"scalefactor 1\n"
"spawnvel 5\n"
"}\n"
"r_part rockettrail\n"
"{\n"
"texture \"particles/smoke.tga\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"step 4\n"
"scale 30\n"
"alpha 0.3\n"
@ -20,11 +38,13 @@ char *particle_set_spikeset =
"gravity -25\n"
"scalefactor 1\n"
"assoc rocketsmoke\n"
"spawnvel 10\n"
"}\n"
"r_part t_rocket\n"
"{\n"
"texture \"particles/rfire\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"step 2\n"
"scale 10\n"
"alpha 0.6\n"
@ -37,24 +57,10 @@ char *particle_set_spikeset =
"scaledelta -10\n"
"}\n"
"r_part rocketsmoke\n"
"{\n"
"texture \"particles/rtrail\"\n"
"step 8\n"
"scale 7.5\n"
"alpha 0.8\n"
"die 2\n"
"randomvel 3\n"
"rgb 10 10 10\n"
"blend modulate\n"
"spawnmode spiral\n"
"scalefactor 1\n"
"spawnvel 10\n"
"}\n"
"r_part rockettail\n"
"{\n"
"texture \"particles/rtrail\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"step 7\n"
"scale 10\n"
"alpha 0.3\n"
@ -68,7 +74,8 @@ char *particle_set_spikeset =
"r_part t_altrocket\n"
"{\n"
"texture \"particles/rtrail\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"step 4\n"
"scale 10\n"
"alpha 0.3\n"
@ -163,7 +170,8 @@ char *particle_set_spikeset =
"r_part shortfume\n"
"{\n"
"texture \"particles/smoke\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"scale 15\n"
"scaledelta 20\n"
"alpha 0.5\n"
@ -176,7 +184,8 @@ char *particle_set_spikeset =
"r_part t_grenade\n"
"{\n"
"texture \"particles/smoke\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"step 24\n"
"scale 16\n"
"scaledelta 4\n"
@ -194,7 +203,8 @@ char *particle_set_spikeset =
//cool's blood trails (cos they're cooler)
"r_part t_gib\n"
"{\n"
"texture \"particles/blood\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 1 63 63 256 2 64\n"
"step 32\n"
"scale 64\n"
"alpha 0.6\n"
@ -212,7 +222,8 @@ char *particle_set_spikeset =
"r_part t_zomgib\n"
"{\n"
"texture \"particles/blood\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 1 63 63 256 2 64\n"
"step 64\n"
"scale 64\n"
"alpha 0.6\n"
@ -230,7 +241,8 @@ char *particle_set_spikeset =
"r_part t_tracer\n"
"{\n"
"texture \"particles/tracer\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
"scale 15\n"
"step 5\n"
"alpha 0.6\n"
@ -244,7 +256,8 @@ char *particle_set_spikeset =
"r_part t_tracer2\n"
"{\n"
"texture \"particles/tracer\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
"scale 15\n"
"step 5\n"
"alpha 0.6\n"
@ -258,7 +271,8 @@ char *particle_set_spikeset =
"r_part t_tracer3\n"
"{\n"
"texture \"particles/tracer\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
"scale 10\n"
"scaledelta -10\n"
"step 5\n"
@ -276,7 +290,8 @@ char *particle_set_spikeset =
//qw blood
"r_part te_lightningblood\n"
"{\n"
"texture \"particles/bloodtrail\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 193 97 255 159 256\n"
"count 3\n"
"scale 20\n"
"alpha 0.4\n"
@ -294,7 +309,8 @@ char *particle_set_spikeset =
//qw blood
"r_part te_blood\n"
"{\n"
"texture \"particles/blood\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 193 97 255 159 256\n"
"count 10\n"
"scale 10\n"
"alpha 0.3\n"
@ -311,7 +327,8 @@ char *particle_set_spikeset =
//nq blood
"r_part pe_73\n"
"{\n"
"texture \"particles/blood\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 193 97 255 159 256\n"
"count 1\n"
"scale 20\n"
"alpha 0.3\n"
@ -330,7 +347,8 @@ char *particle_set_spikeset =
"r_part ember\n"
"{\n"
"count 1\n"
"texture \"particles/explosion\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"rgb 255 128 76\n"
"alpha 0\n"
"scale 15\n"
@ -354,7 +372,8 @@ char *particle_set_spikeset =
"r_part expgib\n"
"{\n"
"cliptype expgib\n"
"texture \"particles/explosion\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"alpha 0\n"
"count 16\n"
"die 1\n"
@ -369,7 +388,8 @@ char *particle_set_spikeset =
//the heart of the explosion
"r_part te_explosion\n"
"{\n"
"texture \"particles/explosion\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"count 1\n"
"scale 200\n"
"scalefactor 1\n"
@ -383,7 +403,8 @@ char *particle_set_spikeset =
"r_part gunshotsmoke\n"
"{\n"
"texture \"particles/smoke\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 65 31 95 256 8 32\n"
"count 3\n"
"scale 25\n"
"scalefactor 1\n"
@ -400,7 +421,8 @@ char *particle_set_spikeset =
"r_part te_gunshot\n"
"{\n"
"type texturedspark\n"
"texture \"ball\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 65 31 95 256 8 32\n"
"count 3\n"
"scale 2\n"
"scalefactor 1\n"
@ -419,7 +441,8 @@ char *particle_set_spikeset =
"r_part spikecore\n"
"{\n"
"texture \"ball\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
"count 1\n"
"scale 1\n"
"scalefactor 1\n"
@ -449,7 +472,8 @@ char *particle_set_spikeset =
"r_part te_lavasplash\n"
"{\n"
"texture \"default\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 129 1 191 63 256\n"
"count 654\n"
"scale 15\n"
"alpha 0.7\n"
@ -468,7 +492,8 @@ char *particle_set_spikeset =
//two rings moving upwards, costs less
"r_part teleportsplashdown\n"
"{\n"
"texture \"textures/smoke\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 193 1 255 63 256\n"
"count 32\n"
"scale 32\n"
"scalefactor 1\n"
@ -482,7 +507,8 @@ char *particle_set_spikeset =
"}\n"
"r_part te_teleportsplash\n"
"{\n"
"texture \"textures/smoke\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 193 1 255 63 256\n"
"count 32\n"
"scale 32\n"
"scalefactor 1\n"
@ -499,7 +525,8 @@ char *particle_set_spikeset =
//flame effect
"r_part cu_flame\n"
"{\n"
"texture \"particles/flame\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 129 1 191 63 256\n"
"count 1024\n"
"scale 0.4\n"
"scalerand 6\n"
@ -518,7 +545,8 @@ char *particle_set_spikeset =
//flame effect
"r_part cu_torch\n"
"{\n"
"texture \"particles/flame\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 129 1 191 63 256\n"
"count 256\n"
"scale 3\n"
"scalefactor 1\n"
@ -535,7 +563,8 @@ char *particle_set_spikeset =
"r_part explodesprite\n"
"{\n"
"texture \"particles/flame\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 97 97 191 191 256\n"
"count 180\n"
"scale 70\n"
"scaledelta -140\n"
@ -554,7 +583,8 @@ char *particle_set_spikeset =
//you'll probably never see this one
"r_part ef_entityparticles\n"
"{\n"
"texture \"j\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
"count 1\n"
"scale 15\n"
"alpha 0.2\n"
@ -567,7 +597,8 @@ char *particle_set_spikeset =
// emp effect, based off of purplehaze's idea
"r_part empshocktrail\n"
"{\n"
"texture \"particles/spark\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 193 1 255 63 256\n"
"step 3.2\n"
"scale 3\n"
"alpha 0.7\n"
@ -580,7 +611,8 @@ char *particle_set_spikeset =
"r_part empcore\n"
"{\n"
"texture \"particles/flame\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 193 1 255 63 256\n"
"count 90\n"
"scale 55\n"
"scaledelta -110\n"
@ -599,7 +631,8 @@ char *particle_set_spikeset =
"r_part empflash\n"
"{\n"
"die 0.1\n"
"texture \"particles/flash\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 193 1 255 63 256\n"
"alpha 1\n"
"count 1\n"
"scale 400\n"
@ -613,7 +646,8 @@ char *particle_set_spikeset =
"r_part te_tarexplosion\n"
"{\n"
"texture \"particles/emp\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
"count 120\n"
"scale 35\n"
"die 0.75\n"
@ -636,7 +670,8 @@ char *particle_set_spikeset =
"r_part pe_default\n"
"{\n"
"texture \"particles/quake\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
"count 1\n"
"scale 4\n"
"veladd 15\n"
@ -649,7 +684,8 @@ char *particle_set_spikeset =
"r_part pe_defaulttrail\n"
"{\n"
"texture \"particles/quake\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
"step 12\n"
"die 1\n"
"scale 10\n"
@ -661,7 +697,8 @@ char *particle_set_spikeset =
"r_part pe_pointfile\n"
"{\n"
"texture \"particles/quake\"\n"
"texture \"particles/fteparticlefont.tga\"\n"
"tcoords 1 97 95 191 256\n"
"count 1\n"
"scale 50\n"
"die 30\n"
@ -676,6 +713,10 @@ char *particle_set_spikeset =
"r_effect \"progs/flame.mdl\" cu_torch\n"
"r_trail \"progs/e_spike1.mdl\" te_railtrail\n";
///////////////////////////////////////////////////////
char *particle_set_faithful =
// faithful, by TimeServ
"r_part t_gib\n"

View File

@ -354,7 +354,7 @@ cvar_t r_shadow_realtime_world_lightmaps = SCVARF ("r_shadow_realtime_world_ligh
CVAR_CHEAT);
cvar_t r_shadows = SCVARF ("r_shadows", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH);
cvar_t r_vertexdlights = SCVAR ("r_vertexdlights", "1");
cvar_t r_vertexdlights = SCVAR ("r_vertexdlights", "0");
cvar_t vid_preservegamma = SCVAR ("vid_preservegamma", "0");
cvar_t vid_hardwaregamma = SCVARF ("vid_hardwaregamma", "1",
@ -2601,8 +2601,8 @@ void R_MarkLeaves_Q1 (void)
else if (r_viewleaf2 && r_viewleaf2 != r_viewleaf)
{
int c;
Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf2, fatvis);
vis = Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf, NULL);
Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf2, fatvis, sizeof(fatvis));
vis = Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf, NULL, 0);
c = (cl.worldmodel->numleafs+31)/32;
for (i=0 ; i<c ; i++)
((int *)fatvis)[i] |= ((int *)vis)[i];
@ -2610,7 +2610,7 @@ void R_MarkLeaves_Q1 (void)
vis = fatvis;
}
else
vis = Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf, NULL);
vis = Q1BSP_LeafPVS (cl.worldmodel, r_viewleaf, NULL, 0);
for (i=0 ; i<cl.worldmodel->numleafs ; i++)
{

View File

@ -35,7 +35,7 @@ typedef struct fileblock_s {
} fileblock_t;
#define FB_BREAK 1
fileblock_t *cursorblock, *firstblock, *executionblock, *viewportystartblock;
static fileblock_t *cursorblock, *firstblock, *executionblock, *viewportystartblock;
void *E_Malloc(int size)
{

View File

@ -1,6 +1,5 @@
#include "quakedef.h"
qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer);
/*
============================================================================
@ -873,7 +872,7 @@ void SV_Q1BSP_AddToFatPVS (model_t *mod, vec3_t org, mnode_t *node, qbyte *buffe
{
if (node->contents != Q1CONTENTS_SOLID)
{
pvs = Q1BSP_LeafPVS (mod, (mleaf_t *)node, NULL);
pvs = Q1BSP_LeafPVS (mod, (mleaf_t *)node, NULL, 0);
for (i=0; i<buffersize; i++)
buffer[i] |= pvs[i];
}
@ -996,7 +995,7 @@ PVS type stuff
Mod_DecompressVis
===================
*/
qbyte *Q1BSP_DecompressVis (qbyte *in, model_t *model, qbyte *decompressed)
qbyte *Q1BSP_DecompressVis (qbyte *in, model_t *model, qbyte *decompressed, unsigned int buffersize)
{
int c;
qbyte *out;
@ -1005,6 +1004,9 @@ qbyte *Q1BSP_DecompressVis (qbyte *in, model_t *model, qbyte *decompressed)
row = (model->numleafs+7)>>3;
out = decompressed;
if (buffersize < row)
row = buffersize;
#if 0
memcpy (out, in, row);
#else
@ -1041,7 +1043,7 @@ qbyte *Q1BSP_DecompressVis (qbyte *in, model_t *model, qbyte *decompressed)
static qbyte mod_novis[MAX_MAP_LEAFS/8];
qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer)
qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer, unsigned int buffersize)
{
static qbyte decompressed[MAX_MAP_LEAFS/8];
@ -1050,14 +1052,17 @@ qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer)
return mod_novis;
if (!buffer)
{
buffer = decompressed;
buffersize = sizeof(decompressed);
}
return Q1BSP_DecompressVis (leaf->compressed_vis, model, buffer);
return Q1BSP_DecompressVis (leaf->compressed_vis, model, buffer, buffersize);
}
qbyte *Q1BSP_LeafnumPVS (model_t *model, int leafnum, qbyte *buffer)
qbyte *Q1BSP_LeafnumPVS (model_t *model, int leafnum, qbyte *buffer, unsigned int buffersize)
{
return Q1BSP_LeafPVS(model, model->leafs + leafnum, buffer);
return Q1BSP_LeafPVS(model, model->leafs + leafnum, buffer, buffersize);
}
//returns the leaf number, which is used as a bit index into the pvs.

File diff suppressed because it is too large Load Diff

View File

@ -212,6 +212,7 @@ typedef struct texture_s
vbo_t vbo;
struct msurface_s *texturechain; // for gl_texsort drawing
struct msurface_s **texturechain_tail; //so we can link them in depth order
int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence
@ -448,7 +449,7 @@ qboolean Q1BSP_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f,
unsigned int Q1BSP_FatPVS (struct model_s *mod, vec3_t org, qbyte *pvsbuffer, unsigned int buffersize, qboolean add);
qboolean Q1BSP_EdictInFatPVS(struct model_s *mod, struct edict_s *ent, qbyte *pvs);
void Q1BSP_FindTouchedLeafs(struct model_s *mod, struct edict_s *ent, float *mins, float *maxs);
qbyte *Q1BSP_LeafPVS (struct model_s *model, mleaf_t *leaf, qbyte *buffer);
qbyte *Q1BSP_LeafPVS (struct model_s *model, mleaf_t *leaf, qbyte *buffer, unsigned int buffersize);
/*
==============================================================================

View File

@ -379,6 +379,7 @@ static void PPL_BaseChain_NoBump_1TMU(msurface_t *first, texture_t *tex)
qglDisableClientState(GL_TEXTURE_COORD_ARRAY);
}*/
#if 0
static void PPL_BaseChain_NoBump_2TMU_Overbright(msurface_t *s, texture_t *tex)
{ //doesn't merge surfaces, but tells gl to do each vertex arrayed surface individually, which means no vertex copying.
int vi;
@ -489,19 +490,20 @@ static void PPL_BaseChain_NoBump_2TMU_Overbright(msurface_t *s, texture_t *tex)
if (tex->alphaed)
qglDisable(GL_ALPHA_TEST);
}
#endif
static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *tex)
static void PPL_BaseChain_NoBump_2TMU_Overbright(msurface_t *s, texture_t *tex, vbo_t *vbo)
{ //doesn't merge surfaces, but tells gl to do each vertex arrayed surface individually, which means no vertex copying.
int vi;
glRect_t *theRect;
// int first = 0, last = 0;
varrayactive = false;
qglDisableClientState(GL_COLOR_ARRAY);
qglEnableClientState(GL_VERTEX_ARRAY);
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, tex->vbo.vboe);
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vbo->vboe);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->vbo.vbocoord);
qglVertexPointer(3, GL_FLOAT, 0, tex->vbo.coord);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vbocoord);
qglVertexPointer(3, GL_FLOAT, 0, vbo->coord);
if (tex->alphaed || currententity->shaderRGBAf[3]<1)
{
@ -526,13 +528,13 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t
GL_MBind(GL_TEXTURE0_ARB, tex->tn.base);
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->vbo.vbotexcoord);
qglTexCoordPointer(2, GL_FLOAT, 0, tex->vbo.texcoord);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vbotexcoord);
qglTexCoordPointer(2, GL_FLOAT, 0, vbo->texcoord);
GL_SelectTexture(GL_TEXTURE1_ARB);
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, tex->vbo.vbolmcoord);
qglTexCoordPointer(2, GL_FLOAT, 0, tex->vbo.lmcoord);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vbolmcoord);
qglTexCoordPointer(2, GL_FLOAT, 0, vbo->lmcoord);
GL_TexEnv(GL_MODULATE);
@ -562,6 +564,10 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t
continue;
if (vi != s->lightmaptexturenum)
{
// if (last != first)
// qglDrawElements(GL_TRIANGLES, last - first, GL_INDEX_TYPE, (index_t*)(first*sizeof(index_t)));
// last = first;
if (vi<0)
qglEnable(GL_TEXTURE_2D);
vi = s->lightmaptexturenum;
@ -585,11 +591,22 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t
else
qglDisable(GL_TEXTURE_2D);
}
qglDrawRangeElements(GL_TRIANGLES, s->mesh->vbofirstvert, s->mesh->vbofirstvert+s->mesh->numvertexes-1, s->mesh->numindexes, GL_INDEX_TYPE, (index_t*)(s->mesh->vbofirstelement*sizeof(index_t)));
qglDrawRangeElements(GL_TRIANGLES, s->mesh->vbofirstvert, s->mesh->vbofirstvert+s->mesh->numvertexes-1, s->mesh->numindexes, GL_INDEX_TYPE, vbo->indicies + s->mesh->vbofirstelement);
// if (s->mesh->vbofirstelement != last)
// {
// if (last != first)
// qglDrawElements(GL_TRIANGLES, last - first, GL_INDEX_TYPE, (index_t*)(first*sizeof(index_t)));
// first = s->mesh->vbofirstelement;
// last = first;
// }
// last += s->mesh->numindexes;
}
// if (last != first)
// qglDrawElements(GL_TRIANGLES, last - first, GL_INDEX_TYPE, (index_t*)(first*sizeof(index_t)));
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
//rebinding vbos is meant to be cheap, thankfully
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
if (overbright != 1)
{
@ -605,6 +622,7 @@ static void PPL_BaseChain_VBO_NoBump_2TMU_Overbright(msurface_t *s, texture_t *t
qglDisableClientState(GL_TEXTURE_COORD_ARRAY);
qglDisable(GL_TEXTURE_2D);
if (tex->alphaed)
qglDisable(GL_ALPHA_TEST);
}
@ -1656,6 +1674,7 @@ static void PPL_BaseChain_NPR_Sketch(msurface_t *first)
static void PPL_BaseTextureChain(msurface_t *first)
{
texture_t *ot = first->texinfo->texture;
texture_t *t;
#ifdef Q3SHADERS
shader_t *shader;
@ -1681,7 +1700,7 @@ static void PPL_BaseTextureChain(msurface_t *first)
}
}
t = R_TextureAnimation (first->texinfo->texture);
t = R_TextureAnimation (ot);
#ifdef Q3SHADERS
shader = t->shader;
@ -1852,10 +1871,8 @@ static void PPL_BaseTextureChain(msurface_t *first)
{
// PPL_BaseChain_NoBump_2TMU_TEST(first, t);
// PPL_BaseChain_NoBump_2TMU(first, t);
if (t->vbo.vbocoord)
PPL_BaseChain_VBO_NoBump_2TMU_Overbright(first, t);
else
PPL_BaseChain_NoBump_2TMU_Overbright(first, t);
PPL_BaseChain_NoBump_2TMU_Overbright(first, t, &ot->vbo);
}
}
}
@ -1863,10 +1880,11 @@ static void PPL_BaseTextureChain(msurface_t *first)
static void PPL_FullBrightTextureChain(msurface_t *first)
{
texture_t *ot = first->texinfo->texture;
texture_t *t;
msurface_t *s;
t = R_TextureAnimation (first->texinfo->texture);
t = R_TextureAnimation (ot);
if (detailtexture && gl_detail.value)
{
@ -1890,14 +1908,23 @@ static void PPL_FullBrightTextureChain(msurface_t *first)
if (gl_mylumassuck.value)
qglEnable(GL_ALPHA_TEST);
PPL_EnableVertexArrays();
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ot->vbo.vboe);
qglEnableClientState(GL_VERTEX_ARRAY);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, ot->vbo.vbocoord);
qglVertexPointer(3, GL_FLOAT, 0, ot->vbo.coord);
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
qglTexCoordPointer(2, GL_FLOAT, sizeof(surfvertexarray_t), varray_v->stw);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, ot->vbo.vbotexcoord);
qglTexCoordPointer(2, GL_FLOAT, 0, ot->vbo.texcoord);
for (s = first; s ; s=s->texturechain)
{
PPL_GenerateArrays(s);
qglDrawRangeElements(GL_TRIANGLES, s->mesh->vbofirstvert, s->mesh->vbofirstvert+s->mesh->numvertexes-1, s->mesh->numindexes, GL_INDEX_TYPE, ot->vbo.indicies + s->mesh->vbofirstelement);
}
PPL_FlushArrays();
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
if (gl_mylumassuck.value)
qglDisable(GL_ALPHA_TEST);
@ -3355,8 +3382,6 @@ void PPL_FullBrights(model_t *model)
continue; // draw translucent water later
PPL_FullBrightTextureChain(s);
t->texturechain=NULL;
}
GL_TexEnv(GL_REPLACE);
@ -3411,7 +3436,7 @@ void PPL_DrawEntFullBrights(void)
int i;
currententity = &r_worldentity;
// if (gl_detail.value || (r_fb_bmodels.value && cls.allow_luma))
if (gl_detail.value || (r_fb_bmodels.value && cls.allow_luma))
PPL_FullBrights(cl.worldmodel);
if (!r_drawentities.value)
@ -3450,6 +3475,8 @@ void PPL_DrawEntFullBrights(void)
case mod_brush:
PPL_FullBrightBModelTextures (currententity);
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
break;
default:

View File

@ -2336,8 +2336,9 @@ start:
}
else
*/ {
surf->texturechain = surf->texinfo->texture->texturechain;
surf->texinfo->texture->texturechain = surf;
*surf->texinfo->texture->texturechain_tail = surf;
surf->texinfo->texture->texturechain_tail = &surf->texturechain;
surf->texturechain = NULL;
}
}
}
@ -2528,6 +2529,17 @@ static void GLR_LeafWorldNode (void)
}
#endif
static void GLR_ClearChains(void)
{
int i;
for (i = 0; i < cl.worldmodel->numtextures; i++)
{
if (!cl.worldmodel->textures[i])
continue;
cl.worldmodel->textures[i]->texturechain = NULL;
cl.worldmodel->textures[i]->texturechain_tail = &cl.worldmodel->textures[i]->texturechain;
}
}
/*
=============
R_DrawWorld
@ -2552,6 +2564,7 @@ void R_DrawWorld (void)
else
#endif
{
GLR_ClearChains();
qglColor3f (1,1,1);
//#ifdef QUAKE2
R_ClearSkyBox ();
@ -2612,8 +2625,6 @@ qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
}
qbyte *Q1BSP_LeafPVS (model_t *model, mleaf_t *leaf, qbyte *buffer);
/*
@ -2847,7 +2858,7 @@ void GL_BuildSurfaceDisplayList (msurface_t *fa)
VectorNegate(fa->plane->normal, mesh->normals_array[i]);
else
VectorCopy(fa->plane->normal, mesh->normals_array[i]);
VectorCopy(fa->texinfo->vecs[0], mesh->snormals_array[i]);
VectorNegate(fa->texinfo->vecs[0], mesh->snormals_array[i]);
VectorCopy(fa->texinfo->vecs[1], mesh->tnormals_array[i]);
mesh->colors_array[i][0] = 255;
@ -2957,7 +2968,7 @@ qboolean GL_BuildVBO(vbo_t *vbo, void *vdata, int vsize, void *edata, int elemen
{
unsigned int vbos[2];
// if (!qglGenBuffersARB)
if (!qglGenBuffersARB)
return false;
qglGenBuffersARB(2, vbos);