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

Function RenderLightmapFace

Descent3/render.cpp:1647–1718  ·  view source on GitHub ↗

Draw the specified face Parameters: rp - pointer to the room the face is un facenum - which face in the specified room

Source from the content-addressed store, hash-verified

1645// Parameters: rp - pointer to the room the face is un
1646// facenum - which face in the specified room
1647void RenderLightmapFace(room *rp, int facenum) {
1648 int vn, drawn = 0;
1649 face *fp = &rp->faces[facenum];
1650 g3Point *pointlist[MAX_VERTS_PER_FACE];
1651 g3Point pointbuffer[MAX_VERTS_PER_FACE];
1652 uint8_t face_code = 255;
1653 if (NoLightmaps)
1654 return;
1655 if (fp->lmi_handle == BAD_LMI_INDEX)
1656 return;
1657 if (!(fp->flags & FF_LIGHTMAP))
1658 return;
1659 // check for render windows hack
1660 if (No_render_windows_hack == 1) {
1661 if (fp->portal_num != -1)
1662 return;
1663 }
1664 if (GameTextures[fp->tmap].flags & TF_SATURATE)
1665 return;
1666#ifdef EDITOR
1667 if (In_editor_mode && !Lighting_on)
1668 return;
1669#endif
1670 int lm_handle = LightmapInfo[fp->lmi_handle].lm_handle;
1671 // Setup saturation if needed
1672 if (GameTextures[fp->tmap].flags & TF_SATURATE_LIGHTMAP)
1673 rend_SetAlphaType(AT_LIGHTMAP_BLEND_SATURATE);
1674 // Our lightmaps aren't square, but our destination texture surfaces are
1675 // Use these scalars to get them into the correct coordinates
1676 float xscalar = (float)GameLightmaps[lm_handle].width / (float)GameLightmaps[lm_handle].square_res;
1677 float yscalar = (float)GameLightmaps[lm_handle].height / (float)GameLightmaps[lm_handle].square_res;
1678 if (!Render_mirror_for_room) {
1679 for (vn = 0; vn < fp->num_verts; vn++) {
1680 pointbuffer[vn] = World_point_buffer[rp->wpb_index + fp->face_verts[vn]];
1681 g3Point *p = &pointbuffer[vn];
1682 pointlist[vn] = p;
1683 p->p3_uvl.u = fp->face_uvls[vn].u2 * xscalar;
1684 p->p3_uvl.v = fp->face_uvls[vn].v2 * yscalar;
1685
1686 p->p3_flags |= PF_UV + PF_L + PF_RGBA; // has uv and l set
1687 p->p3_uvl.l = 1.0;
1688
1689 face_code &= p->p3_codes;
1690 }
1691 } else {
1692 for (vn = 0; vn < fp->num_verts; vn++) {
1693 pointbuffer[vn] = World_point_buffer[rp->wpb_index + fp->face_verts[vn]];
1694 g3Point *p = &pointbuffer[vn];
1695 pointlist[(fp->num_verts - 1) - vn] = p;
1696 p->p3_uvl.u = fp->face_uvls[vn].u2 * xscalar;
1697 p->p3_uvl.v = fp->face_uvls[vn].v2 * yscalar;
1698
1699 p->p3_flags |= PF_UV + PF_L + PF_RGBA; // has uv and l set
1700 p->p3_uvl.l = 1.0;
1701
1702 face_code &= p->p3_codes;
1703 }
1704 }

Callers 1

RenderRoomUnsortedFunction · 0.85

Calls 4

g3_SetTriangulationTestFunction · 0.85
g3_DrawPolyFunction · 0.85
rend_SetAlphaTypeFunction · 0.50
rend_SetAlphaValueFunction · 0.50

Tested by

no test coverage detected