| 1016 | } |
| 1017 | |
| 1018 | void RenderSubmodel(poly_model *pm, bsp_info *sm, uint32_t f_render_sub) { |
| 1019 | int i; |
| 1020 | matrix lightmatrix; |
| 1021 | |
| 1022 | // Don't render door housings |
| 1023 | if (IsNonRenderableSubmodel(pm, sm - pm->submodel)) |
| 1024 | return; |
| 1025 | |
| 1026 | if (Polymodel_light_type != POLYMODEL_LIGHTING_LIGHTMAP) { |
| 1027 | // Turn off bumpmapping if not needed |
| 1028 | rend_SetBumpmapReadyState(0, 0); |
| 1029 | } else { |
| 1030 | if (!StateLimited || UseMultitexture) |
| 1031 | rend_SetOverlayType(OT_BLEND); |
| 1032 | } |
| 1033 | |
| 1034 | if (Multicolor_texture == -1 && Polymodel_use_effect && (Polymodel_effect.type & PEF_CUSTOM_COLOR)) |
| 1035 | Multicolor_texture = FindTextureName("MultiColor"); |
| 1036 | |
| 1037 | rend_SetColorModel(CM_RGB); |
| 1038 | StartPolyModelPosInstance(&sm->mod_pos); |
| 1039 | vector temp_vec = sm->mod_pos + sm->offset; |
| 1040 | g3_StartInstanceAngles(&temp_vec, &sm->angs); |
| 1041 | |
| 1042 | vm_AnglesToMatrix(&lightmatrix, sm->angs.p, sm->angs.h, sm->angs.b); |
| 1043 | StartLightInstance(&temp_vec, &lightmatrix); |
| 1044 | |
| 1045 | // Check my bit to see if I get drawn |
| 1046 | if (f_render_sub & (0x00000001 << (sm - pm->submodel))) { |
| 1047 | if (sm->flags & SOF_CUSTOM) { |
| 1048 | if (!(Polymodel_effect.type & PEF_CUSTOM_TEXTURE)) |
| 1049 | goto pop_lighting; |
| 1050 | } |
| 1051 | |
| 1052 | // Check to draw glow faces |
| 1053 | if (sm->flags & (SOF_GLOW | SOF_THRUSTER)) { |
| 1054 | if (!FacingPass) |
| 1055 | goto pop_lighting; |
| 1056 | |
| 1057 | vector zero_pos = {0, 0, 0}; |
| 1058 | rend_SetOverlayType(OT_NONE); |
| 1059 | |
| 1060 | if (Polymodel_use_effect && Polymodel_effect.type & PEF_GLOW_SCALAR) { |
| 1061 | if (Polymodel_effect.type & PEF_CUSTOM_GLOW) |
| 1062 | DrawThrusterEffect(&zero_pos, Polymodel_effect.glow_r, Polymodel_effect.glow_g, Polymodel_effect.glow_b, |
| 1063 | &sm->glow_info->normal, sm->glow_info->glow_size * Polymodel_effect.glow_size_scalar, |
| 1064 | 3 * Polymodel_effect.glow_length_scalar); |
| 1065 | else |
| 1066 | DrawThrusterEffect(&zero_pos, sm->glow_info->glow_r, sm->glow_info->glow_g, sm->glow_info->glow_b, |
| 1067 | &sm->glow_info->normal, sm->glow_info->glow_size * Polymodel_effect.glow_size_scalar, |
| 1068 | 3 * Polymodel_effect.glow_length_scalar); |
| 1069 | } else { |
| 1070 | if (Polymodel_use_effect && Polymodel_effect.type & PEF_CUSTOM_GLOW) |
| 1071 | DrawGlowEffect(&zero_pos, Polymodel_effect.glow_r, Polymodel_effect.glow_g, Polymodel_effect.glow_b, |
| 1072 | &sm->glow_info->normal, sm->glow_info->glow_size); |
| 1073 | else |
| 1074 | DrawGlowEffect(&zero_pos, sm->glow_info->glow_r, sm->glow_info->glow_g, sm->glow_info->glow_b, |
| 1075 | &sm->glow_info->normal, sm->glow_info->glow_size); |
no test coverage detected