MCPcopy Create free account
hub / github.com/JACoders/OpenJK / BaseWindingForPlane

Function BaseWindingForPlane

code/qcommon/cm_polylib.cpp:101–165  ·  view source on GitHub ↗

================= BaseWindingForPlane ================= */

Source from the content-addressed store, hash-verified

99=================
100*/
101winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist)
102{
103 int i, x;
104 vec_t max, v;
105 vec3_t org, vright, vup;
106 winding_t *w;
107
108// find the major axis
109
110 max = -MAX_MAP_BOUNDS;
111 x = -1;
112 for (i=0 ; i<3; i++)
113 {
114 v = fabs(normal[i]);
115 if (v > max)
116 {
117 x = i;
118 max = v;
119 }
120 }
121 if (x==-1)
122 Com_Error (ERR_DROP, "BaseWindingForPlane: no axis found");
123
124 VectorCopy (vec3_origin, vup);
125 switch (x)
126 {
127 case 0:
128 case 1:
129 vup[2] = 1;
130 break;
131 case 2:
132 vup[0] = 1;
133 break;
134 }
135
136 v = DotProduct (vup, normal);
137 VectorMA (vup, -v, normal, vup);
138 VectorNormalize2(vup, vup);
139
140 VectorScale (normal, dist, org);
141
142 CrossProduct (vup, normal, vright);
143
144 VectorScale (vup, MAX_MAP_BOUNDS, vup);
145 VectorScale (vright, MAX_MAP_BOUNDS, vright);
146
147// project a really big axis aligned box onto the plane
148 w = AllocWinding (4);
149
150 VectorSubtract (org, vright, w->p[0]);
151 VectorAdd (w->p[0], vup, w->p[0]);
152
153 VectorAdd (org, vright, w->p[1]);
154 VectorAdd (w->p[1], vup, w->p[1]);
155
156 VectorAdd (org, vright, w->p[2]);
157 VectorSubtract (w->p[2], vup, w->p[2]);
158

Callers 2

CM_ValidateFacetFunction · 0.70
CM_AddFacetBevelsFunction · 0.70

Calls 10

VectorCopyFunction · 0.85
DotProductFunction · 0.85
VectorNormalize2Function · 0.85
VectorScaleFunction · 0.85
CrossProductFunction · 0.85
VectorSubtractFunction · 0.85
VectorAddFunction · 0.85
Com_ErrorFunction · 0.70
AllocWindingFunction · 0.70
VectorMAFunction · 0.50

Tested by

no test coverage detected