aliasmesh_t *mesh;
aliasskin_t *skin;
rmeshstate_t m;
- float *v, planenormal[3], planedist, dist, projection[3], floororigin[3], surfnormal[3], lightdirection[3], v2[3];
+ float *v, plane[4], dist, projection[3], floororigin[3], surfnormal[3], lightdirection[3], v2[3];
+ rcachearrayrequest_t request;
if ((ent->effects & EF_ADDITIVE) || ent->alpha < 1)
return;
memset(&m, 0, sizeof(m));
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
- R_Mesh_State(&m);
+ if (gl_mesh_copyarrays.integer)
+ R_Mesh_State(&m);
GL_Color(0, 0, 0, 0.5);
// put a light direction in the entity's coordinate space
VectorNormalizeFast(projection);
// put the plane's normal in the entity's coordinate space
- Matrix4x4_Transform3x3(&ent->inversematrix, surfnormal, planenormal);
- VectorNormalizeFast(planenormal);
+ Matrix4x4_Transform3x3(&ent->inversematrix, surfnormal, plane);
+ VectorNormalizeFast(plane);
// put the plane's distance in the entity's coordinate space
VectorSubtract(floororigin, ent->origin, floororigin);
- planedist = DotProduct(floororigin, surfnormal) + 2;
+ plane[3] = DotProduct(floororigin, surfnormal) + 2;
- dist = -1.0f / DotProduct(projection, planenormal);
+ dist = -1.0f / DotProduct(projection, plane);
VectorScale(projection, dist, projection);
+ memset(&request, 0, sizeof(request));
for (meshnum = 0, mesh = ent->model->aliasdata_meshes;meshnum < ent->model->aliasnum_meshes;meshnum++)
{
skin = R_FetchAliasSkin(ent, mesh);
if (skin->flags & ALIASSKIN_TRANSPARENT)
continue;
- R_Mesh_GetSpace(mesh->num_vertices);
- R_Model_Alias_GetMesh_Array3f(ent, mesh, MODELARRAY_VERTEX, varray_vertex3f);
- for (i = 0, v = varray_vertex3f;i < mesh->num_vertices;i++, v += 3)
+ if (gl_mesh_copyarrays.integer)
+ {
+ R_Mesh_GetSpace(mesh->num_vertices);
+ R_Model_Alias_GetMesh_Array3f(ent, mesh, MODELARRAY_VERTEX, varray_vertex3f);
+ for (i = 0, v = varray_vertex3f;i < mesh->num_vertices;i++, v += 3)
+ {
+ dist = DotProduct(v, plane) - plane[3];
+ if (dist > 0)
+ VectorMA(v, dist, projection, v);
+ }
+ }
+ else
{
- dist = DotProduct(v, planenormal) - planedist;
- if (dist > 0)
- VectorMA(v, dist, projection, v);
+ request.data_size = mesh->num_vertices * sizeof(float[3]);
+ request.id_pointer1 = mesh;
+ request.id_number1 = CRC_Block((void *)&ent->matrix, sizeof(ent->matrix));
+ request.id_number2 = CRC_Block((void *)&plane, sizeof(plane));
+ request.id_number3 = CRC_Block((void *)&ent->frameblend, sizeof(ent->frameblend));
+ m.pointervertexcount = mesh->num_vertices;
+ if (R_Mesh_CacheArray(&request))
+ {
+ R_Model_Alias_GetMesh_Array3f(ent, mesh, MODELARRAY_VERTEX, request.data);
+ for (i = 0, v = request.data;i < mesh->num_vertices;i++, v += 3)
+ {
+ dist = DotProduct(v, plane) - plane[3];
+ if (dist > 0)
+ VectorMA(v, dist, projection, v);
+ }
+ }
+ m.pointer_vertex = request.data;
+ R_Mesh_State(&m);
}
c_alias_polys += mesh->num_triangles;
R_Mesh_Draw(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i);