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

Function RenderSubmodelFacesUnsorted

model/newstyle.cpp:740–894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

738 }
739}
740void RenderSubmodelFacesUnsorted(poly_model *pm, bsp_info *sm) {
741 int i;
742 int modelnum = sm - pm->submodel;
743 int16_t alpha_faces[MAX_FACES_PER_ROOM], num_alpha_faces = 0;
744 int rcount = 0;
745 vector view_pos;
746
747 g3_GetViewPosition(&view_pos);
748 g3_GetUnscaledMatrix(&Unscaled_bumpmap_matrix);
749
750 Specular_view_pos = view_pos;
751 Bump_view_pos = view_pos;
752
753 if (modelnum < 0 || modelnum >= pm->n_models) {
754 Error("Got bad model number %d from polymodel %s!", modelnum, pm->name);
755 return;
756 }
757
758 if (sm->flags & SOF_CUSTOM)
759 rend_SetZBias(-.5);
760
761 for (i = 0; i < sm->num_faces; i++) {
762 vector tempv;
763 polyface *fp = &sm->faces[i];
764 texture *texp;
765
766 // Check to see if this face even faces us!
767 tempv = view_pos - sm->verts[fp->vertnums[0]];
768 if ((tempv * fp->normal) < 0)
769 continue;
770
771 if (fp->texnum != -1) {
772 texp = &GameTextures[pm->textures[fp->texnum]];
773
774 if (texp->flags & TF_ALPHA || texp->flags & TF_SATURATE) {
775 alpha_faces[num_alpha_faces++] = i;
776 continue;
777 }
778 }
779
780 if (StateLimited) {
781 State_elements[rcount].facenum = i;
782 State_elements[rcount].sort_key = pm->textures[fp->texnum];
783 rcount++;
784 } else
785 RenderSubmodelFace(pm, sm, i);
786 }
787
788 if (StateLimited) {
789 SortStates(State_elements, rcount);
790 for (i = rcount - 1; i >= 0; i--) {
791 int facenum = State_elements[i].facenum;
792 RenderSubmodelFace(pm, sm, facenum);
793 }
794
795 if (!NoLightmaps) {
796 if (!UseMultitexture && Polymodel_light_type == POLYMODEL_LIGHTING_LIGHTMAP) {
797 rend_SetAlphaType(AT_LIGHTMAP_BLEND);

Callers 1

RenderSubmodelFunction · 0.85

Calls 15

g3_GetViewPositionFunction · 0.85
g3_GetUnscaledMatrixFunction · 0.85
ErrorFunction · 0.85
RenderSubmodelFaceFunction · 0.85
SortStatesFunction · 0.85
g3_CheckNormalFacingFunction · 0.85
RenderSubmodelFaceFoggedFunction · 0.85
rend_SetZBiasFunction · 0.50
rend_SetAlphaTypeFunction · 0.50
rend_SetLightingFunction · 0.50

Tested by

no test coverage detected