UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
polylib.cpp File Reference
#include "polylib.h"
#include "shared.h"

Go to the source code of this file.

Macros

#define BOGUS_RANGE   8192
 
#define EDGE_LENGTH   0.2
 
#define SNAP_EPSILON   0.01
 

Functions

winding_tAllocWinding (int points)
 Allocate a new winding (polygon) More...
 
void FreeWinding (winding_t *w)
 
void RemoveColinearPoints (winding_t *w)
 
vec_t WindingArea (const winding_t *w)
 
void WindingBounds (const winding_t *w, vec3_t mins, vec3_t maxs)
 
void WindingCenter (const winding_t *w, vec3_t center)
 
winding_tBaseWindingForPlane (const vec3_t normal, const vec_t dist)
 
winding_tCopyWinding (const winding_t *w)
 Copy a winding with all its points allocated. More...
 
winding_tReverseWinding (const winding_t *w)
 
void ClipWindingEpsilon (const winding_t *in, const vec3_t normal, const vec_t dist, const vec_t epsilon, winding_t **front, winding_t **back)
 
void ChopWindingInPlace (winding_t **inout, const vec3_t normal, const vec_t dist, const vec_t epsilon)
 
winding_tChopWinding (winding_t *in, vec3_t normal, vec_t dist)
 
bool WindingIsTiny (winding_t *w)
 Returns true if the winding would be crunched out of existance by the vertex snapping. More...
 
bool WindingIsHuge (const winding_t *w)
 Returns true if the winding still has one of the points from basewinding for plane. More...
 
static void SnapWeldVector (const vec3_t a, const vec3_t b, vec3_t out)
 welds two vec3_t's into a third, taking into account nearest-to-integer instead of averaging More...
 
bool FixWinding (winding_t *w)
 removes degenerate edges from a winding More...
 

Detailed Description

Note
Winding = Polyon representation of brushes

Definition in file polylib.cpp.

Macro Definition Documentation

#define BOGUS_RANGE   8192

Definition at line 31 of file polylib.cpp.

Referenced by BaseWindingForPlane().

#define EDGE_LENGTH   0.2

Definition at line 402 of file polylib.cpp.

Referenced by WindingIsTiny().

#define SNAP_EPSILON   0.01

Definition at line 437 of file polylib.cpp.

Referenced by SnapWeldVector().

Function Documentation

winding_t* AllocWinding ( int  points)

Allocate a new winding (polygon)

Parameters
[in]pointsAmount of points for this winding
See also
FreeWinding

Definition at line 38 of file polylib.cpp.

References Mem_Alloc.

Referenced by BaseWindingForPlane(), Check_SidesOverlap(), ChopWindingInPlace(), ClipWindingEpsilon(), CopyWinding(), ReverseWinding(), TryMergeWinding(), and WindingFromFace().

winding_t* ChopWinding ( winding_t in,
vec3_t  normal,
vec_t  dist 
)
Returns
the fragment of in that is on the front side of the cliping plane.
Note
The original is freed.

Definition at line 391 of file polylib.cpp.

References ClipWindingEpsilon(), f, FreeWinding(), and ON_EPSILON.

void ClipWindingEpsilon ( const winding_t in,
const vec3_t  normal,
const vec_t  dist,
const vec_t  epsilon,
winding_t **  front,
winding_t **  back 
)
winding_t* CopyWinding ( const winding_t w)

Copy a winding with all its points allocated.

Parameters
[in]wThe winding to copy
Returns
the new winding

Definition at line 185 of file polylib.cpp.

References AllocWinding(), and winding_s::numpoints.

Referenced by ClipWindingEpsilon(), CopyBrush(), FaceFromPortal(), MakeBspBrushList(), and SplitBrush().

bool FixWinding ( winding_t w)

removes degenerate edges from a winding

Returns
true if the winding is valid

Definition at line 478 of file polylib.cpp.

References i, winding_s::numpoints, ON_EPSILON, winding_s::p, SnapWeldVector(), VectorCopy, VectorLength(), and VectorSubtract.

Referenced by CreateBrushWindings().

void FreeWinding ( winding_t w)
void RemoveColinearPoints ( winding_t w)
winding_t* ReverseWinding ( const winding_t w)

Definition at line 193 of file polylib.cpp.

References AllocWinding(), i, winding_s::numpoints, winding_s::p, and VectorCopy.

Referenced by FaceFromPortal().

static void SnapWeldVector ( const vec3_t  a,
const vec3_t  b,
vec3_t  out 
)
static

welds two vec3_t's into a third, taking into account nearest-to-integer instead of averaging

Definition at line 443 of file polylib.cpp.

References i, and SNAP_EPSILON.

Referenced by FixWinding().

void WindingBounds ( const winding_t w,
vec3_t  mins,
vec3_t  maxs 
)

Definition at line 97 of file polylib.cpp.

References AddPointToBounds(), ClearBounds(), i, winding_s::numpoints, and winding_s::p.

Referenced by SubdividePatch().

void WindingCenter ( const winding_t w,
vec3_t  center 
)
bool WindingIsHuge ( const winding_t w)

Returns true if the winding still has one of the points from basewinding for plane.

Definition at line 427 of file polylib.cpp.

References i, MAX_WORLD_WIDTH, winding_s::numpoints, and winding_s::p.

Referenced by SplitBrush().

bool WindingIsTiny ( winding_t w)

Returns true if the winding would be crunched out of existance by the vertex snapping.

Definition at line 407 of file polylib.cpp.

References EDGE_LENGTH, i, len, winding_s::numpoints, winding_s::p, VectorLength(), and VectorSubtract.

Referenced by MakeNodePortal(), SplitBrush(), and SplitNodePortals().