00001 /* 00002 =========================================================================== 00003 Copyright (C) 1999-2005 Id Software, Inc. 00004 00005 This file is part of Quake III Arena source code. 00006 00007 Quake III Arena source code is free software; you can redistribute it 00008 and/or modify it under the terms of the GNU General Public License as 00009 published by the Free Software Foundation; either version 2 of the License, 00010 or (at your option) any later version. 00011 00012 Quake III Arena source code is distributed in the hope that it will be 00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Foobar; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 =========================================================================== 00021 */ 00022 00023 //a winding gives the bounding points of a convex polygon 00024 typedef struct 00025 { 00026 int numpoints; 00027 vec3_t p[4]; //variable sized 00028 } winding_t; 00029 00030 #define MAX_POINTS_ON_WINDING 96 00031 00032 //you can define on_epsilon in the makefile as tighter 00033 #ifndef ON_EPSILON 00034 #define ON_EPSILON 0.1 00035 #endif 00036 //winding errors 00037 #define WE_NONE 0 00038 #define WE_NOTENOUGHPOINTS 1 00039 #define WE_SMALLAREA 2 00040 #define WE_POINTBOGUSRANGE 3 00041 #define WE_POINTOFFPLANE 4 00042 #define WE_DEGENERATEEDGE 5 00043 #define WE_NONCONVEX 6 00044 00045 //allocates a winding 00046 winding_t *AllocWinding (int points); 00047 //returns the area of the winding 00048 vec_t WindingArea (winding_t *w); 00049 //gives the center of the winding 00050 void WindingCenter (winding_t *w, vec3_t center); 00051 //clips the given winding to the given plane and gives the front 00052 //and back part of the clipped winding 00053 void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, 00054 vec_t epsilon, winding_t **front, winding_t **back); 00055 //returns the fragment of the given winding that is on the front 00056 //side of the cliping plane. The original is freed. 00057 winding_t *ChopWinding (winding_t *in, vec3_t normal, vec_t dist); 00058 //returns a copy of the given winding 00059 winding_t *CopyWinding (winding_t *w); 00060 //returns the reversed winding of the given one 00061 winding_t *ReverseWinding (winding_t *w); 00062 //returns a base winding for the given plane 00063 winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist); 00064 //checks the winding for errors 00065 void CheckWinding (winding_t *w); 00066 //returns the plane normal and dist the winding is in 00067 void WindingPlane(winding_t *w, vec3_t normal, vec_t *dist); 00068 //removes colinear points from the winding 00069 void RemoveColinearPoints(winding_t *w); 00070 //returns on which side of the plane the winding is situated 00071 int WindingOnPlaneSide(winding_t *w, vec3_t normal, vec_t dist); 00072 //frees the winding 00073 void FreeWinding(winding_t *w); 00074 //gets the bounds of the winding 00075 void WindingBounds(winding_t *w, vec3_t mins, vec3_t maxs); 00076 //chops the winding with the given plane, the original winding is freed if clipped 00077 void ChopWindingInPlace (winding_t **w, vec3_t normal, vec_t dist, vec_t epsilon); 00078 //prints the winding points on STDOUT 00079 void pw(winding_t *w); 00080 //try to merge the two windings which are in the given plane 00081 //the original windings are undisturbed 00082 //the merged winding is returned when merging was possible 00083 //NULL is returned otherwise 00084 winding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal); 00085 //brute force winding merging... creates a convex winding out of 00086 //the two whatsoever 00087 winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal); 00088 00089 //#ifdef ME 00090 void ResetWindings(void); 00091 //returns the amount of winding memory 00092 int WindingMemory(void); 00093 int WindingPeakMemory(void); 00094 int ActiveWindings(void); 00095 //returns the winding error string 00096 char *WindingErrorString(void); 00097 //returns one of the WE_ flags when the winding has errors 00098 int WindingError(winding_t *w); 00099 //removes equal points from the winding 00100 void RemoveEqualPoints(winding_t *w, float epsilon); 00101 //returns a winding with a point added at the given spot to the 00102 //given winding, original winding is NOT freed 00103 winding_t *AddWindingPoint(winding_t *w, vec3_t point, int spot); 00104 //returns true if the point is on one of the winding 'edges' 00105 //when the point is on one of the edged the number of the first 00106 //point of the edge is stored in 'spot' 00107 int PointOnWinding(winding_t *w, vec3_t normal, float dist, vec3_t point, int *spot); 00108 //find a plane seperating the two windings 00109 //true is returned when the windings area adjacent 00110 //the seperating plane normal and distance area stored in 'normal' and 'dist' 00111 //this plane will contain both the piece of common edge of the two windings 00112 //and the vector 'dir' 00113 int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, 00114 vec3_t normal, float *dist); 00115 // 00116 int WindingsNonConvex(winding_t *w1, winding_t *w2, 00117 vec3_t normal1, vec3_t normal2, 00118 float dist1, float dist2); 00119 //#endif //ME 00120
1.3.9.1