UFO: Alien Invasion
Loading...
Searching...
No Matches
polylib.cpp File Reference
#include "polylib.h"
#include "shared.h"
Include dependency graph for polylib.cpp:

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).
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.
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.
bool WindingIsHuge (const winding_t *w)
 Returns true if the winding still has one of the points from basewinding for plane.
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
bool FixWinding (winding_t *w)
 removes degenerate edges from a winding

Detailed Description

Note
Winding = Polyon representation of brushes

Definition in file polylib.cpp.

Macro Definition Documentation

◆ BOGUS_RANGE

#define BOGUS_RANGE   8192

Definition at line 31 of file polylib.cpp.

Referenced by BaseWindingForPlane().

◆ EDGE_LENGTH

#define EDGE_LENGTH   0.2

Definition at line 402 of file polylib.cpp.

Referenced by WindingIsTiny().

◆ SNAP_EPSILON

#define SNAP_EPSILON   0.01

Definition at line 437 of file polylib.cpp.

Referenced by SnapWeldVector().

Function Documentation

◆ AllocWinding()

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().

◆ BaseWindingForPlane()

◆ ChopWinding()

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.

◆ ChopWindingInPlace()

◆ ClipWindingEpsilon()

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

◆ CopyWinding()

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_t::numpoints.

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

◆ FixWinding()

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_t::numpoints, ON_EPSILON, winding_t::p, SnapWeldVector(), VectorCopy, VectorLength(), and VectorSubtract.

Referenced by CreateBrushWindings().

◆ FreeWinding()

void FreeWinding ( winding_t * w)

◆ RemoveColinearPoints()

void RemoveColinearPoints ( winding_t * w)

◆ ReverseWinding()

winding_t * ReverseWinding ( const winding_t * w)

Definition at line 193 of file polylib.cpp.

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

Referenced by FaceFromPortal().

◆ SnapWeldVector()

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().

◆ WindingArea()

◆ WindingBounds()

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_t::numpoints, and winding_t::p.

Referenced by SubdividePatch().

◆ WindingCenter()

void WindingCenter ( const winding_t * w,
vec3_t center )

◆ WindingIsHuge()

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_t::numpoints, and winding_t::p.

Referenced by SplitBrush().

◆ WindingIsTiny()

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_t::numpoints, winding_t::p, VectorLength(), and VectorSubtract.

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