LEFT | RIGHT |
1 /* | 1 /* |
2 * ***** BEGIN GPL LICENSE BLOCK ***** | 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version. | 7 * of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 else { | 993 else { |
994 /* we need to check if the next material changes
*/ | 994 /* we need to check if the next material changes
*/ |
995 int next_actualFace = dm->drawObject->triangle_t
o_mface[0]; | 995 int next_actualFace = dm->drawObject->triangle_t
o_mface[0]; |
996 ································ | 996 ································ |
997 for (i = 0; i < tottri; i++) { | 997 for (i = 0; i < tottri; i++) { |
998 //int actualFace = dm->drawObject->trian
gle_to_mface[i]; | 998 //int actualFace = dm->drawObject->trian
gle_to_mface[i]; |
999 int actualFace = next_actualFace; | 999 int actualFace = next_actualFace; |
1000 MFace *mface = mf + actualFace; | 1000 MFace *mface = mf + actualFace; |
1001 /*int drawSmooth = (flag & DM_DRAW_ALWAY
S_SMOOTH) ? 1 : (mface->flag & ME_SMOOTH);*/ /* UNUSED */ | 1001 /*int drawSmooth = (flag & DM_DRAW_ALWAY
S_SMOOTH) ? 1 : (mface->flag & ME_SMOOTH);*/ /* UNUSED */ |
1002 DMDrawOption draw_option = DM_DRAW_OPTIO
N_NORMAL; | 1002 DMDrawOption draw_option = DM_DRAW_OPTIO
N_NORMAL; |
| 1003 int flush = 0; |
| 1004 |
| 1005 if (i != tottri - 1) |
| 1006 next_actualFace = dm->drawObject
->triangle_to_mface[i + 1]; |
| 1007 |
| 1008 orig = (index_mf_to_mpoly) ? DM_originde
x_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace) : actualFace; |
| 1009 |
| 1010 if (orig == ORIGINDEX_NONE) |
| 1011 draw_option = setMaterial(mface-
>mat_nr + 1, NULL); |
| 1012 else if (setDrawOptions != NULL) |
| 1013 draw_option = setDrawOptions(use
rData, orig); |
| 1014 |
| 1015 if (draw_option == DM_DRAW_OPTION_STIPPL
E) { |
| 1016 glEnable(GL_POLYGON_STIPPLE); |
| 1017 glPolygonStipple(stipple_quartto
ne); |
| 1018 } |
| 1019 ········ |
| 1020 /* Goal is to draw as long of a contiguo
us triangle |
| 1021 * array as possible, so draw when we hi
t either an |
| 1022 * invisible triangle or at the end of t
he array */ |
| 1023 |
| 1024 /* flush buffer if current triangle isn'
t drawable or it's last triangle... */ |
| 1025 flush = (ELEM(draw_option, DM_DRAW_OPTIO
N_SKIP, DM_DRAW_OPTION_STIPPLE)) || (i == tottri - 1); |
| 1026 |
| 1027 /* ... or when material setting is dissf
erent */ |
| 1028 flush |= mf[actualFace].mat_nr != mf[nex
t_actualFace].mat_nr; |
| 1029 |
| 1030 if (!flush && compareDrawOptions) { |
| 1031 flush |= compareDrawOptions(user
Data, actualFace, next_actualFace) == 0; |
| 1032 } |
| 1033 |
| 1034 if (flush) { |
| 1035 int first = prevstart * 3; |
| 1036 /* Add one to the length if we'r
e drawing at the end of the array */ |
| 1037 int count = (i - prevstart + (dr
aw_option != DM_DRAW_OPTION_SKIP ? 1 : 0)) * 3; |
| 1038 |
| 1039 if (count) |
| 1040 glDrawArrays(GL_TRIANGLE
S, first, count); |
| 1041 |
| 1042 prevstart = i + 1; |
| 1043 |
| 1044 if (draw_option == DM_DRAW_OPTIO
N_STIPPLE) |
| 1045 glDisable(GL_POLYGON_STI
PPLE); |
| 1046 } |
| 1047 } |
| 1048 } |
| 1049 |
| 1050 glShadeModel(GL_FLAT); |
| 1051 } |
| 1052 GPU_buffer_unbind(); |
| 1053 } |
| 1054 } |
| 1055 |
| 1056 static void cdDM_drawMappedFacesTex(DerivedMesh *dm, |
| 1057 DMSetDrawOptions setDrawOptions, |
| 1058 DMCompareDrawOptions compareDrawOptions, |
| 1059 void *userData) |
| 1060 { |
| 1061 cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, u
serData); |
| 1062 } |
1003 MTFace *tf = dm->getFaceDataArray(dm, CD_MTFACE); | 1063 MTFace *tf = dm->getFaceDataArray(dm, CD_MTFACE); |
1004 float (*nors)[3] = dm->getFaceDataArray(dm, CD_NORMAL); | 1064 float (*nors)[3] = dm->getFaceDataArray(dm, CD_NORMAL); |
1005 int a, b, dodraw, matnr, new_matnr; | 1065 int a, b, dodraw, matnr, new_matnr; |
1006 int transp, new_transp, orig_transp; | 1066 int transp, new_transp, orig_transp; |
1007 int orig, *index = dm->getFaceDataArray(dm, CD_ORIGINDEX); | 1067 int orig, *index = dm->getFaceDataArray(dm, CD_ORIGINDEX); |
1008 | 1068 |
1009 cdDM_update_normals_from_pbvh(dm); | 1069 cdDM_update_normals_from_pbvh(dm); |
1010 | 1070 |
1011 matnr = -1; | 1071 matnr = -1; |
1012 dodraw = 0; | 1072 dodraw = 0; |
1013 transp = GPU_get_material_blend_mode(); | 1073 transp = GPU_get_material_blend_mode(); |
1014 orig_transp = transp; | 1074 orig_transp = transp; |
1015 | 1075 |
1016 glShadeModel(GL_SMOOTH); | 1076 glShadeModel(GL_SMOOTH); |
1017 | 1077 |
LEFT | RIGHT |