- xtess = bound(1, xtess, 1024);
- ytess = bound(1, ytess, 1024);
- // bound to user limit on vertices
- while ((xtess > 1 || ytess > 1) && (((patchsize[0] - 1) * xtess) + 1) * (((patchsize[1] - 1) * ytess) + 1) > min(r_subdivisions_maxvertices.integer, 262144))
- {
- if (xtess > ytess)
- xtess--;
- else
- ytess--;
- }
- finalwidth = ((patchsize[0] - 1) * xtess) + 1;
- finalheight = ((patchsize[1] - 1) * ytess) + 1;
- numvertices = finalwidth * finalheight;
- numtriangles = (finalwidth - 1) * (finalheight - 1) * 2;
+ xtess = bound(0, xtess, 1024);
+ ytess = bound(0, ytess, 1024);
+
+ // lower quality collision patches! Same procedure as before, but different cvars
+ // convert patch to Q3FACETYPE_MESH
+ cxtess = Q3PatchTesselationOnX(patchsize[0], patchsize[1], 3, originalvertex3f, r_subdivisions_collision_tolerance.value);
+ cytess = Q3PatchTesselationOnY(patchsize[0], patchsize[1], 3, originalvertex3f, r_subdivisions_collision_tolerance.value);
+ // bound to user settings
+ cxtess = bound(r_subdivisions_collision_mintess.integer, cxtess, r_subdivisions_collision_maxtess.integer);
+ cytess = bound(r_subdivisions_collision_mintess.integer, cytess, r_subdivisions_collision_maxtess.integer);
+ // bound to sanity settings
+ cxtess = bound(0, cxtess, 1024);
+ cytess = bound(0, cytess, 1024);
+
+ // store it for the LOD grouping step
+ patchtess[patchtesscount].info.xsize = patchsize[0];
+ patchtess[patchtesscount].info.ysize = patchsize[1];
+ patchtess[patchtesscount].info.lods[PATCH_LOD_VISUAL].xtess = xtess;
+ patchtess[patchtesscount].info.lods[PATCH_LOD_VISUAL].ytess = ytess;
+ patchtess[patchtesscount].info.lods[PATCH_LOD_COLLISION].xtess = cxtess;
+ patchtess[patchtesscount].info.lods[PATCH_LOD_COLLISION].ytess = cytess;
+
+ patchtess[patchtesscount].surface_id = i;
+ patchtess[patchtesscount].lodgroup[0] = in->specific.patch.mins[0];
+ patchtess[patchtesscount].lodgroup[1] = in->specific.patch.mins[1];
+ patchtess[patchtesscount].lodgroup[2] = in->specific.patch.mins[2];
+ patchtess[patchtesscount].lodgroup[3] = in->specific.patch.maxs[0];
+ patchtess[patchtesscount].lodgroup[4] = in->specific.patch.maxs[1];
+ patchtess[patchtesscount].lodgroup[5] = in->specific.patch.maxs[2];
+ patchtess[patchtesscount].originalvertex3f = originalvertex3f;
+ ++patchtesscount;