forked from TTimo/bspc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aas_edgemelting.c
125 lines (109 loc) · 4.52 KB
/
aas_edgemelting.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
===========================================================================
Return to Castle Wolfenstein single player GPL Source Code
Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company.
This file is part of the Return to Castle Wolfenstein single player GPL Source Code (RTCW SP Source Code).
RTCW SP Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
RTCW SP Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with RTCW SP Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the RTCW SP Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the RTCW SP Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
//===========================================================================
//
// Name: aas_edgemelting.c
// Function: Melting of Edges
// Programmer: Mr Elusive (MrElusive@demigod.demon.nl)
// Last update: 1997-12-04
// Tab Size: 3
//===========================================================================
#include "qbsp.h"
#include "botlib/aasfile.h"
#include "aas_create.h"
//===========================================================================
// try to melt the windings of the two faces
// FIXME: this is buggy
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int AAS_MeltFaceWinding( tmp_face_t *face1, tmp_face_t *face2 ) {
int i, n;
int splits = 0;
winding_t *w2, *neww;
plane_t *plane1;
#ifdef DEBUG
if ( !face1->winding ) {
Error( "face1 %d without winding", face1->num );
}
if ( !face2->winding ) {
Error( "face2 %d without winding", face2->num );
}
#endif //DEBUG
w2 = face2->winding;
plane1 = &mapplanes[face1->planenum];
for ( i = 0; i < w2->numpoints; i++ )
{
if ( PointOnWinding( face1->winding, plane1->normal, plane1->dist, w2->p[i], &n ) ) {
neww = AddWindingPoint( face1->winding, w2->p[i], n );
FreeWinding( face1->winding );
face1->winding = neww;
splits++;
} //end if
} //end for
return splits;
} //end of the function AAS_MeltFaceWinding
//===========================================================================
// melt the windings of the area faces
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
int AAS_MeltFaceWindingsOfArea( tmp_area_t *tmparea ) {
int side1, side2, num_windingsplits = 0;
tmp_face_t *face1, *face2;
for ( face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1] )
{
side1 = face1->frontarea != tmparea;
for ( face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2] )
{
side2 = face2->frontarea != tmparea;
if ( face1 == face2 ) {
continue;
}
num_windingsplits += AAS_MeltFaceWinding( face1, face2 );
} //end for
} //end for
return num_windingsplits;
} //end of the function AAS_MeltFaceWindingsOfArea
//===========================================================================
// melt the windings of the faces of all areas
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void AAS_MeltAreaFaceWindings( void ) {
tmp_area_t *tmparea;
int num_windingsplits = 0;
Log_Write( "AAS_MeltAreaFaceWindings\r\n" );
qprintf( "%6d edges melted", num_windingsplits );
//NOTE: first convex area (zero) is a dummy
for ( tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next )
{
num_windingsplits += AAS_MeltFaceWindingsOfArea( tmparea );
qprintf( "\r%6d", num_windingsplits );
} //end for
qprintf( "\n" );
Log_Write( "%6d edges melted\r\n", num_windingsplits );
} //end of the function AAS_MeltAreaFaceWindings