-void VMPolygons_Store(vmpolygons_t *polys)
-{
- qboolean hasalpha;
- int i;
-
- // detect if we have alpha
- hasalpha = polys->begin_texture_hasalpha;
- for(i = 0; !hasalpha && (i < polys->begin_vertices); ++i)
- if(polys->begin_color[i][3] < 1)
- hasalpha = true;
-
- if (polys->begin_draw2d)
- {
- // draw the polygon as 2D immediately
- drawqueuemesh_t mesh;
- mesh.texture = polys->begin_texture;
- mesh.num_vertices = polys->begin_vertices;
- mesh.num_triangles = polys->begin_vertices-2;
- mesh.data_element3i = polygonelement3i;
- mesh.data_element3s = polygonelement3s;
- mesh.data_vertex3f = polys->begin_vertex[0];
- mesh.data_color4f = polys->begin_color[0];
- mesh.data_texcoord2f = polys->begin_texcoord[0];
- DrawQ_Mesh(&mesh, polys->begin_drawflag, hasalpha);
- }
- else
- {
- // queue the polygon as 3D for sorted transparent rendering later
- int i;
- if (polys->max_triangles < polys->num_triangles + polys->begin_vertices-2)
- {
- while (polys->max_triangles < polys->num_triangles + polys->begin_vertices-2)
- polys->max_triangles *= 2;
- VM_ResizePolygons(polys);
- }
- if (polys->num_vertices + polys->begin_vertices <= polys->max_vertices)
- {
- // needle in a haystack!
- // polys->num_vertices was used for copying where we actually want to copy begin_vertices
- // that also caused it to not render the first polygon that is added
- // --blub
- memcpy(polys->data_vertex3f + polys->num_vertices * 3, polys->begin_vertex[0], polys->begin_vertices * sizeof(float[3]));
- memcpy(polys->data_color4f + polys->num_vertices * 4, polys->begin_color[0], polys->begin_vertices * sizeof(float[4]));
- memcpy(polys->data_texcoord2f + polys->num_vertices * 2, polys->begin_texcoord[0], polys->begin_vertices * sizeof(float[2]));
- for (i = 0;i < polys->begin_vertices-2;i++)
- {
- polys->data_triangles[polys->num_triangles].texture = polys->begin_texture;
- polys->data_triangles[polys->num_triangles].drawflag = polys->begin_drawflag;
- polys->data_triangles[polys->num_triangles].elements[0] = polys->num_vertices;
- polys->data_triangles[polys->num_triangles].elements[1] = polys->num_vertices + i+1;
- polys->data_triangles[polys->num_triangles].elements[2] = polys->num_vertices + i+2;
- polys->data_triangles[polys->num_triangles].hasalpha = hasalpha;
- polys->num_triangles++;
- }
- polys->num_vertices += polys->begin_vertices;
- }
- }
- polys->begin_active = false;
-}
-
-// TODO: move this into the client code and clean-up everything else, too! [1/6/2008 Black]
-// LordHavoc: agreed, this is a mess
-void VM_CL_AddPolygonsToMeshQueue (void)
-{
- int i;
- vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
- vec3_t center;
-
- // only add polygons of the currently active prog to the queue - if there is none, we're done
- if( !prog )
- return;
-
- if (!polys->num_triangles)
- return;
-
- for (i = 0;i < polys->num_triangles;i++)
- {
- VectorMAMAM(1.0f / 3.0f, polys->data_vertex3f + 3*polys->data_triangles[i].elements[0], 1.0f / 3.0f, polys->data_vertex3f + 3*polys->data_triangles[i].elements[1], 1.0f / 3.0f, polys->data_vertex3f + 3*polys->data_triangles[i].elements[2], center);
- R_MeshQueue_AddTransparent(center, VM_DrawPolygonCallback, NULL, i, NULL);
- }
-
- /*polys->num_triangles = 0; // now done after rendering the scene,
- polys->num_vertices = 0; // otherwise it's not rendered at all and prints an error message --blub */
-}
-