VectorClear(forward);
VectorClear(right);
VectorSet(up, 0, 0, 1);
- for (j = 0;j < surface->mesh.num_vertices - 3;j += 4)
+ for (j = 0;j < surface->num_vertices - 3;j += 4)
{
VectorClear(center);
for (i = 0;i < 4;i++)
- VectorAdd(center, surface->mesh.data_vertex3f + (j+i) * 3, center);
+ VectorAdd(center, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + (j+i) * 3, center);
VectorScale(center, 0.25f, center);
// FIXME: calculate vectors from triangle edges instead of using texture vectors as an easy way out?
- Matrix4x4_FromVectors(&matrix1, surface->mesh.data_normal3f + j*3, surface->mesh.data_svector3f + j*3, surface->mesh.data_tvector3f + j*3, center);
+ Matrix4x4_FromVectors(&matrix1, (surface->groupmesh->data_normal3f + 3 * surface->num_firstvertex) + j*3, (surface->groupmesh->data_svector3f + 3 * surface->num_firstvertex) + j*3, (surface->groupmesh->data_tvector3f + 3 * surface->num_firstvertex) + j*3, center);
Matrix4x4_Invert_Simple(&imatrix1, &matrix1);
for (i = 0;i < 4;i++)
- Matrix4x4_Transform(&imatrix1, surface->mesh.data_vertex3f + (j+i)*3, v[i]);
+ Matrix4x4_Transform(&imatrix1, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + (j+i)*3, v[i]);
forward[0] = modelorg[0] - center[0];
forward[1] = modelorg[1] - center[1];
VectorNormalize(forward);
Matrix4x4_Transform(&ent->inversematrix, r_viewright, right);
Matrix4x4_Transform(&ent->inversematrix, r_viewup, up);
// a single autosprite surface can contain multiple sprites...
- for (j = 0;j < surface->mesh.num_vertices - 3;j += 4)
+ for (j = 0;j < surface->num_vertices - 3;j += 4)
{
VectorClear(center);
for (i = 0;i < 4;i++)
- VectorAdd(center, surface->mesh.data_vertex3f + (j+i) * 3, center);
+ VectorAdd(center, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + (j+i) * 3, center);
VectorScale(center, 0.25f, center);
// FIXME: calculate vectors from triangle edges instead of using texture vectors as an easy way out?
- Matrix4x4_FromVectors(&matrix1, surface->mesh.data_normal3f + j*3, surface->mesh.data_svector3f + j*3, surface->mesh.data_tvector3f + j*3, center);
+ Matrix4x4_FromVectors(&matrix1, (surface->groupmesh->data_normal3f + 3 * surface->num_firstvertex) + j*3, (surface->groupmesh->data_svector3f + 3 * surface->num_firstvertex) + j*3, (surface->groupmesh->data_tvector3f + 3 * surface->num_firstvertex) + j*3, center);
Matrix4x4_Invert_Simple(&imatrix1, &matrix1);
for (i = 0;i < 4;i++)
- Matrix4x4_Transform(&imatrix1, surface->mesh.data_vertex3f + (j+i)*3, v[i]);
+ Matrix4x4_Transform(&imatrix1, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + (j+i)*3, v[i]);
for (i = 0;i < 4;i++)
VectorMAMAMAM(1, center, v[i][0], forward, v[i][1], right, v[i][2], up, varray_vertex3f + (i+j) * 3);
}
}
else
- memcpy(varray_vertex3f, surface->mesh.data_vertex3f, sizeof(float[3]) * surface->mesh.num_vertices);
+ memcpy(varray_vertex3f, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), sizeof(float[3]) * surface->num_vertices);
}
// any sort of deformvertices call is *VERY* rare, so this must be optimized
// to skip deformvertices quickly!
#if 1
-#define RSurf_GetVertexPointer(ent, texture, surface, modelorg) ((texture->textureflags & (Q3TEXTUREFLAG_AUTOSPRITE | Q3TEXTUREFLAG_AUTOSPRITE2)) ? (RSurf_DeformVertices(ent, texture, surface, modelorg), varray_vertex3f) : surface->mesh.data_vertex3f)
+#define RSurf_GetVertexPointer(ent, texture, surface, modelorg) ((texture->textureflags & (Q3TEXTUREFLAG_AUTOSPRITE | Q3TEXTUREFLAG_AUTOSPRITE2)) ? (RSurf_DeformVertices(ent, texture, surface, modelorg), varray_vertex3f) : (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex))
#else
static float *RSurf_GetVertexPointer(const entity_render_t *ent, const texture_t *texture, const msurface_t *surface, const vec3_t modelorg)
{
return varray_vertex3f;
}
else
- return surface->mesh.data_vertex3f;
+ return (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex);
}
#endif
{
surface = texturesurfacelist[texturesurfaceindex];
R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture));
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordlightmap2f);
- R_Mesh_ColorPointer(surface->lightmaptexture ? NULL : surface->mesh.data_lightmapcolor4f);
- R_Mesh_VertexPointer(surface->mesh.data_vertex3f);
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex));
+ R_Mesh_ColorPointer(surface->lightmaptexture ? NULL : (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex));
+ R_Mesh_VertexPointer((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex));
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
qglEnable(GL_CULL_FACE);
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
surface = texturesurfacelist[texturesurfaceindex];
- R_Mesh_VertexPointer(surface->mesh.data_vertex3f);
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ R_Mesh_VertexPointer((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex));
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
{
surface = texturesurfacelist[texturesurfaceindex];
R_Mesh_VertexPointer(RSurf_GetVertexPointer(ent, texture, surface, modelorg));
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
- R_Mesh_TexCoordPointer(1, 2, surface->mesh.data_texcoordtexture2f);
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
+ R_Mesh_TexCoordPointer(1, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
surface = texturesurfacelist[texturesurfaceindex];
vertex3f = RSurf_GetVertexPointer(ent, texture, surface, modelorg);
R_Mesh_VertexPointer(vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordlightmap2f);
- R_Mesh_TexCoordPointer(1, 2, surface->mesh.data_texcoordtexture2f);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex));
+ R_Mesh_TexCoordPointer(1, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
if (surface->lightmaptexture)
{
R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture));
if (fogallpasses)
{
R_Mesh_ColorPointer(varray_color4f);
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
VectorSubtract(v, modelorg, diff);
f = 1 - exp(fogdensity/DotProduct(diff, diff));
{
R_Mesh_TexBind(0, R_GetTexture(r_texture_white));
R_Mesh_ColorPointer(varray_color4f);
- if (surface->mesh.data_lightmapcolor4f)
+ if ((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex))
{
- for (i = 0, c = varray_color4f;i < surface->mesh.num_vertices;i++, c += 4)
+ for (i = 0, c = varray_color4f;i < surface->num_vertices;i++, c += 4)
{
- c[0] = surface->mesh.data_lightmapcolor4f[i*4+0] * r;
- c[1] = surface->mesh.data_lightmapcolor4f[i*4+1] * g;
- c[2] = surface->mesh.data_lightmapcolor4f[i*4+2] * b;
- c[3] = surface->mesh.data_lightmapcolor4f[i*4+3] * a;
+ c[0] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+0] * r;
+ c[1] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+1] * g;
+ c[2] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+2] * b;
+ c[3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3] * a;
}
if (fogallpasses)
{
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
VectorSubtract(v, modelorg, diff);
f = 1 - exp(fogdensity/DotProduct(diff, diff));
GL_Color(0, 0, 0, a);
}
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
surface = texturesurfacelist[texturesurfaceindex];
vertex3f = RSurf_GetVertexPointer(ent, texture, surface, modelorg);
R_Mesh_VertexPointer(vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
c[0] = 0;
c[1] = 0;
c[2] = 0;
- if (surface->mesh.data_lightmapcolor4f)
- VectorCopy(surface->mesh.data_lightmapcolor4f + i*4, c);
+ if ((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex))
+ VectorCopy((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex) + i*4, c);
else if (surface->lightmapinfo)
{
- const qbyte *lm = surface->lightmapinfo->samples + surface->mesh.data_lightmapoffsets[i];
+ const qbyte *lm = surface->lightmapinfo->samples + (surface->groupmesh->data_lightmapoffsets + surface->num_firstvertex)[i];
float scale = d_lightstylevalue[surface->lightmapinfo->styles[0]] * (1.0f / 32768.0f);
VectorMA(c, scale, lm, c);
if (surface->lightmapinfo->styles[1] != 255)
f = 1 - exp(fogdensity/DotProduct(diff, diff));
VectorScale(c, f, c);
}
- if (surface->mesh.data_lightmapcolor4f && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
- c[3] = surface->mesh.data_lightmapcolor4f[i*4+3] * a;
+ if ((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex) && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
+ c[3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3] * a;
else
c[3] = a;
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
surface = texturesurfacelist[texturesurfaceindex];
vertex3f = RSurf_GetVertexPointer(ent, texture, surface, modelorg);
R_Mesh_VertexPointer(vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
- if (surface->mesh.data_lightmapcolor4f && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
+ if ((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex) && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
{
R_Mesh_ColorPointer(varray_color4f);
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
VectorSubtract(v, modelorg, diff);
f = 1 - exp(fogdensity/DotProduct(diff, diff));
c[0] = r * f;
c[1] = g * f;
c[2] = b * f;
- c[3] = surface->mesh.data_lightmapcolor4f[i*4+3] * a;
+ c[3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3] * a;
}
}
else
{
R_Mesh_ColorPointer(varray_color4f);
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
VectorSubtract(v, modelorg, diff);
f = 1 - exp(fogdensity/DotProduct(diff, diff));
c[3] = a;
}
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
surface = texturesurfacelist[texturesurfaceindex];
vertex3f = RSurf_GetVertexPointer(ent, texture, surface, modelorg);
R_Mesh_VertexPointer(vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
- if (surface->mesh.data_lightmapcolor4f && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
+ if ((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex) && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
{
R_Mesh_ColorPointer(varray_color4f);
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
c[0] = r;
c[1] = g;
c[2] = b;
- c[3] = surface->mesh.data_lightmapcolor4f[i*4+3] * a;
+ c[3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3] * a;
}
}
else
R_Mesh_ColorPointer(NULL);
GL_Color(r, g, b, a);
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
{
surface = texturesurfacelist[texturesurfaceindex];
R_Mesh_VertexPointer(RSurf_GetVertexPointer(ent, texture, surface, modelorg));
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
{
surface = texturesurfacelist[texturesurfaceindex];
R_Mesh_VertexPointer(RSurf_GetVertexPointer(ent, texture, surface, modelorg));
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
{
surface = texturesurfacelist[texturesurfaceindex];
RSurf_DeformVertices(ent, texture, surface, modelorg);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordlightmap2f);
- R_Mesh_TexCoordPointer(1, 2, surface->mesh.data_texcoordtexture2f);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex));
+ R_Mesh_TexCoordPointer(1, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
if (surface->lightmaptexture)
{
R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture));
else //if (r == 1 && g == 1 && b == 1)
{
R_Mesh_TexBind(0, R_GetTexture(r_texture_white));
- R_Mesh_ColorPointer(surface->mesh.data_lightmapcolor4f);
+ R_Mesh_ColorPointer((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex));
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
{
surface = texturesurfacelist[texturesurfaceindex];
RSurf_DeformVertices(ent, texture, surface, modelorg);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordlightmap2f);
- R_Mesh_TexCoordPointer(1, 2, surface->mesh.data_texcoordtexture2f);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex));
+ R_Mesh_TexCoordPointer(1, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
if (surface->lightmaptexture)
{
R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture));
{
R_Mesh_TexBind(0, R_GetTexture(r_texture_white));
R_Mesh_ColorPointer(varray_color4f);
- for (i = 0;i < surface->mesh.num_vertices;i++)
+ for (i = 0;i < surface->num_vertices;i++)
{
- varray_color4f[i*4+0] = surface->mesh.data_lightmapcolor4f[i*4+0] * r;
- varray_color4f[i*4+1] = surface->mesh.data_lightmapcolor4f[i*4+1] * g;
- varray_color4f[i*4+2] = surface->mesh.data_lightmapcolor4f[i*4+2] * b;
- varray_color4f[i*4+3] = surface->mesh.data_lightmapcolor4f[i*4+3];
+ varray_color4f[i*4+0] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+0] * r;
+ varray_color4f[i*4+1] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+1] * g;
+ varray_color4f[i*4+2] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+2] * b;
+ varray_color4f[i*4+3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3];
}
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
surface = texturesurfacelist[texturesurfaceindex];
- qglVertexPointer(3, GL_FLOAT, sizeof(float[3]), surface->mesh.data_vertex3f);
+ qglVertexPointer(3, GL_FLOAT, sizeof(float[3]), (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex));
qglClientActiveTexture(GL_TEXTURE0_ARB);
- qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), surface->mesh.data_texcoordlightmap2f);
+ qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex));
qglClientActiveTexture(GL_TEXTURE1_ARB);
- qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), surface->mesh.data_texcoordtexture2f);
+ qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
if (surface->lightmaptexture)
{
R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture));
{
R_Mesh_TexBind(0, R_GetTexture(r_texture_white));
qglEnableClientState(GL_COLOR_ARRAY);
- qglColorPointer(4, GL_FLOAT, sizeof(float[4]), surface->mesh.data_lightmapcolor4f);
+ qglColorPointer(4, GL_FLOAT, sizeof(float[4]), (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex));
}
- qglLockArraysEXT(0, surface->mesh.num_vertices);
- qglDrawRangeElements(GL_TRIANGLES, 0, surface->mesh.num_vertices, surface->mesh.num_triangles * 3, GL_UNSIGNED_INT, surface->mesh.data_element3i);
+ qglLockArraysEXT(0, surface->num_vertices);
+ qglDrawRangeElements(GL_TRIANGLES, 0, surface->num_vertices, surface->num_triangles * 3, GL_UNSIGNED_INT, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
qglUnlockArraysEXT();
}
#else
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
surface = texturesurfacelist[texturesurfaceindex];
- R_Mesh_VertexPointer(surface->mesh.data_vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordlightmap2f);
- R_Mesh_TexCoordPointer(1, 2, surface->mesh.data_texcoordtexture2f);
+ R_Mesh_VertexPointer((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex));
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex));
+ R_Mesh_TexCoordPointer(1, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
if (surface->lightmaptexture)
{
R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture));
else //if (r == 1 && g == 1 && b == 1)
{
R_Mesh_TexBind(0, R_GetTexture(r_texture_white));
- R_Mesh_ColorPointer(surface->mesh.data_lightmapcolor4f);
+ R_Mesh_ColorPointer((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex));
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
#endif
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
surface = texturesurfacelist[texturesurfaceindex];
- R_Mesh_VertexPointer(surface->mesh.data_vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordlightmap2f);
- R_Mesh_TexCoordPointer(1, 2, surface->mesh.data_texcoordtexture2f);
+ R_Mesh_VertexPointer((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex));
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex));
+ R_Mesh_TexCoordPointer(1, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
if (surface->lightmaptexture)
{
R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture));
{
R_Mesh_TexBind(0, R_GetTexture(r_texture_white));
R_Mesh_ColorPointer(varray_color4f);
- for (i = 0;i < surface->mesh.num_vertices;i++)
+ for (i = 0;i < surface->num_vertices;i++)
{
- varray_color4f[i*4+0] = surface->mesh.data_lightmapcolor4f[i*4+0] * r;
- varray_color4f[i*4+1] = surface->mesh.data_lightmapcolor4f[i*4+1] * g;
- varray_color4f[i*4+2] = surface->mesh.data_lightmapcolor4f[i*4+2] * b;
- varray_color4f[i*4+3] = surface->mesh.data_lightmapcolor4f[i*4+3];
+ varray_color4f[i*4+0] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+0] * r;
+ varray_color4f[i*4+1] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+1] * g;
+ varray_color4f[i*4+2] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+2] * b;
+ varray_color4f[i*4+3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3];
}
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
surface = texturesurfacelist[texturesurfaceindex];
R_Mesh_VertexPointer(RSurf_GetVertexPointer(ent, texture, surface, modelorg));
R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture));
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordlightmap2f);
- R_Mesh_ColorPointer(surface->lightmaptexture ? NULL : surface->mesh.data_lightmapcolor4f);
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex));
+ R_Mesh_ColorPointer(surface->lightmaptexture ? NULL : (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex));
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
{
surface = texturesurfacelist[texturesurfaceindex];
R_Mesh_VertexPointer(RSurf_GetVertexPointer(ent, texture, surface, modelorg));
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
surface = texturesurfacelist[texturesurfaceindex];
vertex3f = RSurf_GetVertexPointer(ent, texture, surface, modelorg);
R_Mesh_VertexPointer(vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
c[0] = r;
c[1] = g;
f = 1 - exp(fogdensity/DotProduct(diff, diff));
VectorScale(c, f, c);
}
- if (surface->mesh.data_lightmapcolor4f && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
- c[3] = surface->mesh.data_lightmapcolor4f[i*4+3] * a;
+ if ((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex) && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
+ c[3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3] * a;
else
c[3] = a;
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
{
surface = texturesurfacelist[texturesurfaceindex];
R_Mesh_VertexPointer(RSurf_GetVertexPointer(ent, texture, surface, modelorg));
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoorddetail2f);
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoorddetail2f + 2 * surface->num_firstvertex));
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
surface = texturesurfacelist[texturesurfaceindex];
vertex3f = RSurf_GetVertexPointer(ent, texture, surface, modelorg);
R_Mesh_VertexPointer(vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
R_Mesh_ColorPointer(varray_color4f);
- if (surface->mesh.data_lightmapcolor4f && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
+ if ((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex) && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
{
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
VectorSubtract(v, modelorg, diff);
f = 1 - exp(fogdensity/DotProduct(diff, diff));
c[0] = f * r;
c[1] = f * g;
c[2] = f * b;
- c[3] = surface->mesh.data_lightmapcolor4f[i*4+3] * a;
+ c[3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3] * a;
}
}
else
{
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
VectorSubtract(v, modelorg, diff);
f = 1 - exp(fogdensity/DotProduct(diff, diff));
c[3] = a;
}
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
surface = texturesurfacelist[texturesurfaceindex];
vertex3f = RSurf_GetVertexPointer(ent, texture, surface, modelorg);
R_Mesh_VertexPointer(vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
- if (surface->mesh.data_lightmapcolor4f && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
+ if ((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex) && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
{
R_Mesh_ColorPointer(varray_color4f);
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
c[0] = r;
c[1] = g;
c[2] = b;
- c[3] = surface->mesh.data_lightmapcolor4f[i*4+3] * a;
+ c[3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3] * a;
}
}
else
R_Mesh_ColorPointer(NULL);
GL_Color(r, g, b, a);
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
surface = texturesurfacelist[texturesurfaceindex];
vertex3f = RSurf_GetVertexPointer(ent, texture, surface, modelorg);
R_Mesh_VertexPointer(vertex3f);
- R_Mesh_TexCoordPointer(0, 2, surface->mesh.data_texcoordtexture2f);
+ R_Mesh_TexCoordPointer(0, 2, (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex));
R_Mesh_ColorPointer(varray_color4f);
- //RSurf_FogPassColors_Vertex3f_Color4f(surface->mesh.data_vertex3f, varray_color4f, fogcolor[0], fogcolor[1], fogcolor[2], texture->currentalpha, 1, surface->mesh.num_vertices, modelorg);
- if (surface->mesh.data_lightmapcolor4f && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
+ //RSurf_FogPassColors_Vertex3f_Color4f((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), varray_color4f, fogcolor[0], fogcolor[1], fogcolor[2], texture->currentalpha, 1, surface->num_vertices, modelorg);
+ if ((surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex) && (texture->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
{
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
VectorSubtract(v, modelorg, diff);
f = exp(fogdensity/DotProduct(diff, diff));
c[0] = r;
c[1] = g;
c[2] = b;
- c[3] = surface->mesh.data_lightmapcolor4f[i*4+3] * f * a;
+ c[3] = (surface->groupmesh->data_lightmapcolor4f + 4 * surface->num_firstvertex)[i*4+3] * f * a;
}
}
else
{
- for (i = 0, v = vertex3f, c = varray_color4f;i < surface->mesh.num_vertices;i++, v += 3, c += 4)
+ for (i = 0, v = vertex3f, c = varray_color4f;i < surface->num_vertices;i++, v += 3, c += 4)
{
VectorSubtract(v, modelorg, diff);
f = exp(fogdensity/DotProduct(diff, diff));
c[3] = f * a;
}
}
- GL_LockArrays(0, surface->mesh.num_vertices);
- R_Mesh_Draw(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ GL_LockArrays(0, surface->num_vertices);
+ R_Mesh_Draw(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
GL_LockArrays(0, 0);
}
}
f = t->currentmaterialflags & flagsmask;
texture = t->currentframe;
}
- if (f && surface->mesh.num_triangles)
+ if (f && surface->num_triangles)
{
// if lightmap parameters changed, rebuild lightmap texture
if (surface->cached_dlight && surface->lightmapinfo->samples)
f = t->currentmaterialflags & flagsmask;
texture = t->currentframe;
}
- if (f && surface->mesh.num_triangles)
+ if (f && surface->num_triangles)
{
// if lightmap parameters changed, rebuild lightmap texture
if (surface->cached_dlight && surface->lightmapinfo->samples)
if (BoxesOverlap(lightmins, lightmaxs, surface->mins, surface->maxs))
if ((surface->texture->currentmaterialflags & (MATERIALFLAG_WALL | MATERIALFLAG_NODRAW | MATERIALFLAG_TRANSPARENT)) == MATERIALFLAG_WALL)
{
- for (triangleindex = 0, t = surface->num_firstshadowmeshtriangle, e = model->brush.shadowmesh->element3i + t * 3;triangleindex < surface->mesh.num_triangles;triangleindex++, t++, e += 3)
+ for (triangleindex = 0, t = surface->num_firstshadowmeshtriangle, e = model->brush.shadowmesh->element3i + t * 3;triangleindex < surface->num_triangles;triangleindex++, t++, e += 3)
{
v[0] = model->brush.shadowmesh->vertex3f + e[0] * 3;
v[1] = model->brush.shadowmesh->vertex3f + e[1] * 3;
continue;
if (surface->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
continue;
- R_Shadow_MarkVolumeFromBox(surface->num_firstshadowmeshtriangle, surface->mesh.num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, relativelightorigin, lightmins, lightmaxs, surface->mins, surface->maxs);
+ R_Shadow_MarkVolumeFromBox(surface->num_firstshadowmeshtriangle, surface->num_triangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, relativelightorigin, lightmins, lightmaxs, surface->mins, surface->maxs);
}
R_Shadow_VolumeFromList(model->brush.shadowmesh->numverts, model->brush.shadowmesh->numtriangles, model->brush.shadowmesh->vertex3f, model->brush.shadowmesh->element3i, model->brush.shadowmesh->neighbor3i, relativelightorigin, lightradius + model->radius + r_shadow_projectdistance.value, numshadowmark, shadowmarklist);
}
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
surface = model->brush.data_surfaces + surfacelist[surfacelistindex];
- if (surface->texture->basematerialflags & MATERIALFLAG_NODRAW || !surface->mesh.num_triangles)
+ if (surface->texture->basematerialflags & MATERIALFLAG_NODRAW || !surface->num_triangles)
continue;
if (r_shadow_compilingrtlight)
{
// if compiling an rtlight, capture the mesh
t = surface->texture;
if ((t->basematerialflags & (MATERIALFLAG_WALL | MATERIALFLAG_TRANSPARENT)) == MATERIALFLAG_WALL)
- Mod_ShadowMesh_AddMesh(r_shadow_mempool, r_shadow_compilingrtlight->static_meshchain_light, surface->texture->skin.base, surface->texture->skin.gloss, surface->texture->skin.nmap, surface->mesh.data_vertex3f, surface->mesh.data_svector3f, surface->mesh.data_tvector3f, surface->mesh.data_normal3f, surface->mesh.data_texcoordtexture2f, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ Mod_ShadowMesh_AddMesh(r_shadow_mempool, r_shadow_compilingrtlight->static_meshchain_light, surface->texture->skin.base, surface->texture->skin.gloss, surface->texture->skin.nmap, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_svector3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_tvector3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_normal3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex), surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
}
else if (ent != r_refdef.worldentity || r_worldsurfacevisible[surfacelist[surfacelistindex]])
{
{
if (surface->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
qglDisable(GL_CULL_FACE);
- R_Shadow_RenderLighting(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_element3i, surface->mesh.data_vertex3f, surface->mesh.data_svector3f, surface->mesh.data_tvector3f, surface->mesh.data_normal3f, surface->mesh.data_texcoordtexture2f, relativelightorigin, relativeeyeorigin, lightcolor, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, t->skin.base, t->skin.nmap, t->skin.gloss, lightcubemap, ambientscale, diffusescale, specularscale);
+ R_Shadow_RenderLighting(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_svector3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_tvector3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_normal3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex), relativelightorigin, relativeeyeorigin, lightcolor, matrix_modeltolight, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, t->skin.base, t->skin.nmap, t->skin.gloss, lightcubemap, ambientscale, diffusescale, specularscale);
if (surface->texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
qglEnable(GL_CULL_FACE);
}
surface = info->model->brush.data_surfaces + *mark;
if (surface->texture->supercontents & SUPERCONTENTS_SOLID)
{
- for (k = 0;k < surface->mesh.num_triangles;k++)
+ for (k = 0;k < surface->num_triangles;k++)
{
- tri = surface->mesh.data_element3i + k * 3;
- VectorCopy((surface->mesh.data_vertex3f + tri[0] * 3), vert[0]);
- VectorCopy((surface->mesh.data_vertex3f + tri[1] * 3), vert[1]);
- VectorCopy((surface->mesh.data_vertex3f + tri[2] * 3), vert[2]);
+ tri = (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle) + k * 3;
+ VectorCopy(((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + tri[0] * 3), vert[0]);
+ VectorCopy(((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + tri[1] * 3), vert[1]);
+ VectorCopy(((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + tri[2] * 3), vert[2]);
VectorSubtract(vert[1], vert[0], edge[0]);
VectorSubtract(vert[2], vert[1], edge[1]);
CrossProduct(edge[1], edge[0], facenormal);
subdivpolytriangles = 0;
subdivpolyverts = 0;
- SubdividePolygon(surface->mesh.num_vertices, surface->mesh.data_vertex3f);
+ SubdividePolygon(surface->num_vertices, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex));
if (subdivpolytriangles < 1)
Host_Error("Mod_Q1BSP_GenerateWarpMesh: no triangles?\n");
// surface->flags |= SURF_PLANEBACK;
//surface->plane = loadmodel->brush.data_planes + planenum;
- surface->mesh.num_vertices = numedges;
- surface->mesh.num_triangles = numedges - 2;
- surface->mesh.data_vertex3f = loadmodel->meshlist[0]->data_vertex3f + totalverts * 3;
- surface->mesh.data_texcoordtexture2f = loadmodel->meshlist[0]->data_texcoordtexture2f + totalverts * 2;
- surface->mesh.data_texcoordlightmap2f = loadmodel->meshlist[0]->data_texcoordlightmap2f + totalverts * 2;
- surface->mesh.data_texcoorddetail2f = loadmodel->meshlist[0]->data_texcoorddetail2f + totalverts * 2;
- surface->mesh.data_svector3f = loadmodel->meshlist[0]->data_svector3f + totalverts * 3;
- surface->mesh.data_tvector3f = loadmodel->meshlist[0]->data_tvector3f + totalverts * 3;
- surface->mesh.data_normal3f = loadmodel->meshlist[0]->data_normal3f + totalverts * 3;
- surface->mesh.data_lightmapoffsets = loadmodel->meshlist[0]->data_lightmapoffsets + totalverts;
- surface->mesh.data_element3i = loadmodel->meshlist[0]->data_element3i + totaltris * 3;
- surface->mesh.data_neighbor3i = loadmodel->meshlist[0]->data_neighbor3i + totaltris * 3;
+ surface->groupmesh = loadmodel->meshlist[0];
+ surface->num_firstvertex = totalverts;
+ surface->num_vertices = numedges;
+ surface->num_firsttriangle = totaltris;
+ surface->num_triangles = numedges - 2;
totalverts += numedges;
totaltris += numedges - 2;
// convert edges back to a normal polygon
- for (i = 0;i < surface->mesh.num_vertices;i++)
+ for (i = 0;i < surface->num_vertices;i++)
{
int lindex = loadmodel->brushq1.surfedges[firstedge + i];
float s, t;
if (lindex > 0)
- VectorCopy(loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[lindex].v[0]].position, surface->mesh.data_vertex3f + i * 3);
+ VectorCopy(loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[lindex].v[0]].position, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + i * 3);
else
- VectorCopy(loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[-lindex].v[1]].position, surface->mesh.data_vertex3f + i * 3);
- s = DotProduct((surface->mesh.data_vertex3f + i * 3), surface->lightmapinfo->texinfo->vecs[0]) + surface->lightmapinfo->texinfo->vecs[0][3];
- t = DotProduct((surface->mesh.data_vertex3f + i * 3), surface->lightmapinfo->texinfo->vecs[1]) + surface->lightmapinfo->texinfo->vecs[1][3];
- surface->mesh.data_texcoordtexture2f[i * 2 + 0] = s / surface->texture->width;
- surface->mesh.data_texcoordtexture2f[i * 2 + 1] = t / surface->texture->height;
- surface->mesh.data_texcoorddetail2f[i * 2 + 0] = s * (1.0f / 16.0f);
- surface->mesh.data_texcoorddetail2f[i * 2 + 1] = t * (1.0f / 16.0f);
- surface->mesh.data_texcoordlightmap2f[i * 2 + 0] = 0;
- surface->mesh.data_texcoordlightmap2f[i * 2 + 1] = 0;
- surface->mesh.data_lightmapoffsets[i] = 0;
+ VectorCopy(loadmodel->brushq1.vertexes[loadmodel->brushq1.edges[-lindex].v[1]].position, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + i * 3);
+ s = DotProduct(((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + i * 3), surface->lightmapinfo->texinfo->vecs[0]) + surface->lightmapinfo->texinfo->vecs[0][3];
+ t = DotProduct(((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + i * 3), surface->lightmapinfo->texinfo->vecs[1]) + surface->lightmapinfo->texinfo->vecs[1][3];
+ (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex)[i * 2 + 0] = s / surface->texture->width;
+ (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex)[i * 2 + 1] = t / surface->texture->height;
+ (surface->groupmesh->data_texcoorddetail2f + 2 * surface->num_firstvertex)[i * 2 + 0] = s * (1.0f / 16.0f);
+ (surface->groupmesh->data_texcoorddetail2f + 2 * surface->num_firstvertex)[i * 2 + 1] = t * (1.0f / 16.0f);
+ (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex)[i * 2 + 0] = 0;
+ (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex)[i * 2 + 1] = 0;
+ (surface->groupmesh->data_lightmapoffsets + surface->num_firstvertex)[i] = 0;
}
- for (i = 0;i < surface->mesh.num_triangles;i++)
+ for (i = 0;i < surface->num_triangles;i++)
{
- surface->mesh.data_element3i[i * 3 + 0] = 0;
- surface->mesh.data_element3i[i * 3 + 1] = i + 1;
- surface->mesh.data_element3i[i * 3 + 2] = i + 2;
+ (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)[i * 3 + 0] = 0;
+ (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)[i * 3 + 1] = i + 1;
+ (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)[i * 3 + 2] = i + 2;
}
// compile additional data about the surface geometry
- Mod_BuildTriangleNeighbors(surface->mesh.data_neighbor3i, surface->mesh.data_element3i, surface->mesh.num_triangles);
- Mod_BuildTextureVectorsAndNormals(surface->mesh.num_vertices, surface->mesh.num_triangles, surface->mesh.data_vertex3f, surface->mesh.data_texcoordtexture2f, surface->mesh.data_element3i, surface->mesh.data_svector3f, surface->mesh.data_tvector3f, surface->mesh.data_normal3f);
- BoxFromPoints(surface->mins, surface->maxs, surface->mesh.num_vertices, surface->mesh.data_vertex3f);
+ Mod_BuildTextureVectorsAndNormals(surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_texcoordtexture2f + 2 * surface->num_firstvertex), (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle), (surface->groupmesh->data_svector3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_tvector3f + 3 * surface->num_firstvertex), (surface->groupmesh->data_normal3f + 3 * surface->num_firstvertex));
+ BoxFromPoints(surface->mins, surface->maxs, surface->num_vertices, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex));
// generate surface extents information
- texmins[0] = texmaxs[0] = DotProduct(surface->mesh.data_vertex3f, surface->lightmapinfo->texinfo->vecs[0]) + surface->lightmapinfo->texinfo->vecs[0][3];
- texmins[1] = texmaxs[1] = DotProduct(surface->mesh.data_vertex3f, surface->lightmapinfo->texinfo->vecs[1]) + surface->lightmapinfo->texinfo->vecs[1][3];
- for (i = 1;i < surface->mesh.num_vertices;i++)
+ texmins[0] = texmaxs[0] = DotProduct((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), surface->lightmapinfo->texinfo->vecs[0]) + surface->lightmapinfo->texinfo->vecs[0][3];
+ texmins[1] = texmaxs[1] = DotProduct((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), surface->lightmapinfo->texinfo->vecs[1]) + surface->lightmapinfo->texinfo->vecs[1][3];
+ for (i = 1;i < surface->num_vertices;i++)
{
for (j = 0;j < 2;j++)
{
- val = DotProduct(surface->mesh.data_vertex3f + i * 3, surface->lightmapinfo->texinfo->vecs[j]) + surface->lightmapinfo->texinfo->vecs[j][3];
+ val = DotProduct((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + i * 3, surface->lightmapinfo->texinfo->vecs[j]) + surface->lightmapinfo->texinfo->vecs[j][3];
texmins[j] = min(texmins[j], val);
texmaxs[j] = max(texmaxs[j], val);
}
uscale = (uscale - ubase) / ssize;
vscale = (vscale - vbase) / tsize;
- for (i = 0;i < surface->mesh.num_vertices;i++)
+ for (i = 0;i < surface->num_vertices;i++)
{
- u = ((DotProduct((surface->mesh.data_vertex3f + i * 3), surface->lightmapinfo->texinfo->vecs[0]) + surface->lightmapinfo->texinfo->vecs[0][3]) + 8 - surface->lightmapinfo->texturemins[0]) * (1.0 / 16.0);
- v = ((DotProduct((surface->mesh.data_vertex3f + i * 3), surface->lightmapinfo->texinfo->vecs[1]) + surface->lightmapinfo->texinfo->vecs[1][3]) + 8 - surface->lightmapinfo->texturemins[1]) * (1.0 / 16.0);
- surface->mesh.data_texcoordlightmap2f[i * 2 + 0] = u * uscale + ubase;
- surface->mesh.data_texcoordlightmap2f[i * 2 + 1] = v * vscale + vbase;
+ u = ((DotProduct(((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + i * 3), surface->lightmapinfo->texinfo->vecs[0]) + surface->lightmapinfo->texinfo->vecs[0][3]) + 8 - surface->lightmapinfo->texturemins[0]) * (1.0 / 16.0);
+ v = ((DotProduct(((surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex) + i * 3), surface->lightmapinfo->texinfo->vecs[1]) + surface->lightmapinfo->texinfo->vecs[1][3]) + 8 - surface->lightmapinfo->texturemins[1]) * (1.0 / 16.0);
+ (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex)[i * 2 + 0] = u * uscale + ubase;
+ (surface->groupmesh->data_texcoordlightmap2f + 2 * surface->num_firstvertex)[i * 2 + 1] = v * vscale + vbase;
// LordHavoc: calc lightmap data offset for vertex lighting to use
iu = (int) u;
iv = (int) v;
- surface->mesh.data_lightmapoffsets[i] = (bound(0, iv, tmax) * ssize + bound(0, iu, smax)) * 3;
+ (surface->groupmesh->data_lightmapoffsets + surface->num_firstvertex)[i] = (bound(0, iv, tmax) * ssize + bound(0, iu, smax)) * 3;
}
}
}
for (j = 0, surface = loadmodel->brush.data_surfaces;j < loadmodel->brush.num_surfaces;j++, surface++)
{
surface->num_firstshadowmeshtriangle = numshadowmeshtriangles;
- numshadowmeshtriangles += surface->mesh.num_triangles;
+ numshadowmeshtriangles += surface->num_triangles;
}
loadmodel->brush.shadowmesh = Mod_ShadowMesh_Begin(loadmodel->mempool, numshadowmeshtriangles * 3, numshadowmeshtriangles, NULL, NULL, NULL, false, false, true);
for (j = 0, surface = loadmodel->brush.data_surfaces;j < loadmodel->brush.num_surfaces;j++, surface++)
- Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, surface->mesh.data_vertex3f, NULL, NULL, NULL, NULL, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), NULL, NULL, NULL, NULL, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
loadmodel->brush.shadowmesh = Mod_ShadowMesh_Finish(loadmodel->mempool, loadmodel->brush.shadowmesh, false, true);
Mod_BuildTriangleNeighbors(loadmodel->brush.shadowmesh->neighbor3i, loadmodel->brush.shadowmesh->element3i, loadmodel->brush.shadowmesh->numtriangles);
if (surface->texture->basematerialflags & MATERIALFLAG_SKY)
mod->DrawSky = R_Q1BSP_DrawSky;
// calculate bounding shapes
- for (k = 0, vec = surface->mesh.data_vertex3f;k < surface->mesh.num_vertices;k++, vec += 3)
+ for (k = 0, vec = (surface->groupmesh->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];
// don't render it
continue;
}
- out->mesh.num_vertices = numvertices;
- out->mesh.num_triangles = numtriangles;
- if (meshvertices + out->mesh.num_vertices > 65536)
+ out->num_vertices = numvertices;
+ out->num_triangles = numtriangles;
+ if (meshvertices + out->num_vertices > 65536)
break;
- meshvertices += out->mesh.num_vertices;
- meshtriangles += out->mesh.num_triangles;
+ meshvertices += out->num_vertices;
+ meshtriangles += out->num_triangles;
}
i = oldi;
mesh = tempmeshlist[meshnum] = Mod_AllocSurfMesh(loadmodel->mempool, meshvertices, meshtriangles, false, false, true);
meshvertices = 0;
meshtriangles = 0;
- for (;i < count && meshvertices + out->mesh.num_vertices <= mesh->num_vertices;i++, in++, out++)
+ for (;i < count && meshvertices + out->num_vertices <= mesh->num_vertices;i++, in++, out++)
{
- if (out->mesh.num_vertices < 3 || out->mesh.num_triangles < 1)
+ if (out->num_vertices < 3 || out->num_triangles < 1)
continue;
type = LittleLong(in->type);
firstvertex = LittleLong(in->firstvertex);
firstelement = LittleLong(in->firstelement);
- out->mesh.data_vertex3f = mesh->data_vertex3f + meshvertices * 3;
- out->mesh.data_svector3f = mesh->data_svector3f + meshvertices * 3;
- out->mesh.data_tvector3f = mesh->data_tvector3f + meshvertices * 3;
- out->mesh.data_normal3f = mesh->data_normal3f + meshvertices * 3;
- out->mesh.data_texcoordtexture2f = mesh->data_texcoordtexture2f + meshvertices * 2;
- out->mesh.data_texcoordlightmap2f = mesh->data_texcoordlightmap2f + meshvertices * 2;
- out->mesh.data_lightmapcolor4f = mesh->data_lightmapcolor4f + meshvertices * 4;
- out->mesh.data_element3i = mesh->data_element3i + meshtriangles * 3;
- out->mesh.data_neighbor3i = mesh->data_neighbor3i + meshtriangles * 3;
+ out->groupmesh = mesh;
+ out->num_firstvertex = meshvertices;
+ out->num_firsttriangle = meshtriangles;
switch(type)
{
case Q3FACETYPE_POLYGON:
case Q3FACETYPE_MESH:
// no processing necessary
- for (j = 0;j < out->mesh.num_vertices;j++)
+ for (j = 0;j < out->num_vertices;j++)
{
- out->mesh.data_vertex3f[j * 3 + 0] = loadmodel->brushq3.data_vertex3f[(firstvertex + j) * 3 + 0];
- out->mesh.data_vertex3f[j * 3 + 1] = loadmodel->brushq3.data_vertex3f[(firstvertex + j) * 3 + 1];
- out->mesh.data_vertex3f[j * 3 + 2] = loadmodel->brushq3.data_vertex3f[(firstvertex + j) * 3 + 2];
- out->mesh.data_texcoordtexture2f[j * 2 + 0] = loadmodel->brushq3.data_texcoordtexture2f[(firstvertex + j) * 2 + 0];
- out->mesh.data_texcoordtexture2f[j * 2 + 1] = loadmodel->brushq3.data_texcoordtexture2f[(firstvertex + j) * 2 + 1];
- out->mesh.data_texcoordlightmap2f[j * 2 + 0] = loadmodel->brushq3.data_texcoordlightmap2f[(firstvertex + j) * 2 + 0];
- out->mesh.data_texcoordlightmap2f[j * 2 + 1] = loadmodel->brushq3.data_texcoordlightmap2f[(firstvertex + j) * 2 + 1];
- out->mesh.data_lightmapcolor4f[j * 4 + 0] = loadmodel->brushq3.data_color4f[(firstvertex + j) * 4 + 0];
- out->mesh.data_lightmapcolor4f[j * 4 + 1] = loadmodel->brushq3.data_color4f[(firstvertex + j) * 4 + 1];
- out->mesh.data_lightmapcolor4f[j * 4 + 2] = loadmodel->brushq3.data_color4f[(firstvertex + j) * 4 + 2];
- out->mesh.data_lightmapcolor4f[j * 4 + 3] = loadmodel->brushq3.data_color4f[(firstvertex + j) * 4 + 3];
+ (out->groupmesh->data_vertex3f + 3 * out->num_firstvertex)[j * 3 + 0] = loadmodel->brushq3.data_vertex3f[(firstvertex + j) * 3 + 0];
+ (out->groupmesh->data_vertex3f + 3 * out->num_firstvertex)[j * 3 + 1] = loadmodel->brushq3.data_vertex3f[(firstvertex + j) * 3 + 1];
+ (out->groupmesh->data_vertex3f + 3 * out->num_firstvertex)[j * 3 + 2] = loadmodel->brushq3.data_vertex3f[(firstvertex + j) * 3 + 2];
+ (out->groupmesh->data_texcoordtexture2f + 2 * out->num_firstvertex)[j * 2 + 0] = loadmodel->brushq3.data_texcoordtexture2f[(firstvertex + j) * 2 + 0];
+ (out->groupmesh->data_texcoordtexture2f + 2 * out->num_firstvertex)[j * 2 + 1] = loadmodel->brushq3.data_texcoordtexture2f[(firstvertex + j) * 2 + 1];
+ (out->groupmesh->data_texcoordlightmap2f + 2 * out->num_firstvertex)[j * 2 + 0] = loadmodel->brushq3.data_texcoordlightmap2f[(firstvertex + j) * 2 + 0];
+ (out->groupmesh->data_texcoordlightmap2f + 2 * out->num_firstvertex)[j * 2 + 1] = loadmodel->brushq3.data_texcoordlightmap2f[(firstvertex + j) * 2 + 1];
+ (out->groupmesh->data_lightmapcolor4f + 4 * out->num_firstvertex)[j * 4 + 0] = loadmodel->brushq3.data_color4f[(firstvertex + j) * 4 + 0];
+ (out->groupmesh->data_lightmapcolor4f + 4 * out->num_firstvertex)[j * 4 + 1] = loadmodel->brushq3.data_color4f[(firstvertex + j) * 4 + 1];
+ (out->groupmesh->data_lightmapcolor4f + 4 * out->num_firstvertex)[j * 4 + 2] = loadmodel->brushq3.data_color4f[(firstvertex + j) * 4 + 2];
+ (out->groupmesh->data_lightmapcolor4f + 4 * out->num_firstvertex)[j * 4 + 3] = loadmodel->brushq3.data_color4f[(firstvertex + j) * 4 + 3];
}
- for (j = 0;j < out->mesh.num_triangles*3;j++)
- out->mesh.data_element3i[j] = loadmodel->brushq3.data_element3i[firstelement + j];
+ for (j = 0;j < out->num_triangles*3;j++)
+ (out->groupmesh->data_element3i + 3 * out->num_firsttriangle)[j] = loadmodel->brushq3.data_element3i[firstelement + j];
break;
case Q3FACETYPE_PATCH:
patchsize[0] = LittleLong(in->specific.patch.patchsize[0]);
type = Q3FACETYPE_MESH;
// generate geometry
// (note: normals are skipped because they get recalculated)
- Q3PatchTesselateFloat(3, sizeof(float[3]), out->mesh.data_vertex3f, patchsize[0], patchsize[1], sizeof(float[3]), originalvertex3f, xtess, ytess);
- Q3PatchTesselateFloat(2, sizeof(float[2]), out->mesh.data_texcoordtexture2f, patchsize[0], patchsize[1], sizeof(float[2]), originaltexcoordtexture2f, xtess, ytess);
- Q3PatchTesselateFloat(2, sizeof(float[2]), out->mesh.data_texcoordlightmap2f, patchsize[0], patchsize[1], sizeof(float[2]), originaltexcoordlightmap2f, xtess, ytess);
- Q3PatchTesselateFloat(4, sizeof(float[4]), out->mesh.data_lightmapcolor4f, patchsize[0], patchsize[1], sizeof(float[4]), originalcolor4f, xtess, ytess);
- Q3PatchTriangleElements(out->mesh.data_element3i, finalwidth, finalheight);
- out->mesh.num_triangles = Mod_RemoveDegenerateTriangles(out->mesh.num_triangles, out->mesh.data_element3i, out->mesh.data_element3i, out->mesh.data_vertex3f);
+ Q3PatchTesselateFloat(3, sizeof(float[3]), (out->groupmesh->data_vertex3f + 3 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[3]), originalvertex3f, xtess, ytess);
+ Q3PatchTesselateFloat(2, sizeof(float[2]), (out->groupmesh->data_texcoordtexture2f + 2 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[2]), originaltexcoordtexture2f, xtess, ytess);
+ Q3PatchTesselateFloat(2, sizeof(float[2]), (out->groupmesh->data_texcoordlightmap2f + 2 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[2]), originaltexcoordlightmap2f, xtess, ytess);
+ Q3PatchTesselateFloat(4, sizeof(float[4]), (out->groupmesh->data_lightmapcolor4f + 4 * out->num_firstvertex), patchsize[0], patchsize[1], sizeof(float[4]), originalcolor4f, xtess, ytess);
+ Q3PatchTriangleElements((out->groupmesh->data_element3i + 3 * out->num_firsttriangle), finalwidth, finalheight);
+ out->num_triangles = Mod_RemoveDegenerateTriangles(out->num_triangles, (out->groupmesh->data_element3i + 3 * out->num_firsttriangle), (out->groupmesh->data_element3i + 3 * out->num_firsttriangle), (out->groupmesh->data_vertex3f + 3 * out->num_firstvertex));
if (developer.integer >= 2)
{
- if (out->mesh.num_triangles < finaltriangles)
- Con_Printf("Mod_Q3BSP_LoadFaces: %ix%i curve subdivided to %i vertices / %i triangles, %i degenerate triangles removed (leaving %i)\n", patchsize[0], patchsize[1], out->mesh.num_vertices, finaltriangles, finaltriangles - out->mesh.num_triangles, out->mesh.num_triangles);
+ if (out->num_triangles < finaltriangles)
+ Con_Printf("Mod_Q3BSP_LoadFaces: %ix%i curve subdivided to %i vertices / %i triangles, %i degenerate triangles removed (leaving %i)\n", patchsize[0], patchsize[1], out->num_vertices, finaltriangles, finaltriangles - out->num_triangles, out->num_triangles);
else
- Con_Printf("Mod_Q3BSP_LoadFaces: %ix%i curve subdivided to %i vertices / %i triangles\n", patchsize[0], patchsize[1], out->mesh.num_vertices, out->mesh.num_triangles);
+ Con_Printf("Mod_Q3BSP_LoadFaces: %ix%i curve subdivided to %i vertices / %i triangles\n", patchsize[0], patchsize[1], out->num_vertices, out->num_triangles);
}
// q3map does not put in collision brushes for curves... ugh
// build the lower quality collision geometry
Q3PatchTesselateFloat(3, sizeof(float[3]), out->data_collisionvertex3f, patchsize[0], patchsize[1], sizeof(float[3]), originalvertex3f, xtess, ytess);
Q3PatchTriangleElements(out->data_collisionelement3i, finalwidth, finalheight);
- //Mod_SnapVertices(3, out->mesh.num_vertices, out->mesh.data_vertex3f, 0.25);
+ //Mod_SnapVertices(3, out->num_vertices, (out->groupmesh->data_vertex3f + 3 * out->num_firstvertex), 0.25);
Mod_SnapVertices(3, out->num_collisionvertices, out->data_collisionvertex3f, 1);
- oldnumtriangles = out->mesh.num_triangles;
+ oldnumtriangles = out->num_triangles;
oldnumtriangles2 = out->num_collisiontriangles;
out->num_collisiontriangles = Mod_RemoveDegenerateTriangles(out->num_collisiontriangles, out->data_collisionelement3i, out->data_collisionelement3i, out->data_collisionvertex3f);
if (developer.integer)
- Con_Printf("Mod_Q3BSP_LoadFaces: %ix%i curve became %i:%i vertices / %i:%i triangles (%i:%i degenerate)\n", patchsize[0], patchsize[1], out->mesh.num_vertices, out->num_collisionvertices, oldnumtriangles, oldnumtriangles2, oldnumtriangles - out->mesh.num_triangles, oldnumtriangles2 - out->num_collisiontriangles);
+ Con_Printf("Mod_Q3BSP_LoadFaces: %ix%i curve became %i:%i vertices / %i:%i triangles (%i:%i degenerate)\n", patchsize[0], patchsize[1], out->num_vertices, out->num_collisionvertices, oldnumtriangles, oldnumtriangles2, oldnumtriangles - out->num_triangles, oldnumtriangles2 - out->num_collisiontriangles);
break;
default:
break;
}
- meshvertices += out->mesh.num_vertices;
- meshtriangles += out->mesh.num_triangles;
- for (j = 0, invalidelements = 0;j < out->mesh.num_triangles * 3;j++)
- if (out->mesh.data_element3i[j] < 0 || out->mesh.data_element3i[j] >= out->mesh.num_vertices)
+ meshvertices += out->num_vertices;
+ meshtriangles += out->num_triangles;
+ for (j = 0, invalidelements = 0;j < out->num_triangles * 3;j++)
+ if ((out->groupmesh->data_element3i + 3 * out->num_firsttriangle)[j] < 0 || (out->groupmesh->data_element3i + 3 * out->num_firsttriangle)[j] >= out->num_vertices)
invalidelements++;
if (invalidelements)
{
- Con_Printf("Mod_Q3BSP_LoadFaces: Warning: face #%i has %i invalid elements, type = %i, texture->name = \"%s\", texture->surfaceflags = %i, firstvertex = %i, numvertices = %i, firstelement = %i, numelements = %i, elements list:\n", i, invalidelements, type, out->texture->name, out->texture->surfaceflags, firstvertex, out->mesh.num_vertices, firstelement, out->mesh.num_triangles * 3);
- for (j = 0;j < out->mesh.num_triangles * 3;j++)
+ Con_Printf("Mod_Q3BSP_LoadFaces: Warning: face #%i has %i invalid elements, type = %i, texture->name = \"%s\", texture->surfaceflags = %i, firstvertex = %i, numvertices = %i, firstelement = %i, numelements = %i, elements list:\n", i, invalidelements, type, out->texture->name, out->texture->surfaceflags, firstvertex, out->num_vertices, firstelement, out->num_triangles * 3);
+ for (j = 0;j < out->num_triangles * 3;j++)
{
- Con_Printf(" %i", out->mesh.data_element3i[j]);
- if (out->mesh.data_element3i[j] < 0 || out->mesh.data_element3i[j] >= out->mesh.num_vertices)
- out->mesh.data_element3i[j] = 0;
+ Con_Printf(" %i", (out->groupmesh->data_element3i + 3 * out->num_firsttriangle)[j]);
+ if ((out->groupmesh->data_element3i + 3 * out->num_firsttriangle)[j] < 0 || (out->groupmesh->data_element3i + 3 * out->num_firsttriangle)[j] >= out->num_vertices)
+ (out->groupmesh->data_element3i + 3 * out->num_firsttriangle)[j] = 0;
}
Con_Print("\n");
}
- // for shadow volumes
- Mod_BuildTriangleNeighbors(out->mesh.data_neighbor3i, out->mesh.data_element3i, out->mesh.num_triangles);
// for per pixel lighting
- Mod_BuildTextureVectorsAndNormals(out->mesh.num_vertices, out->mesh.num_triangles, out->mesh.data_vertex3f, out->mesh.data_texcoordtexture2f, out->mesh.data_element3i, out->mesh.data_svector3f, out->mesh.data_tvector3f, out->mesh.data_normal3f);
+ Mod_BuildTextureVectorsAndNormals(out->num_vertices, out->num_triangles, (out->groupmesh->data_vertex3f + 3 * out->num_firstvertex), (out->groupmesh->data_texcoordtexture2f + 2 * out->num_firstvertex), (out->groupmesh->data_element3i + 3 * out->num_firsttriangle), (out->groupmesh->data_svector3f + 3 * out->num_firstvertex), (out->groupmesh->data_tvector3f + 3 * out->num_firstvertex), (out->groupmesh->data_normal3f + 3 * out->num_firstvertex));
// calculate a bounding box
VectorClear(out->mins);
VectorClear(out->maxs);
- if (out->mesh.num_vertices)
+ if (out->num_vertices)
{
- VectorCopy(out->mesh.data_vertex3f, out->mins);
- VectorCopy(out->mesh.data_vertex3f, out->maxs);
- for (j = 1, v = out->mesh.data_vertex3f + 3;j < out->mesh.num_vertices;j++, v += 3)
+ VectorCopy((out->groupmesh->data_vertex3f + 3 * out->num_firstvertex), out->mins);
+ VectorCopy((out->groupmesh->data_vertex3f + 3 * out->num_firstvertex), out->maxs);
+ for (j = 1, v = (out->groupmesh->data_vertex3f + 3 * out->num_firstvertex) + 3;j < out->num_vertices;j++, v += 3)
{
out->mins[0] = min(out->mins[0], v[0]);
out->maxs[0] = max(out->maxs[0], v[0]);
for (j = 0, surface = loadmodel->brush.data_surfaces;j < loadmodel->brush.num_surfaces;j++, surface++)
{
surface->num_firstshadowmeshtriangle = numshadowmeshtriangles;
- numshadowmeshtriangles += surface->mesh.num_triangles;
+ numshadowmeshtriangles += surface->num_triangles;
}
loadmodel->brush.shadowmesh = Mod_ShadowMesh_Begin(loadmodel->mempool, numshadowmeshtriangles * 3, numshadowmeshtriangles, NULL, NULL, NULL, false, false, true);
for (j = 0, surface = loadmodel->brush.data_surfaces;j < loadmodel->brush.num_surfaces;j++, surface++)
- Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, surface->mesh.data_vertex3f, NULL, NULL, NULL, NULL, surface->mesh.num_triangles, surface->mesh.data_element3i);
+ Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, (surface->groupmesh->data_vertex3f + 3 * surface->num_firstvertex), NULL, NULL, NULL, NULL, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle));
loadmodel->brush.shadowmesh = Mod_ShadowMesh_Finish(loadmodel->mempool, loadmodel->brush.shadowmesh, false, true);
Mod_BuildTriangleNeighbors(loadmodel->brush.shadowmesh->neighbor3i, loadmodel->brush.shadowmesh->element3i, loadmodel->brush.shadowmesh->numtriangles);