MCPcopy Create free account
hub / github.com/Meridian59/Meridian59 / InsertPolygon

Function InsertPolygon

roomedit/source/objects.cpp:3272–3335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3270*/
3271
3272void InsertPolygon (SHORT xpos, SHORT ypos, SHORT nsides, SHORT radius)
3273{
3274 SHORT sector;
3275 SHORT n;
3276
3277 // are we inside a Sector?
3278 sector = GetCurObject (OBJ_SECTORS, xpos, ypos, xpos, ypos);
3279
3280 if (nsides < 3) nsides = 3;
3281 if (radius < 8) radius = 8;
3282
3283 // Insert vertices (and new sector)
3284 InsertPolygonVertices (xpos, ypos, nsides, radius);
3285 if (sector < 0)
3286 InsertObject (OBJ_SECTORS, -1, 0, 0);
3287
3288 // Insert the LineDefs
3289 for (n = 0; n < nsides; n++)
3290 {
3291 // Insert LineDef
3292 InsertObject (OBJ_LINEDEFS, -1, 0, 0);
3293
3294 // Insert SideDef1
3295 InsertObject (OBJ_SIDEDEFS, -1, 0, 0);
3296 LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs-1;
3297 if (sector >= 0)
3298 SideDefs[NumSideDefs - 1].sector = sector;
3299 }
3300
3301 // If inside a sector, join LineDef clockwise
3302 if (sector >= 0)
3303 {
3304 LineDef *pLineDef = &LineDefs[NumLineDefs-1];
3305
3306 // Close polygon with last LineDef
3307 pLineDef->start = NumVertexes - 1;
3308 pLineDef->end = NumVertexes - nsides;
3309
3310 // Build polygon with LineDefs
3311 for (n = 2; n <= nsides; n++)
3312 {
3313 pLineDef = &LineDefs[NumLineDefs-n];
3314
3315 pLineDef->start = NumVertexes - n;
3316 pLineDef->end = NumVertexes - n + 1;
3317 }
3318 }
3319 // If outside a sector, join LineDef anti-clockwise
3320 else
3321 {
3322 LineDef *pLineDef = &LineDefs[NumLineDefs-1];
3323
3324 pLineDef->start = NumVertexes - nsides;
3325 pLineDef->end = NumVertexes - 1;
3326
3327 for (n = 2; n <= nsides; n++)
3328 {
3329 pLineDef = &LineDefs[NumLineDefs-n];

Callers 1

CmObjectsPolygonMethod · 0.85

Calls 3

GetCurObjectFunction · 0.85
InsertPolygonVerticesFunction · 0.85
InsertObjectFunction · 0.85

Tested by

no test coverage detected