29 #include "../precompiled.h"
50 bevel.
z = - ( point.
x * bevel.
x + point.
y * bevel.
y );
63 bevel.
z = - ( point.
x * bevel.
x + point.
y * bevel.
y );
81 for ( numPlanes = i = 0; i <
numPoints; i++ ) {
82 j = (i+1) % numPoints;
83 if ( (
p[j] -
p[i] ).LengthSqr() < 0.01f ) {
89 planes[numPlanes++] = bevel;
93 planes[numPlanes++] = plane;
95 if (
GetAxialBevel( planes[numPlanes-1], planes[0],
p[0], bevel ) ) {
96 planes[numPlanes++] = bevel;
100 for ( i = 0; i < numPlanes; i++ ) {
103 planes[
i].
z += v.
x * planes[
i].
x + v.
y * planes[
i].
y;
107 for ( numPoints = i = 0; i < numPlanes; i++ ) {
126 edgeNormals[
i].
x = start.
y - end.
y;
127 edgeNormals[
i].
y = end.
x - start.
x;
133 p[
i] += edgeNormals[
i] + edgeNormals[(i+numPoints-1)%numPoints];
154 counts[0] = counts[1] = counts[2] = 0;
158 dists[
i] = dot = plane.
x *
p[
i].x + plane.
y *
p[
i].y + plane.
z;
159 if ( dot > epsilon ) {
161 }
else if ( dot < -epsilon ) {
171 *front = *back =
NULL;
184 maxpts = numPoints+4;
200 if ( sides[i] == SIDE_FRONT ) {
205 if ( sides[i] == SIDE_BACK ) {
210 if ( sides[i+1] ==
SIDE_ON || sides[i+1] == sides[i] ) {
215 p2 = &
p[(i+1)%numPoints];
219 if ( sides[i] == SIDE_FRONT ) {
220 dot = dists[
i] / ( dists[
i] - dists[i+1] );
221 for ( j = 0; j < 2; j++ ) {
223 if ( plane[j] == 1.0f ) {
225 }
else if ( plane[j] == -1.0f ) {
228 mid[
j] = (*p1)[
j] + dot * ((*p2)[
j] - (*p1)[
j]);
232 dot = dists[i+1] / ( dists[i+1] - dists[
i] );
233 for ( j = 0; j < 2; j++ ) {
235 if ( plane[j] == 1.0f ) {
237 }
else if ( plane[j] == -1.0f ) {
240 mid[
j] = (*p2)[
j] + dot * ( (*p1)[
j] - (*p2)[
j] );
260 int i,
j, maxpts, newNumPoints;
268 dists[
i] = dot = plane.
x *
p[
i].x + plane.
y *
p[
i].y + plane.
z;
269 if ( dot > epsilon ) {
271 }
else if ( dot < -epsilon ) {
289 if ( !counts[SIDE_BACK] ) {
293 maxpts = numPoints + 4;
299 if ( newNumPoints+1 > maxpts ) {
304 newPoints[newNumPoints] = *p1;
309 if ( sides[i] == SIDE_FRONT ) {
310 newPoints[newNumPoints] = *p1;
314 if ( sides[i+1] ==
SIDE_ON || sides[i+1] == sides[i] ) {
318 if ( newNumPoints+1 > maxpts ) {
323 p2 = &
p[(i+1)%numPoints];
325 dot = dists[
i] / (dists[
i] - dists[i+1]);
326 for ( j = 0; j < 2; j++ ) {
328 if ( plane[j] == 1.0
f ) {
330 }
else if ( plane[j] == -1.0
f ) {
333 mid[
j] = (*p1)[
j] + dot * ((*p2)[
j] - (*p1)[
j]);
337 newPoints[newNumPoints] = mid;
345 numPoints = newNumPoints;
346 memcpy(
p, newPoints, newNumPoints *
sizeof(
idVec2) );
377 w->
p[ numPoints - i - 1 ] =
p[
i];
396 total += d1.
x * d2.
y - d1.
y * d2.
x;
452 bounds[0] = bounds[1] =
p[0];
454 if (
p[i].
x < bounds[0].
x ) {
455 bounds[0].
x =
p[
i].x;
456 }
else if (
p[i].x > bounds[1].x ) {
457 bounds[1].
x =
p[
i].x;
459 if (
p[i].
y < bounds[0].
y ) {
460 bounds[0].
y =
p[
i].y;
461 }
else if (
p[i].y > bounds[1].y ) {
462 bounds[1].
y =
p[
i].y;
472 #define EDGE_LENGTH 0.2f
482 delta =
p[(i+1)%numPoints] -
p[i];
485 if ( ++edges == 3 ) {
502 for ( j = 0; j < 2; j++ ) {
536 d = plane.
x *
p[
i].x + plane.
y *
p[
i].y + plane.
z;
572 d = plane.
x *
p[
i].x + plane.
y *
p[
i].y + plane.
z;
573 if ( d < -epsilon ) {
580 else if ( d > epsilon ) {
610 d = plane.
x * point.
x + plane.
y * point.
y + plane.
z;
626 float d1, d2, epsilon = 0.1f;
633 d1 = plane.
x *
p[
i].x + plane.
y *
p[
i].y + plane.
z;
634 if ( d1 > epsilon ) {
637 else if ( d1 < -epsilon ) {
656 if ( sides[i] != sides[i+1] && sides[i+1] !=
SIDE_ON ) {
658 if ( numEdges >= 2 ) {
663 if ( numEdges < 2 ) {
667 d1 = edges[0].
x * start.
x + edges[0].
y * start.
y + edges[0].
z;
668 d2 = edges[0].
x * end.
x + edges[0].
y * end.
y + edges[0].
z;
672 d1 = edges[1].
x * start.
x + edges[1].
y * start.
y + edges[1].
z;
673 d2 = edges[1].
x * end.
x + edges[1].
y * end.
y + edges[1].
z;
686 int i, numEdges, localEdgeNums[2];
688 float d1, d2, epsilon = 0.1f;
691 scale1 = scale2 = 0.0f;
696 d1 = plane.
x *
p[
i].x + plane.
y *
p[
i].y + plane.
z;
697 if ( d1 > epsilon ) {
700 else if ( d1 < -epsilon ) {
719 if ( sides[i] != sides[i+1] && sides[i+1] !=
SIDE_ON ) {
720 localEdgeNums[numEdges] =
i;
722 if ( numEdges >= 2 ) {
727 if ( numEdges < 2 ) {
731 d1 = edges[0].
x * start.
x + edges[0].
y * start.
y + edges[0].
z;
732 d2 = - ( edges[0].
x * dir.
x + edges[0].
y * dir.
y );
737 d1 = edges[1].
x * start.
x + edges[1].
y * start.
y + edges[1].
z;
738 d2 = - ( edges[1].
x * dir.
x + edges[1].
y * dir.
y );
746 idSwap( localEdgeNums[0], localEdgeNums[1] );
750 edgeNums[0] = localEdgeNums[0];
751 edgeNums[1] = localEdgeNums[1];
static const float INFINITY
float GetArea(void) const
assert(prefInfo.fullscreenBtn)
void Expand(const float d)
static bool Plane2DIntersection(const idVec3 &plane1, const idVec3 &plane2, idVec2 &point)
int PlaneSide(const idVec3 &plane, const float epsilon=ON_EPSILON) const
static float Sqrt(float x)
float PlaneDistance(const idVec3 &plane) const
idVec2 p[MAX_POINTS_ON_WINDING_2D]
#define FLOATSIGNBITSET(f)
bool PointInside(const idVec2 &point, const float epsilon) const
GLubyte GLubyte GLubyte GLubyte w
int Split(const idVec3 &plane, const float epsilon, idWinding2D **front, idWinding2D **back) const
bool GetAxialBevel(const idVec3 &plane1, const idVec3 &plane2, const idVec2 &point, idVec3 &bevel)
static float Fabs(float f)
idWinding2D * Copy(void) const
static idVec3 Plane2DFromPoints(const idVec2 &start, const idVec2 &end, const bool normalize=false)
void ExpandForAxialBox(const idVec2 bounds[2])
idVec2 GetCenter(void) const
bool ClipInPlace(const idVec3 &plane, const float epsilon=ON_EPSILON, const bool keepOn=false)
virtual void Printf(const char *fmt,...) id_attribute((format(printf
ID_INLINE void idSwap(type &a, type &b)
float GetRadius(const idVec2 ¢er) const
bool RayIntersection(const idVec2 &start, const idVec2 &dir, float &scale1, float &scale2, int *edgeNums=NULL) const
#define MAX_POINTS_ON_WINDING_2D
GLdouble GLdouble GLdouble r
void GetBounds(idVec2 bounds[2]) const
#define FLOATSIGNBITNOTSET(f)
bool LineIntersection(const idVec2 &start, const idVec2 &end) const
float dot(float a[], float b[])
idWinding2D * Reverse(void) const
static idVec3 Plane2DFromVecs(const idVec2 &start, const idVec2 &dir, const bool normalize=false)
static class idCommon * common