void Mod_RenderInit(void)
{
- R_RegisterModule("Models", mod_start, mod_shutdown, mod_newmap);
+ R_RegisterModule("Models", mod_start, mod_shutdown, mod_newmap, NULL, NULL);
}
void Mod_UnloadModel (dp_model_t *mod)
edgehashentry_t *edgehashentries, *hash;
if (!numtriangles)
return;
- edgehash = Mem_Alloc(tempmempool, TRIANGLEEDGEHASH * sizeof(*edgehash));
+ edgehash = (edgehashentry_t **)Mem_Alloc(tempmempool, TRIANGLEEDGEHASH * sizeof(*edgehash));
// if there are too many triangles for the stack array, allocate larger buffer
edgehashentries = (edgehashentry_t *)Mem_Alloc(tempmempool, numtriangles * 3 * sizeof(edgehashentry_t));
// find neighboring triangles
}
#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)
memcpy (&entry->shader, shader, sizeof (q3shaderinfo_t));
}
-extern cvar_t r_picmipworld;
extern cvar_t mod_q3shader_default_offsetmapping;
void Mod_LoadQ3Shaders(void)
{
q3shaderinfo_layer_t *layer;
int numparameters;
char parameter[TEXTURE_MAXFRAMES + 4][Q3PATHLENGTH];
+ char *custsurfaceparmnames[256]; // VorteX: q3map2 has 64 but well, someone will need more
+ unsigned long custsurfaceparms[256];
+ int numcustsurfaceparms;
Mod_FreeQ3Shaders();
Mem_ExpandableArray_NewArray (&q3shader_data->char_ptrs,
q3shaders_mem, sizeof (char**), 256);
+ // parse custinfoparms.txt
+ numcustsurfaceparms = 0;
+ if ((text = f = (char *)FS_LoadFile("scripts/custinfoparms.txt", tempmempool, false, NULL)) != NULL)
+ {
+ if (!COM_ParseToken_QuakeC(&text, false) || strcasecmp(com_token, "{"))
+ Con_DPrintf("scripts/custinfoparms.txt: contentflags section parsing error - expected \"{\", found \"%s\"\n", com_token);
+ else
+ {
+ while (COM_ParseToken_QuakeC(&text, false))
+ if (!strcasecmp(com_token, "}"))
+ break;
+ // custom surfaceflags section
+ if (!COM_ParseToken_QuakeC(&text, false) || strcasecmp(com_token, "{"))
+ Con_DPrintf("scripts/custinfoparms.txt: surfaceflags section parsing error - expected \"{\", found \"%s\"\n", com_token);
+ else
+ {
+ while(COM_ParseToken_QuakeC(&text, false))
+ {
+ if (!strcasecmp(com_token, "}"))
+ break;
+ // register surfaceflag
+ if (numcustsurfaceparms >= 256)
+ {
+ Con_Printf("scripts/custinfoparms.txt: surfaceflags section parsing error - max 256 surfaceflags exceeded\n");
+ break;
+ }
+ // name
+ j = strlen(com_token)+1;
+ custsurfaceparmnames[numcustsurfaceparms] = (char *)Mem_Alloc(tempmempool, j);
+ strlcpy(custsurfaceparmnames[numcustsurfaceparms], com_token, j+1);
+ // value
+ if (COM_ParseToken_QuakeC(&text, false))
+ custsurfaceparms[numcustsurfaceparms] = strtol(com_token, NULL, 0);
+ else
+ custsurfaceparms[numcustsurfaceparms] = 0;
+ numcustsurfaceparms++;
+ }
+ }
+ }
+ Mem_Free(f);
+ }
+
+ // parse shaders
search = FS_Search("scripts/*.shader", true, false);
if (!search)
return;
else if (!strcasecmp(parameter[1], "antiportal"))
shader.surfaceparms |= Q3SURFACEPARM_ANTIPORTAL;
else
- Con_DPrintf("%s parsing warning: unknown surfaceparm \"%s\"\n", search->filenames[fileindex], parameter[1]);
+ {
+ // try custom surfaceparms
+ for (j = 0; j < numcustsurfaceparms; j++)
+ {
+ if (!strcasecmp(custsurfaceparmnames[j], parameter[1]))
+ {
+ shader.surfaceparms |= custsurfaceparms[j];
+ break;
+ }
+ }
+ // failed all
+ if (j == numcustsurfaceparms)
+ Con_DPrintf("%s parsing warning: unknown surfaceparm \"%s\"\n", search->filenames[fileindex], parameter[1]);
+ }
}
else if (!strcasecmp(parameter[0], "dpshadow"))
shader.dpshadow = true;
Mem_Free(f);
}
FS_FreeSearch(search);
+ // free custinfoparm values
+ for (j = 0; j < numcustsurfaceparms; j++)
+ Mem_Free(custsurfaceparmnames[j]);
}
q3shaderinfo_t *Mod_LookupQ3Shader(const char *name)
state->width = width;
state->height = height;
state->currentY = 0;
- state->rows = Mem_Alloc(loadmodel->mempool, state->height * sizeof(*state->rows));
+ state->rows = (mod_alloclightmap_row_t *)Mem_Alloc(loadmodel->mempool, state->height * sizeof(*state->rows));
for (y = 0;y < state->height;y++)
{
state->rows[y].currentX = 0;
VectorSet(mins, lightinfo->origin[0] - lightinfo->radius, lightinfo->origin[1] - lightinfo->radius, lightinfo->origin[2] - lightinfo->radius);
VectorSet(maxs, lightinfo->origin[0] + lightinfo->radius, lightinfo->origin[1] + lightinfo->radius, lightinfo->origin[2] + lightinfo->radius);
VectorCopy(lightinfo->origin, origin);
- nodes = Mem_Alloc(tempmempool, maxnodes * sizeof(*nodes));
+ nodes = (svbsp_node_t *)Mem_Alloc(tempmempool, maxnodes * sizeof(*nodes));
for (;;)
{
SVBSP_Init(&svbsp, origin, maxnodes, nodes);
Mod_GenerateLightmaps_CreateLights_ComputeSVBSP_InsertSurfaces(model, &svbsp, mins, maxs);
if (svbsp.ranoutofnodes)
{
- maxnodes *= 2;
- if (maxnodes >= 1<<22)
+ maxnodes *= 16;
+ if (maxnodes > 1<<22)
{
Mem_Free(nodes);
return;
}
Mem_Free(nodes);
- nodes = Mem_Alloc(tempmempool, maxnodes * sizeof(*nodes));
+ nodes = (svbsp_node_t *)Mem_Alloc(tempmempool, maxnodes * sizeof(*nodes));
}
else
break;
}
if (svbsp.numnodes > 0)
{
- svbsp.nodes = Mem_Alloc(tempmempool, svbsp.numnodes * sizeof(*nodes));
+ svbsp.nodes = (svbsp_node_t *)Mem_Alloc(tempmempool, svbsp.numnodes * sizeof(*nodes));
memcpy(svbsp.nodes, nodes, svbsp.numnodes * sizeof(*nodes));
lightinfo->svbsp = svbsp;
}
}
if (mod_generatelightmaps_numlights > 0)
{
- mod_generatelightmaps_lightinfo = Mem_Alloc(tempmempool, mod_generatelightmaps_numlights * sizeof(*mod_generatelightmaps_lightinfo));
+ mod_generatelightmaps_lightinfo = (lightmaplight_t *)Mem_Alloc(tempmempool, mod_generatelightmaps_numlights * sizeof(*mod_generatelightmaps_lightinfo));
lightinfo = mod_generatelightmaps_lightinfo;
for (index = 0;;index++)
{
const int *e;
lightmaptriangle_t *triangle;
// generate lightmap triangle structs
- mod_generatelightmaps_lightmaptriangles = Mem_Alloc(model->mempool, model->surfmesh.num_triangles * sizeof(lightmaptriangle_t));
+ mod_generatelightmaps_lightmaptriangles = (lightmaptriangle_t *)Mem_Alloc(model->mempool, model->surfmesh.num_triangles * sizeof(lightmaptriangle_t));
for (surfaceindex = 0;surfaceindex < model->num_surfaces;surfaceindex++)
{
surface = model->data_surfaces + surfaceindex;
model->brushq3.deluxemapping_modelspace = true;
model->brushq3.deluxemapping = true;
model->brushq3.num_mergedlightmaps = lightmapnumber;
- model->brushq3.data_lightmaps = Mem_Alloc(model->mempool, model->brushq3.num_mergedlightmaps * sizeof(rtexture_t *));
- model->brushq3.data_deluxemaps = Mem_Alloc(model->mempool, model->brushq3.num_mergedlightmaps * sizeof(rtexture_t *));
- lightmappixels = Mem_Alloc(tempmempool, model->brushq3.num_mergedlightmaps * lm_texturesize * lm_texturesize * 4);
- deluxemappixels = Mem_Alloc(tempmempool, model->brushq3.num_mergedlightmaps * lm_texturesize * lm_texturesize * 4);
+ model->brushq3.data_lightmaps = (rtexture_t **)Mem_Alloc(model->mempool, model->brushq3.num_mergedlightmaps * sizeof(rtexture_t *));
+ model->brushq3.data_deluxemaps = (rtexture_t **)Mem_Alloc(model->mempool, model->brushq3.num_mergedlightmaps * sizeof(rtexture_t *));
+ lightmappixels = (unsigned char *)Mem_Alloc(tempmempool, model->brushq3.num_mergedlightmaps * lm_texturesize * lm_texturesize * 4);
+ deluxemappixels = (unsigned char *)Mem_Alloc(tempmempool, model->brushq3.num_mergedlightmaps * lm_texturesize * lm_texturesize * 4);
for (surfaceindex = 0;surfaceindex < model->num_surfaces;surfaceindex++)
{
surface = model->data_surfaces + surfaceindex;
for (lightmapindex = 0;lightmapindex < model->brushq3.num_mergedlightmaps;lightmapindex++)
{
- model->brushq3.data_lightmaps[lightmapindex] = R_LoadTexture2D(model->texturepool, va("lightmap%i", lightmapindex), lm_texturesize, lm_texturesize, lightmappixels + lightmapindex * lm_texturesize * lm_texturesize * 4, TEXTYPE_BGRA, TEXF_FORCELINEAR, NULL);
- model->brushq3.data_deluxemaps[lightmapindex] = R_LoadTexture2D(model->texturepool, va("deluxemap%i", lightmapindex), lm_texturesize, lm_texturesize, deluxemappixels + lightmapindex * lm_texturesize * lm_texturesize * 4, TEXTYPE_BGRA, TEXF_FORCELINEAR, NULL);
+ model->brushq3.data_lightmaps[lightmapindex] = R_LoadTexture2D(model->texturepool, va("lightmap%i", lightmapindex), lm_texturesize, lm_texturesize, lightmappixels + lightmapindex * lm_texturesize * lm_texturesize * 4, TEXTYPE_BGRA, TEXF_FORCELINEAR, -1, NULL);
+ model->brushq3.data_deluxemaps[lightmapindex] = R_LoadTexture2D(model->texturepool, va("deluxemap%i", lightmapindex), lm_texturesize, lm_texturesize, deluxemappixels + lightmapindex * lm_texturesize * lm_texturesize * 4, TEXTYPE_BGRA, TEXF_FORCELINEAR, -1, NULL);
}
if (lightmappixels)