+
+ if (r_showtris.integer || r_shownormals.integer)
+ {
+ int k, l;
+ const int *elements;
+ rmeshstate_t m;
+ vec3_t v;
+ GL_DepthTest(true);
+ GL_DepthMask(true);
+ if (r_showdisabledepthtest.integer)
+ qglDepthFunc(GL_ALWAYS);
+ GL_BlendFunc(GL_ONE, GL_ZERO);
+ memset(&m, 0, sizeof(m));
+ R_Mesh_State(&m);
+ for (i = 0, j = model->firstmodelsurface, surface = model->data_surfaces + j;i < model->nummodelsurfaces;i++, j++, surface++)
+ {
+ if (ent == r_refdef.worldentity && !r_worldsurfacevisible[j])
+ continue;
+ texture = surface->texture->currentframe;
+ if ((texture->currentmaterialflags & flagsmask) && surface->num_triangles)
+ {
+ RSurf_SetVertexPointer(ent, texture, surface, modelorg, false, r_shownormals.integer != 0);
+ if (r_showtris.integer)
+ {
+ if (!texture->currentlayers->depthmask)
+ GL_Color(r_showtris.value, 0, 0, 1);
+ else if (ent == r_refdef.worldentity)
+ GL_Color(r_showtris.value, r_showtris.value, r_showtris.value, 1);
+ else
+ GL_Color(0, r_showtris.value, 0, 1);
+ elements = (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle);
+ qglBegin(GL_LINES);
+ for (k = 0;k < surface->num_triangles;k++, elements += 3)
+ {
+ qglArrayElement(elements[0]);qglArrayElement(elements[1]);
+ qglArrayElement(elements[1]);qglArrayElement(elements[2]);
+ qglArrayElement(elements[2]);qglArrayElement(elements[0]);
+ }
+ qglEnd();
+ }
+ if (r_shownormals.integer)
+ {
+ GL_Color(r_shownormals.value, 0, 0, 1);
+ qglBegin(GL_LINES);
+ for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++)
+ {
+ VectorCopy(rsurface_vertex3f + l * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ VectorMA(v, 8, rsurface_svector3f + l * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ }
+ qglEnd();
+ GL_Color(0, 0, r_shownormals.value, 1);
+ qglBegin(GL_LINES);
+ for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++)
+ {
+ VectorCopy(rsurface_vertex3f + l * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ VectorMA(v, 8, rsurface_tvector3f + l * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ }
+ qglEnd();
+ GL_Color(0, r_shownormals.value, 0, 1);
+ qglBegin(GL_LINES);
+ for (k = 0, l = surface->num_firstvertex;k < surface->num_vertices;k++, l++)
+ {
+ VectorCopy(rsurface_vertex3f + l * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ VectorMA(v, 8, rsurface_normal3f + l * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ }
+ qglEnd();
+ }
+ }
+ }
+ if (r_showdisabledepthtest.integer)
+ qglDepthFunc(GL_LEQUAL);
+ }