MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / CalculateAreaForElement

Function CalculateAreaForElement

editor/rad_init.cpp:148–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void CalculateAreaForElement(rad_element *ep) {
149 int i;
150
151 vector normal;
152
153 if (ep->flags & EF_IGNORE) {
154 ep->area = .0000001f;
155 return;
156 }
157
158 vm_GetPerp(&normal, &ep->verts[0], &ep->verts[1], &ep->verts[2]);
159 ep->area = (vm_GetMagnitude(&normal) / 2);
160
161 for (i = 2; i < ep->num_verts - 1; i++) {
162 vm_GetPerp(&normal, &ep->verts[0], &ep->verts[i], &ep->verts[i + 1]);
163 ep->area += (vm_GetMagnitude(&normal) / 2);
164 }
165
166 if (ep->area < .05)
167 ep->flags |= EF_SMALL;
168 if (ep->area == 0) {
169 ep->flags |= EF_IGNORE;
170 ep->area = .00000001f;
171 }
172}
173
174// Calculates the area of the surfaces and elements in our environment
175void CalculateArea() {

Callers 1

CalculateAreaFunction · 0.85

Calls 2

vm_GetPerpFunction · 0.50
vm_GetMagnitudeFunction · 0.50

Tested by

no test coverage detected