static int Mod_Q1BSP_PointSuperContents(struct model_s *model, int frame, const vec3_t point)
{
- int num = 0;
+ int num = model->brushq1.hulls[0].firstclipnode;
mplane_t *plane;
mclipnode_t *nodes = model->brushq1.hulls[0].clipnodes;
mplane_t *planes = model->brushq1.hulls[0].planes;
if (name[j] >= 'A' && name[j] <= 'Z')
name[j] += 'a' - 'A';
- if (dmiptex->name[0] && Mod_LoadTextureFromQ3Shader(loadmodel->data_textures + i, name, true, false, false))
+ if (dmiptex->name[0] && Mod_LoadTextureFromQ3Shader(loadmodel->data_textures + i, name, false, false, 0))
continue;
tx = loadmodel->data_textures + i;
i = LittleLong(((int *)data)[1]);
if (i == 1)
{
- Con_DPrintf("loaded %s\n", litfilename);
+ if (developer_loading.integer)
+ Con_Printf("loaded %s\n", litfilename);
loadmodel->brushq1.lightdata = (unsigned char *)Mem_Alloc(loadmodel->mempool, filesize - 8);
memcpy(loadmodel->brushq1.lightdata, data + 8, filesize - 8);
Mem_Free(data);
i = LittleLong(((int *)data)[1]);
if (i == 1)
{
- Con_DPrintf("loaded %s\n", dlitfilename);
+ if (developer_loading.integer)
+ Con_Printf("loaded %s\n", dlitfilename);
loadmodel->brushq1.nmaplightdata = (unsigned char *)Mem_Alloc(loadmodel->mempool, filesize - 8);
memcpy(loadmodel->brushq1.nmaplightdata, data + 8, filesize - 8);
loadmodel->brushq3.deluxemapping_modelspace = false;
static void init_alloc_lm_state (struct alloc_lm_state* state)
{
int r;
-
+
state->currentY = 0;
for (r = 0; r < MAX_SINGLE_LM_SIZE; r++)
{
{
int i, iu, iv, lightmapx, lightmapy;
float u, v, ubase, vbase, uscale, vscale;
-
+
smax = surface->lightmapinfo->extents[0] >> 4;
tmax = surface->lightmapinfo->extents[1] >> 4;
ssize = (surface->lightmapinfo->extents[0] >> 4) + 1;
tsize = (surface->lightmapinfo->extents[1] >> 4) + 1;
-
- // stainmap for permanent marks on walls
- surface->lightmapinfo->stainsamples = (unsigned char *)Mem_Alloc(loadmodel->mempool, ssize * tsize * 3);
- // clear to white
- memset(surface->lightmapinfo->stainsamples, 255, ssize * tsize * 3);
if (!lightmaptexture || !Mod_Q1BSP_AllocLightmapBlock(&allocState, lightmapsize, lightmapsize, ssize, tsize, &lightmapx, &lightmapy))
{
}
}
+
+ if (cl_stainmaps.integer)
+ {
+ // allocate stainmaps for permanent marks on walls
+ int stainmapsize = 0;
+ unsigned char *stainsamples = NULL;
+ for (surfacenum = 0, surface = loadmodel->data_surfaces;surfacenum < count;surfacenum++, surface++)
+ {
+ ssize = (surface->lightmapinfo->extents[0] >> 4) + 1;
+ tsize = (surface->lightmapinfo->extents[1] >> 4) + 1;
+ stainmapsize += ssize * tsize * 3;
+ }
+ // allocate and clear to white
+ stainsamples = (unsigned char *)Mem_Alloc(loadmodel->mempool, stainmapsize);
+ memset(stainsamples, 255, stainmapsize);
+ // assign pointers
+ for (surfacenum = 0, surface = loadmodel->data_surfaces;surfacenum < count;surfacenum++, surface++)
+ {
+ ssize = (surface->lightmapinfo->extents[0] >> 4) + 1;
+ tsize = (surface->lightmapinfo->extents[1] >> 4) + 1;
+ surface->lightmapinfo->stainsamples = stainsamples;
+ stainsamples += ssize * tsize * 3;
+ }
+ }
}
+
+ // generate ushort elements array if possible
+ if (loadmodel->surfmesh.data_element3s)
+ for (i = 0;i < loadmodel->surfmesh.num_triangles*3;i++)
+ loadmodel->surfmesh.data_element3s[i] = loadmodel->surfmesh.data_element3i[i];
}
static void Mod_Q1BSP_LoadNodes_RecursiveSetParent(mnode_t *node, mnode_t *parent)
int i, j;
mleaf_t *leaf;
const unsigned char *pvs;
+ // if there's no vis data, assume supported (because everything is visible all the time)
+ if (!loadmodel->brush.data_pvsclusters)
+ return true;
// check all liquid leafs to see if they can see into empty leafs, if any
// can we can assume this map supports r_wateralpha
for (i = 0, leaf = loadmodel->brush.data_leafs;i < loadmodel->brush.num_leafs;i++, leaf++)
{
- if ((leaf->contents == CONTENTS_WATER || leaf->contents == CONTENTS_SLIME) && (leaf->clusterindex >= 0 && loadmodel->brush.data_pvsclusters))
+ if ((leaf->contents == CONTENTS_WATER || leaf->contents == CONTENTS_SLIME) && leaf->clusterindex >= 0)
{
pvs = loadmodel->brush.data_pvsclusters + leaf->clusterindex * loadmodel->brush.num_pvsclusterbytes;
for (j = 0;j < loadmodel->brush.num_leafs;j++)
mod->brush.LightPoint = NULL;
mod->brush.AmbientSoundLevelsForPoint = NULL;
}
+ // copy the submodel bounds, then enlarge the yaw and rotated bounds according to radius
+ VectorCopy(bm->mins, mod->normalmins);
+ VectorCopy(bm->maxs, mod->normalmaxs);
+ VectorCopy(bm->mins, mod->yawmins);
+ VectorCopy(bm->maxs, mod->yawmaxs);
+ VectorCopy(bm->mins, mod->rotatedmins);
+ VectorCopy(bm->maxs, mod->rotatedmaxs);
if (mod->nummodelsurfaces)
{
- // LordHavoc: calculate bmodel bounding box rather than trusting what it says
- mod->normalmins[0] = mod->normalmins[1] = mod->normalmins[2] = 1000000000.0f;
- mod->normalmaxs[0] = mod->normalmaxs[1] = mod->normalmaxs[2] = -1000000000.0f;
modelyawradius = 0;
modelradius = 0;
for (j = 0, surface = &mod->data_surfaces[mod->firstmodelsurface];j < mod->nummodelsurfaces;j++, surface++)
// calculate bounding shapes
for (k = 0, vec = (loadmodel->surfmesh.data_vertex3f + 3 * surface->num_firstvertex);k < surface->num_vertices;k++, vec += 3)
{
- if (mod->normalmins[0] > vec[0]) mod->normalmins[0] = vec[0];
- if (mod->normalmins[1] > vec[1]) mod->normalmins[1] = vec[1];
- if (mod->normalmins[2] > vec[2]) mod->normalmins[2] = vec[2];
- if (mod->normalmaxs[0] < vec[0]) mod->normalmaxs[0] = vec[0];
- if (mod->normalmaxs[1] < vec[1]) mod->normalmaxs[1] = vec[1];
- if (mod->normalmaxs[2] < vec[2]) mod->normalmaxs[2] = vec[2];
dist = vec[0]*vec[0]+vec[1]*vec[1];
if (modelyawradius < dist)
modelyawradius = dist;
}
modelyawradius = sqrt(modelyawradius);
modelradius = sqrt(modelradius);
- mod->yawmins[0] = mod->yawmins[1] = - (mod->yawmaxs[0] = mod->yawmaxs[1] = modelyawradius);
- mod->yawmins[2] = mod->normalmins[2];
- mod->yawmaxs[2] = mod->normalmaxs[2];
- mod->rotatedmins[0] = mod->rotatedmins[1] = mod->rotatedmins[2] = -modelradius;
- mod->rotatedmaxs[0] = mod->rotatedmaxs[1] = mod->rotatedmaxs[2] = modelradius;
+ mod->yawmins[0] = min(mod->yawmins[0], -modelyawradius);
+ mod->yawmaxs[0] = min(mod->yawmaxs[0], -modelyawradius);
+ mod->yawmins[1] = min(mod->yawmins[1], modelyawradius);
+ mod->yawmaxs[1] = min(mod->yawmaxs[1], modelyawradius);
+ mod->rotatedmins[0] = min(mod->rotatedmins[0], -modelradius);
+ mod->rotatedmaxs[0] = min(mod->rotatedmaxs[0], modelradius);
+ mod->rotatedmins[1] = min(mod->rotatedmins[1], -modelradius);
+ mod->rotatedmaxs[1] = min(mod->rotatedmaxs[1], modelradius);
+ mod->rotatedmins[2] = min(mod->rotatedmins[2], -modelradius);
+ mod->rotatedmaxs[2] = min(mod->rotatedmaxs[2], modelradius);
mod->radius = modelradius;
mod->radius2 = modelradius * modelradius;
{
q3dtexture_t *in;
texture_t *out;
- int i, count, c;
+ int i, count;
in = (q3dtexture_t *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
if (cls.state == ca_dedicated)
return;
- c = 0;
for (i = 0;i < count;i++, in++, out++)
- if (!Mod_LoadTextureFromQ3Shader(out, out->name, false, true, false))
- c++;
- if (c)
- Con_DPrintf("%s: %i textures missing shaders\n", loadmodel->name, c);
+ Mod_LoadTextureFromQ3Shader(out, out->name, true, true, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | (r_picmipworld.integer ? TEXF_PICMIP : 0) | TEXF_COMPRESS);
}
static void Mod_Q3BSP_LoadPlanes(lump_t *l)
;
for (mergeheight = 1;mergewidth*mergeheight < j && mergeheight < (1 << power);mergeheight *= 2)
;
- Con_DPrintf("lightmap merge texture #%i is %ix%i (%i of %i used)\n", lightmapindex, mergewidth*128, mergeheight*128, min(j, mergewidth*mergeheight), mergewidth*mergeheight);
+ if (developer_loading.integer)
+ Con_Printf("lightmap merge texture #%i is %ix%i (%i of %i used)\n", lightmapindex, mergewidth*128, mergeheight*128, min(j, mergewidth*mergeheight), mergewidth*mergeheight);
loadmodel->brushq3.data_lightmaps[lightmapindex] = R_LoadTexture2D(loadmodel->texturepool, va("lightmap%04i", lightmapindex), mergewidth * 128, mergeheight * 128, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_PRECACHE | (gl_texturecompression_q3bsplightmaps.integer ? TEXF_COMPRESS : 0), NULL);
if (loadmodel->brushq3.data_deluxemaps)
loadmodel->brushq3.data_deluxemaps[lightmapindex] = R_LoadTexture2D(loadmodel->texturepool, va("deluxemap%04i", lightmapindex), mergewidth * 128, mergeheight * 128, NULL, TEXTYPE_BGRA, TEXF_FORCELINEAR | TEXF_PRECACHE | (gl_texturecompression_q3bspdeluxemaps.integer ? TEXF_COMPRESS : 0), NULL);
{
// check face type first
type = LittleLong(in->type);
- if (type != Q3FACETYPE_POLYGON
+ if (type != Q3FACETYPE_FLAT
&& type != Q3FACETYPE_PATCH
&& type != Q3FACETYPE_MESH
&& type != Q3FACETYPE_FLARE)
}
switch(type)
{
- case Q3FACETYPE_POLYGON:
+ case Q3FACETYPE_FLAT:
case Q3FACETYPE_MESH:
// no processing necessary
break;
out->num_firsttriangle = meshtriangles;
switch(type)
{
- case Q3FACETYPE_POLYGON:
+ case Q3FACETYPE_FLAT:
case Q3FACETYPE_MESH:
// no processing necessary, except for lightmap merging
for (j = 0;j < out->num_vertices;j++)
// for per pixel lighting
Mod_BuildTextureVectorsFromNormals(0, loadmodel->surfmesh.num_vertices, loadmodel->surfmesh.num_triangles, loadmodel->surfmesh.data_vertex3f, loadmodel->surfmesh.data_texcoordtexture2f, loadmodel->surfmesh.data_normal3f, loadmodel->surfmesh.data_element3i, loadmodel->surfmesh.data_svector3f, loadmodel->surfmesh.data_tvector3f, true);
+ // generate ushort elements array if possible
+ if (loadmodel->surfmesh.data_element3s)
+ for (i = 0;i < loadmodel->surfmesh.num_triangles*3;i++)
+ loadmodel->surfmesh.data_element3s[i] = loadmodel->surfmesh.data_element3i[i];
+
// free the no longer needed vertex data
loadmodel->brushq3.num_vertices = 0;
if (loadmodel->brushq3.data_vertex3f)
VectorCopy(mod->brushq3.data_models[i].mins, mod->normalmins);
VectorCopy(mod->brushq3.data_models[i].maxs, mod->normalmaxs);
+ // enlarge the bounding box to enclose all geometry of this model,
+ // because q3map2 sometimes lies (mostly to affect the lightgrid),
+ // which can in turn mess up the farclip (as well as culling when
+ // outside the level - an unimportant concern)
+
+ //printf("Editing model %d... BEFORE re-bounding: %f %f %f - %f %f %f\n", i, mod->normalmins[0], mod->normalmins[1], mod->normalmins[2], mod->normalmaxs[0], mod->normalmaxs[1], mod->normalmaxs[2]);
+ for (j = 0;j < mod->nummodelsurfaces;j++)
+ {
+ const msurface_t *surface = mod->data_surfaces + j + mod->firstmodelsurface;
+ const float *v = mod->surfmesh.data_vertex3f + 3 * surface->num_firstvertex;
+ int k;
+ if (!surface->num_vertices)
+ continue;
+ for (k = 0;k < surface->num_vertices;k++, v += 3)
+ {
+ mod->normalmins[0] = min(mod->normalmins[0], v[0]);
+ mod->normalmins[1] = min(mod->normalmins[1], v[1]);
+ mod->normalmins[2] = min(mod->normalmins[2], v[2]);
+ mod->normalmaxs[0] = max(mod->normalmaxs[0], v[0]);
+ mod->normalmaxs[1] = max(mod->normalmaxs[1], v[1]);
+ mod->normalmaxs[2] = max(mod->normalmaxs[2], v[2]);
+ }
+ }
+ //printf("Editing model %d... AFTER re-bounding: %f %f %f - %f %f %f\n", i, mod->normalmins[0], mod->normalmins[1], mod->normalmins[2], mod->normalmaxs[0], mod->normalmaxs[1], mod->normalmaxs[2]);
corner[0] = max(fabs(mod->normalmins[0]), fabs(mod->normalmaxs[0]));
corner[1] = max(fabs(mod->normalmins[1]), fabs(mod->normalmaxs[1]));
corner[2] = max(fabs(mod->normalmins[2]), fabs(mod->normalmaxs[2]));