mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-10 14:42:13 +00:00
small fix
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4823 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
c7e4a1b183
commit
16868f1604
2 changed files with 75 additions and 67 deletions
|
@ -955,6 +955,79 @@ Physics functions (common)
|
||||||
|
|
||||||
============================================================================
|
============================================================================
|
||||||
|
|
||||||
|
Utility function
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAXFRAGMENTVERTS 360
|
||||||
|
int Fragment_ClipPolyToPlane(float *inverts, float *outverts, int incount, float *plane, float planedist)
|
||||||
|
{
|
||||||
|
#define C 4
|
||||||
|
float dotv[MAXFRAGMENTVERTS+1];
|
||||||
|
char keep[MAXFRAGMENTVERTS+1];
|
||||||
|
#define KEEP_KILL 0
|
||||||
|
#define KEEP_KEEP 1
|
||||||
|
#define KEEP_BORDER 2
|
||||||
|
int i;
|
||||||
|
int outcount = 0;
|
||||||
|
int clippedcount = 0;
|
||||||
|
float d, *p1, *p2, *out;
|
||||||
|
#define FRAG_EPSILON 0.5
|
||||||
|
|
||||||
|
for (i = 0; i < incount; i++)
|
||||||
|
{
|
||||||
|
dotv[i] = DotProduct((inverts+i*C), plane) - planedist;
|
||||||
|
if (dotv[i]<-FRAG_EPSILON)
|
||||||
|
{
|
||||||
|
keep[i] = KEEP_KILL;
|
||||||
|
clippedcount++;
|
||||||
|
}
|
||||||
|
else if (dotv[i] > FRAG_EPSILON)
|
||||||
|
keep[i] = KEEP_KEEP;
|
||||||
|
else
|
||||||
|
keep[i] = KEEP_BORDER;
|
||||||
|
}
|
||||||
|
dotv[i] = dotv[0];
|
||||||
|
keep[i] = keep[0];
|
||||||
|
|
||||||
|
if (clippedcount == incount)
|
||||||
|
return 0; //all were clipped
|
||||||
|
if (clippedcount == 0)
|
||||||
|
{ //none were clipped
|
||||||
|
for (i = 0; i < incount; i++)
|
||||||
|
VectorCopy((inverts+i*C), (outverts+i*C));
|
||||||
|
return incount;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < incount; i++)
|
||||||
|
{
|
||||||
|
p1 = inverts+i*C;
|
||||||
|
if (keep[i] == KEEP_BORDER)
|
||||||
|
{
|
||||||
|
out = outverts+outcount++*C;
|
||||||
|
VectorCopy(p1, out);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (keep[i] == KEEP_KEEP)
|
||||||
|
{
|
||||||
|
out = outverts+outcount++*C;
|
||||||
|
VectorCopy(p1, out);
|
||||||
|
}
|
||||||
|
if (keep[i+1] == KEEP_BORDER || keep[i] == keep[i+1])
|
||||||
|
continue;
|
||||||
|
p2 = inverts+((i+1)%incount)*C;
|
||||||
|
d = dotv[i] - dotv[i+1];
|
||||||
|
if (d)
|
||||||
|
d = dotv[i] / d;
|
||||||
|
|
||||||
|
out = outverts+outcount++*C;
|
||||||
|
VectorInterpolate(p1, d, p2, out);
|
||||||
|
}
|
||||||
|
return outcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
========================
|
||||||
|
|
||||||
Rendering functions (Client only)
|
Rendering functions (Client only)
|
||||||
*/
|
*/
|
||||||
#ifndef SERVERONLY
|
#ifndef SERVERONLY
|
||||||
|
@ -1216,73 +1289,6 @@ static void Fragment_ClipTriangle(fragmentdecal_t *dec, float *a, float *b, floa
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define MAXFRAGMENTVERTS 360
|
|
||||||
int Fragment_ClipPolyToPlane(float *inverts, float *outverts, int incount, float *plane, float planedist)
|
|
||||||
{
|
|
||||||
#define C 4
|
|
||||||
float dotv[MAXFRAGMENTVERTS+1];
|
|
||||||
char keep[MAXFRAGMENTVERTS+1];
|
|
||||||
#define KEEP_KILL 0
|
|
||||||
#define KEEP_KEEP 1
|
|
||||||
#define KEEP_BORDER 2
|
|
||||||
int i;
|
|
||||||
int outcount = 0;
|
|
||||||
int clippedcount = 0;
|
|
||||||
float d, *p1, *p2, *out;
|
|
||||||
#define FRAG_EPSILON 0.5
|
|
||||||
|
|
||||||
for (i = 0; i < incount; i++)
|
|
||||||
{
|
|
||||||
dotv[i] = DotProduct((inverts+i*C), plane) - planedist;
|
|
||||||
if (dotv[i]<-FRAG_EPSILON)
|
|
||||||
{
|
|
||||||
keep[i] = KEEP_KILL;
|
|
||||||
clippedcount++;
|
|
||||||
}
|
|
||||||
else if (dotv[i] > FRAG_EPSILON)
|
|
||||||
keep[i] = KEEP_KEEP;
|
|
||||||
else
|
|
||||||
keep[i] = KEEP_BORDER;
|
|
||||||
}
|
|
||||||
dotv[i] = dotv[0];
|
|
||||||
keep[i] = keep[0];
|
|
||||||
|
|
||||||
if (clippedcount == incount)
|
|
||||||
return 0; //all were clipped
|
|
||||||
if (clippedcount == 0)
|
|
||||||
{ //none were clipped
|
|
||||||
for (i = 0; i < incount; i++)
|
|
||||||
VectorCopy((inverts+i*C), (outverts+i*C));
|
|
||||||
return incount;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < incount; i++)
|
|
||||||
{
|
|
||||||
p1 = inverts+i*C;
|
|
||||||
if (keep[i] == KEEP_BORDER)
|
|
||||||
{
|
|
||||||
out = outverts+outcount++*C;
|
|
||||||
VectorCopy(p1, out);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (keep[i] == KEEP_KEEP)
|
|
||||||
{
|
|
||||||
out = outverts+outcount++*C;
|
|
||||||
VectorCopy(p1, out);
|
|
||||||
}
|
|
||||||
if (keep[i+1] == KEEP_BORDER || keep[i] == keep[i+1])
|
|
||||||
continue;
|
|
||||||
p2 = inverts+((i+1)%incount)*C;
|
|
||||||
d = dotv[i] - dotv[i+1];
|
|
||||||
if (d)
|
|
||||||
d = dotv[i] / d;
|
|
||||||
|
|
||||||
out = outverts+outcount++*C;
|
|
||||||
VectorInterpolate(p1, d, p2, out);
|
|
||||||
}
|
|
||||||
return outcount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Fragment_ClipPoly(fragmentdecal_t *dec, int numverts, float *inverts)
|
void Fragment_ClipPoly(fragmentdecal_t *dec, int numverts, float *inverts)
|
||||||
{
|
{
|
||||||
//emit the triangle, and clip it's fragments.
|
//emit the triangle, and clip it's fragments.
|
||||||
|
|
|
@ -4794,6 +4794,7 @@ size_t Terr_GenerateBrushFace(vecV_t *points, size_t maxpoints, vec4_t *planes,
|
||||||
return numverts;
|
return numverts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef SERVERONLY
|
||||||
void Terr_Brush_Draw(heightmap_t *hm, batch_t **batches, entity_t *e)
|
void Terr_Brush_Draw(heightmap_t *hm, batch_t **batches, entity_t *e)
|
||||||
{
|
{
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
|
@ -4909,6 +4910,7 @@ void Terr_Brush_Draw(heightmap_t *hm, batch_t **batches, entity_t *e)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
brushtex_t *Terr_Brush_FindTexture(heightmap_t *hm, char *texname)
|
brushtex_t *Terr_Brush_FindTexture(heightmap_t *hm, char *texname)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue