by jitspoe » Wed Feb 18, 2015 5:53 am
Hm, I thought I already had. Guess not.
----------------------
qbsp.h:
Made this global:
#define PLANESIDE_EPSILON 0.001
-----------------------
brushbsp.c
I removed the local #define PLANESIDE_EPSILON
In CreateBrushWindings():
I changed:
ChopWindingInPlace (&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);
To:
ChopWindingInPlace(&w, plane->normal, plane->dist, PLANESIDE_EPSILON);
(not sure how important this one is)
In SplitBrush():
float d, d_front, d_back;
To:
vec_t d, d_front, d_back; // jit (use higher precision, if enabled)
And
ChopWindingInPlace (&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON);
To:
ChopWindingInPlace(&w, plane2->normal, plane2->dist, PLANESIDE_EPSILON); // jit - reenabled epsilon (was 0)
(multiple instances of this -- reenabled the epsilon on all of them)
******* THIS IS THE IMPORTANT ONE ********
v1 = BrushVolume (b[i]);
if (v1 < 1.0)
to:
v1 = BrushVolume(b[i]);
if (v1 < microvolume) // jit - allow for smaller brush volumes
----------------
csg.c:
MakeBspBrushList():
float dist;
to:
vec_t dist; // jit (use higher precision, if enabled)
----------------
faces.c:
#define POINT_EPSILON 0.5
#define OFF_EPSILON 0.5
To:
#define POINT_EPSILON 0.04 // jit, was 0.5
#define OFF_EPSILON 0.04 // jit, was 0.5
GetVertexnum():
for (vnum=hashverts[h] ; vnum ; vnum=vertexchain[vnum])
{
p = dvertexes[vnum].point;
if ( fabs(p[0]-vert[0])<POINT_EPSILON
&& fabs(p[1]-vert[1])<POINT_EPSILON
&& fabs(p[2]-vert[2])<POINT_EPSILON )
return vnum;
}
To:
for (vnum = hashverts[h]; vnum; vnum = vertexchain[vnum])
{
vec3_t diff;
vec_t length_sq; // jit
p = dvertexes[vnum].point;
VectorSubtract(p, vert, diff); // jit
length_sq = VectorLengthSq(diff); // jit
if (length_sq < POINT_EPSILON * POINT_EPSILON)
return vnum;
}
---------------------
map.c:
ChopWindingInPlace (&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);
To:
ChopWindingInPlace(&w, plane->normal, plane->dist, PLANESIDE_EPSILON); // jit, was 0); //CLIP_EPSILON);
---------------------
qbsp3.c
*********** ALSO IMPORTANT (relates to the other microvolume change) *******************
vec_t microvolume = 1.0;
vec_t microvolume = 0.02f; // jit - was 1.0, but this messes up small brushes
---------------------
mathlib.h
#ifdef QBSP3 // only do this for qbsp, leads to stack overflows on qrad3.
#define DOUBLEVEC_T // jit - might as well be more accurate, and sometimes doubles are even faster on modern hardware, anyway...
#endif
*NOTE* I had to do this only for QBSP3, because if you do it for qrad3, it will stack overflow.
------------------------------------
I think that covers everything. The microvolume is the one that fixes the biggest issue. The other fixes may or may not be necessary, but I think I fixed a lot of issues with near infinitely-small triangle creation.