| 2743 | static int Instance_light_cnt = 0; |
| 2744 | |
| 2745 | void StartLightInstance(vector *pos, matrix *orient) { |
| 2746 | int gouraud = 0, specular = 0, fogged = 0, bumped = 0; |
| 2747 | |
| 2748 | if (Polymodel_light_type == POLYMODEL_LIGHTING_GOURAUD) |
| 2749 | gouraud = 1; |
| 2750 | if (Polymodel_use_effect && Polymodel_effect.type & PEF_FOGGED_MODEL) |
| 2751 | fogged = 1; |
| 2752 | if (Polymodel_use_effect && Polymodel_effect.type & (PEF_SPECULAR_MODEL | PEF_SPECULAR_FACES)) |
| 2753 | specular = 1; |
| 2754 | if (Polymodel_use_effect && (Polymodel_effect.type & PEF_BUMPMAPPED)) |
| 2755 | bumped = 1; |
| 2756 | |
| 2757 | if (gouraud) |
| 2758 | Instance_light_stack[Instance_light_cnt] = *Polymodel_light_direction; |
| 2759 | if (fogged) { |
| 2760 | Instance_fog_plane_stack[Instance_light_cnt] = Polymodel_fog_plane; |
| 2761 | Instance_fog_portal_vert_stack[Instance_light_cnt] = Polymodel_fog_portal_vert; |
| 2762 | } |
| 2763 | |
| 2764 | if (specular) |
| 2765 | Instance_specular_pos[Instance_light_cnt] = Polymodel_specular_pos; |
| 2766 | |
| 2767 | if (bumped) |
| 2768 | Instance_bump_pos[Instance_light_cnt] = Polymodel_bump_pos; |
| 2769 | |
| 2770 | Instance_light_cnt++; |
| 2771 | |
| 2772 | vector temp_vec; |
| 2773 | |
| 2774 | if (gouraud) { |
| 2775 | vm_MatrixMulVector(&temp_vec, Polymodel_light_direction, orient); |
| 2776 | *Polymodel_light_direction = temp_vec; |
| 2777 | } |
| 2778 | if (fogged) { |
| 2779 | vector tempv = Polymodel_fog_portal_vert - *pos; |
| 2780 | vm_MatrixMulVector(&temp_vec, &tempv, orient); |
| 2781 | Polymodel_fog_portal_vert = temp_vec; |
| 2782 | |
| 2783 | vm_MatrixMulVector(&temp_vec, &Polymodel_fog_plane, orient); |
| 2784 | Polymodel_fog_plane = temp_vec; |
| 2785 | } |
| 2786 | if (specular) { |
| 2787 | vector tempv = Polymodel_specular_pos - *pos; |
| 2788 | vm_MatrixMulVector(&temp_vec, &tempv, orient); |
| 2789 | Polymodel_specular_pos = temp_vec; |
| 2790 | } |
| 2791 | |
| 2792 | if (bumped) { |
| 2793 | vector tempv = Polymodel_bump_pos - *pos; |
| 2794 | vm_MatrixMulVector(&temp_vec, &tempv, orient); |
| 2795 | Polymodel_bump_pos = temp_vec; |
| 2796 | } |
| 2797 | } |
| 2798 | void DoneLightInstance() { |
| 2799 | ASSERT(Instance_light_cnt != 0); |
| 2800 | Instance_light_cnt--; |
no test coverage detected