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

Function ClipSurfaceElement

editor/editor_lighting.cpp:1519–1568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1517}
1518
1519void ClipSurfaceElement(vector *surf_verts, rad_element *ep, vector *clip_verts, int nv) {
1520 rad_point src_verts[50];
1521 rad_point dest_verts[50];
1522 rad_point *slist, *dlist;
1523 uint8_t and = 0xff;
1524 uint8_t or = 0;
1525 int i;
1526
1527 ASSERT(nv < 50);
1528
1529 ep->flags = 0;
1530
1531 SetRadClipLines(&clip_verts[0], &clip_verts[1], &clip_verts[2], &clip_verts[3]);
1532
1533 for (i = 0; i < nv; i++) {
1534 src_verts[i].pos = surf_verts[i];
1535 src_verts[i].code = CodeRadPoint(&src_verts[i]);
1536 }
1537
1538 for (i = 0; i < nv; i++) {
1539 and &= src_verts[i].code;
1540 or |= src_verts[i].code;
1541 }
1542
1543 if (and) {
1544 // This element is not even in the face, ignore it
1545 ep->flags |= EF_IGNORE;
1546 ep->num_verts = 0;
1547 return;
1548 }
1549
1550 int pnv = nv, nnv;
1551 slist = src_verts;
1552 dlist = dest_verts;
1553
1554 nnv = ClipRadPointList(&slist, &dlist, &pnv, or);
1555
1556 ep->num_verts = nnv;
1557
1558 if (ep->num_verts == 0)
1559 ep->flags |= EF_IGNORE;
1560 else {
1561 ep->verts = (vector *)mem_malloc(sizeof(vector) * nnv);
1562 ASSERT(ep->verts);
1563
1564 for (i = 0; i < nnv; i++) {
1565 ep->verts[i] = dlist[i].pos;
1566 }
1567 }
1568}
1569
1570// Takes a points and clips all its viewpoints so they fit into the view frustum
1571// Puts the new clipped list in dest

Callers 2

Calls 3

SetRadClipLinesFunction · 0.85
CodeRadPointFunction · 0.85
ClipRadPointListFunction · 0.85

Tested by

no test coverage detected