light: move DicePatch to polylib.c
This commit is contained in:
parent
a0f636a69a
commit
fff12697e5
|
|
@ -418,3 +418,52 @@ CheckWinding(const winding_t * w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
DiceWinding
|
||||||
|
|
||||||
|
Chops the winding by a global grid.
|
||||||
|
Calls save_fn on each subdivided chunk.
|
||||||
|
Frees w.
|
||||||
|
|
||||||
|
From q3rad (DicePatch)
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
void DiceWinding (winding_t *w, vec_t subdiv, save_winding_fn_t save_fn)
|
||||||
|
{
|
||||||
|
winding_t *o1, *o2;
|
||||||
|
vec3_t mins, maxs;
|
||||||
|
vec3_t split;
|
||||||
|
vec_t dist;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!w)
|
||||||
|
return;
|
||||||
|
|
||||||
|
WindingBounds (w, mins, maxs);
|
||||||
|
for (i=0 ; i<3 ; i++)
|
||||||
|
if (floor((mins[i]+1)/subdiv) < floor((maxs[i]-1)/subdiv))
|
||||||
|
break;
|
||||||
|
if (i == 3)
|
||||||
|
{
|
||||||
|
// no splitting needed
|
||||||
|
save_fn(w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// split the winding
|
||||||
|
//
|
||||||
|
VectorCopy (vec3_origin, split);
|
||||||
|
split[i] = 1;
|
||||||
|
dist = subdiv*(1+floor((mins[i]+1)/subdiv));
|
||||||
|
ClipWinding (w, split, dist, &o1, &o2);
|
||||||
|
free(w);
|
||||||
|
|
||||||
|
//
|
||||||
|
// create a new patch
|
||||||
|
//
|
||||||
|
DiceWinding(o1, subdiv, save_fn);
|
||||||
|
DiceWinding(o2, subdiv, save_fn);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ void CheckWinding(const winding_t * w);
|
||||||
void WindingPlane(const winding_t * w, vec3_t normal, vec_t *dist);
|
void WindingPlane(const winding_t * w, vec3_t normal, vec_t *dist);
|
||||||
void RemoveColinearPoints(winding_t * w);
|
void RemoveColinearPoints(winding_t * w);
|
||||||
|
|
||||||
|
typedef void (*save_winding_fn_t)(winding_t *w);
|
||||||
|
void DiceWinding (winding_t *w, vec_t subdiv, save_winding_fn_t save_fn);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -958,52 +958,6 @@ void SavePatch (const bsp2_t *bsp, const bsp2_dface_t *sourceface, winding_t *w)
|
||||||
facenumToPatches[i].push_back(p);
|
facenumToPatches[i].push_back(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
=============
|
|
||||||
DicePatch
|
|
||||||
|
|
||||||
Chops the patch by a global grid
|
|
||||||
From q3rad
|
|
||||||
=============
|
|
||||||
*/
|
|
||||||
void DicePatch (const bsp2_t *bsp, const bsp2_dface_t *sourceface, winding_t *w, vec_t subdiv)
|
|
||||||
{
|
|
||||||
winding_t *o1, *o2;
|
|
||||||
vec3_t mins, maxs;
|
|
||||||
vec3_t split;
|
|
||||||
vec_t dist;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!w)
|
|
||||||
return;
|
|
||||||
|
|
||||||
WindingBounds (w, mins, maxs);
|
|
||||||
for (i=0 ; i<3 ; i++)
|
|
||||||
if (floor((mins[i]+1)/subdiv) < floor((maxs[i]-1)/subdiv))
|
|
||||||
break;
|
|
||||||
if (i == 3)
|
|
||||||
{
|
|
||||||
// no splitting needed
|
|
||||||
SavePatch(bsp, sourceface, w);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// split the winding
|
|
||||||
//
|
|
||||||
VectorCopy (vec3_origin, split);
|
|
||||||
split[i] = 1;
|
|
||||||
dist = subdiv*(1+floor((mins[i]+1)/subdiv));
|
|
||||||
ClipWinding (w, split, dist, &o1, &o2);
|
|
||||||
free(w);
|
|
||||||
|
|
||||||
//
|
|
||||||
// create a new patch
|
|
||||||
//
|
|
||||||
DicePatch(bsp, sourceface, o1, subdiv);
|
|
||||||
DicePatch(bsp, sourceface, o2, subdiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
MakeBounceLightsThread (void *arg)
|
MakeBounceLightsThread (void *arg)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue