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

Function NewPolygon

Descent3/bsp.cpp:162–184  ·  view source on GitHub ↗

Allocates memory for a polygon Returns pointer to polygon

Source from the content-addressed store, hash-verified

160// Allocates memory for a polygon
161// Returns pointer to polygon
162bsppolygon *NewPolygon(int roomnum, int facenum, int numverts) {
163 bsppolygon *newpoly;
164 vector *verts;
165
166 newpoly = (bsppolygon *)mem_malloc(sizeof(bsppolygon));
167
168 if (newpoly == NULL) {
169 mprintf(0, "NewPolygon: Couldn't allocate polygon\n");
170 return NULL;
171 }
172
173 verts = (vector *)mem_malloc(sizeof(vector) * numverts);
174 ASSERT(verts != NULL);
175
176 newpoly->nv = numverts;
177 newpoly->verts = verts;
178
179 newpoly->roomnum = roomnum;
180 newpoly->facenum = facenum;
181 newpoly->color = ps_rand() * ps_rand();
182
183 return newpoly;
184}
185
186// Saves and BSP node to an open file and recurses with the nodes children
187void SaveBSPNode(CFILE *outfile, bspnode *node) {

Callers 3

SplitPolygonFunction · 0.85
BuildBSPTreeFunction · 0.85
BuildSingleBSPTreeFunction · 0.85

Calls 1

ps_randFunction · 0.85

Tested by

no test coverage detected