- VectorCopy((surfmesh->vertex3f + elements[0] * 3), trianglepoints[0]);
- VectorCopy((surfmesh->vertex3f + elements[1] * 3), trianglepoints[1]);
- VectorCopy((surfmesh->vertex3f + elements[2] * 3), trianglepoints[2]);
- if (PointInfrontOfTriangle(info->eye, trianglepoints[0], trianglepoints[1], trianglepoints[2])
- && Portal_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, trianglepoints[0], 3, &portaltemppoints2[0][0], 256) >= 3)
- break;
+ int j;
+ const int *elements;
+ const float *vertex3f;
+ float v[9], trimins[3], trimaxs[3];
+ vertex3f = surface->groupmesh->data_vertex3f;
+ elements = (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle);
+ for (j = 0;j < surface->num_triangles;j++, elements += 3)
+ {
+ VectorCopy(vertex3f + elements[0] * 3, v + 0);
+ VectorCopy(vertex3f + elements[1] * 3, v + 3);
+ VectorCopy(vertex3f + elements[2] * 3, v + 6);
+ if (PointInfrontOfTriangle(info->eye, v + 0, v + 3, v + 6))
+ {
+ trimins[0] = min(v[0], min(v[3], v[6]));
+ trimaxs[0] = max(v[0], max(v[3], v[6]));
+ trimins[1] = min(v[1], min(v[4], v[7]));
+ trimaxs[1] = max(v[1], max(v[4], v[7]));
+ trimins[2] = min(v[2], min(v[5], v[8]));
+ trimaxs[2] = max(v[2], max(v[5], v[8]));
+ if (BoxesOverlap(trimins, trimaxs, info->boxmins, info->boxmaxs) && Portal_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, v, 3, &portaltemppoints2[0][0], 256) >= 3)
+ {
+ SETPVSBIT(info->surfacepvs, surfaceindex);
+ info->surfacelist[info->numsurfaces++] = surfaceindex;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ SETPVSBIT(info->surfacepvs, surfaceindex);
+ info->surfacelist[info->numsurfaces++] = surfaceindex;