// FIELDS UPDATED BY RENDERER:
// last time visible during trace culling
double last_trace_visibility;
+
+ // user wavefunc parameters (from csqc)
+ float userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
}
entity_render_t;
return false;
}
+ if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.userwavefunc_param0))) entrender->userwavefunc_param[0] = val->_float;
+ if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.userwavefunc_param1))) entrender->userwavefunc_param[1] = val->_float;
+ if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.userwavefunc_param2))) entrender->userwavefunc_param[2] = val->_float;
+ if((val = PRVM_EDICTFIELDVALUE(ed, prog->fieldoffsets.userwavefunc_param3))) entrender->userwavefunc_param[3] = val->_float;
+
entrender->model = model;
entrender->skinnum = (int)ed->fields.client->skin;
entrender->effects |= entrender->model->effects;
layer->color[3] = a;
}
+static qboolean R_TestQ3WaveFunc(q3wavefunc_t func, const float *parms)
+{
+ if(parms[0] == 0 && parms[1] == 0)
+ return false;
+ if(func >> Q3WAVEFUNC_USER_SHIFT) // assumes rsurface to be set!
+ if(rsurface.userwavefunc_param[bound(0, (func >> Q3WAVEFUNC_USER_SHIFT) - 1, Q3WAVEFUNC_USER_COUNT)] == 0);
+ return false;
+ return true;
+}
+
static float R_EvaluateQ3WaveFunc(q3wavefunc_t func, const float *parms)
{
double index, f;
index = parms[2] + r_refdef.scene.time * parms[3];
index -= floor(index);
- switch (func)
+ switch (func & ((1 << Q3WAVEFUNC_USER_SHIFT) - 1))
{
default:
case Q3WAVEFUNC_NONE:
f = -(1 - f);
break;
}
- return (float)(parms[0] + parms[1] * f);
+ f = parms[0] + parms[1] * f;
+ if(func >> Q3WAVEFUNC_USER_SHIFT) // assumes rsurface to be set!
+ f *= rsurface.userwavefunc_param[bound(0, (func >> Q3WAVEFUNC_USER_SHIFT) - 1, Q3WAVEFUNC_USER_COUNT)];
+ return (float) f;
}
void R_tcMod_ApplyToMatrix(matrix4x4_t *texmatrix, q3shaderinfo_layer_tcmod_t *tcmod, int currentmaterialflags)
// return;
rsurface.entity = r_refdef.scene.worldentity;
rsurface.skeleton = NULL;
+ memset(rsurface.userwavefunc_param, 0, sizeof(rsurface.userwavefunc_param));
rsurface.ent_skinnum = 0;
rsurface.ent_qwskin = -1;
rsurface.ent_shadertime = 0;
// return;
rsurface.entity = (entity_render_t *)ent;
rsurface.skeleton = ent->skeleton;
+ memcpy(rsurface.userwavefunc_param, ent->userwavefunc_param, sizeof(rsurface.userwavefunc_param));
rsurface.ent_skinnum = ent->skinnum;
rsurface.ent_qwskin = (ent->entitynumber <= cl.maxclients && ent->entitynumber >= 1 && cls.protocol == PROTOCOL_QUAKEWORLD && cl.scores[ent->entitynumber - 1].qw_skin[0] && !strcmp(ent->model->name, "progs/player.mdl")) ? (ent->entitynumber - 1) : -1;
rsurface.ent_shadertime = ent->shadertime;
waveparms[1] = deform->waveparms[1];
waveparms[2] = deform->waveparms[2];
waveparms[3] = deform->waveparms[3];
+ if(!R_TestQ3WaveFunc(deform->wavefunc, waveparms))
+ break; // if wavefunc is a nop, don't make a dynamic vertex array
// this is how a divisor of vertex influence on deformation
animpos = deform->parms[0] ? 1.0f / deform->parms[0] : 100.0f;
scale = R_EvaluateQ3WaveFunc(deform->wavefunc, waveparms);
break;
case Q3DEFORM_MOVE:
// deform vertex array
+ if(!R_TestQ3WaveFunc(deform->wavefunc, deform->waveparms))
+ break; // if wavefunc is a nop, don't make a dynamic vertex array
scale = R_EvaluateQ3WaveFunc(deform->wavefunc, deform->waveparms);
VectorScale(deform->parms, scale, waveparms);
for (j = 0;j < rsurface.batchnumvertices;j++)
}
#endif
-q3wavefunc_t Mod_LoadQ3Shaders_EnumerateWaveFunc(const char *s)
+int Mod_LoadQ3Shaders_EnumerateWaveFunc(const char *s)
{
- if (!strcasecmp(s, "sin")) return Q3WAVEFUNC_SIN;
- if (!strcasecmp(s, "square")) return Q3WAVEFUNC_SQUARE;
- if (!strcasecmp(s, "triangle")) return Q3WAVEFUNC_TRIANGLE;
- if (!strcasecmp(s, "sawtooth")) return Q3WAVEFUNC_SAWTOOTH;
- if (!strcasecmp(s, "inversesawtooth")) return Q3WAVEFUNC_INVERSESAWTOOTH;
- if (!strcasecmp(s, "noise")) return Q3WAVEFUNC_NOISE;
+ int offset = 0;
+ if (!strncasecmp(s, "user", 4)) // parse stuff like "user1sin", always user<n>func
+ {
+ offset = bound(0, s[4] - '0', 9);
+ offset = (offset + 1) << Q3WAVEFUNC_USER_SHIFT;
+ s += 4;
+ if(*s)
+ ++s;
+ }
+ if (!strcasecmp(s, "sin")) return offset | Q3WAVEFUNC_SIN;
+ if (!strcasecmp(s, "square")) return offset | Q3WAVEFUNC_SQUARE;
+ if (!strcasecmp(s, "triangle")) return offset | Q3WAVEFUNC_TRIANGLE;
+ if (!strcasecmp(s, "sawtooth")) return offset | Q3WAVEFUNC_SAWTOOTH;
+ if (!strcasecmp(s, "inversesawtooth")) return offset | Q3WAVEFUNC_INVERSESAWTOOTH;
+ if (!strcasecmp(s, "noise")) return offset | Q3WAVEFUNC_NOISE;
+ if (!strcasecmp(s, "none")) return offset | Q3WAVEFUNC_NONE;
Con_DPrintf("Mod_LoadQ3Shaders: unknown wavefunc %s\n", s);
- return Q3WAVEFUNC_NONE;
+ return offset | Q3WAVEFUNC_NONE;
}
void Mod_FreeQ3Shaders(void)
Q3WAVEFUNC_TRIANGLE,
Q3WAVEFUNC_COUNT
}
-q3wavefunc_t;
+q3wavefunc_e;
+typedef int q3wavefunc_t;
+#define Q3WAVEFUNC_USER_COUNT 4
+#define Q3WAVEFUNC_USER_SHIFT 8 // use 8 bits for wave func type
typedef enum q3deform_e
{
int movedir; // ssqc / csqc (physics)
int camera_transform; // csqc (warpzones)
+
+ int userwavefunc_param0; // csqc (userwavefunc)
+ int userwavefunc_param1; // csqc (userwavefunc)
+ int userwavefunc_param2; // csqc (userwavefunc)
+ int userwavefunc_param3; // csqc (userwavefunc)
}
prvm_prog_fieldoffsets_t;
prog->fieldoffsets.movedir = PRVM_ED_FindFieldOffset("movedir");
prog->fieldoffsets.camera_transform = PRVM_ED_FindFieldOffset("camera_transform");
+ prog->fieldoffsets.userwavefunc_param0 = PRVM_ED_FindFieldOffset("userwavefunc_param0");
+ prog->fieldoffsets.userwavefunc_param1 = PRVM_ED_FindFieldOffset("userwavefunc_param1");
+ prog->fieldoffsets.userwavefunc_param2 = PRVM_ED_FindFieldOffset("userwavefunc_param2");
+ prog->fieldoffsets.userwavefunc_param3 = PRVM_ED_FindFieldOffset("userwavefunc_param3");
prog->funcoffsets.CSQC_ConsoleCommand = PRVM_ED_FindFunctionOffset("CSQC_ConsoleCommand");
prog->funcoffsets.CSQC_Ent_Remove = PRVM_ED_FindFunctionOffset("CSQC_Ent_Remove");
// this transforms only the Z to S, and T is always 0.5
matrix4x4_t entitytoattenuationz;
+ // user wavefunc parameters (from csqc)
+ float userwavefunc_param[Q3WAVEFUNC_USER_COUNT];
+
// pointer to an entity_render_t used only by R_GetCurrentTexture and
// RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity as a unique id within
// each frame (see r_frame also)