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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 /* these may not really be the orco's, but it's only for preview. | 906 /* these may not really be the orco's, but it's only for preview. |
907 * could be solver better once, but isn't simple */ | 907 * could be solver better once, but isn't simple */ |
908 ········ | 908 ········ |
909 orco = MEM_mallocN(sizeof(float) * 3 * em->bm->totvert, "BMEditMesh Orco
"); | 909 orco = MEM_mallocN(sizeof(float) * 3 * em->bm->totvert, "BMEditMesh Orco
"); |
910 | 910 |
911 BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { | 911 BM_ITER_MESH_INDEX (eve, &iter, em->bm, BM_VERTS_OF_MESH, i) { |
912 copy_v3_v3(orco[i], eve->co); | 912 copy_v3_v3(orco[i], eve->co); |
913 } | 913 } |
914 ········ | 914 ········ |
915 return orco; | 915 return orco; |
| 916 } |
| 917 |
| 918 /* orco custom data layer */ |
| 919 static float (*get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *fr
ee))[3] |
| 920 { |
| 921 *free = 0; |
| 922 |
| 923 if (layer == CD_ORCO) { |
| 924 /* get original coordinates */ |
| 925 *free = 1; |
| 926 |
| 927 if (em) |
| 928 return get_editbmesh_orco_verts(em); |
| 929 else |
| 930 return BKE_mesh_orco_verts_get(ob); |
| 931 } |
| 932 else if (layer == CD_CLOTH_ORCO) { |
| 933 /* apply shape key for cloth, this should really be solved |
| 934 * by a more flexible customdata system, but not simple */ |
| 935 if (!em) { |
| 936 ClothModifierData *clmd = (ClothModifierData *)modifiers
_findByType(ob, eModifierType_Cloth); |
| 937 KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object
(ob), clmd->sim_parms->shapekey_rest); |
| 938 |
| 939 if (kb->data) |
| 940 return kb->data; |
| 941 } |
| 942 |
| 943 return NULL; |
| 944 } |
| 945 |
| 946 return NULL; |
| 947 } |
| 948 |
| 949 static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em, int lay
er) |
| 950 { |
| 951 DerivedMesh *dm; |
| 952 float (*orco)[3]; |
| 953 int free; |
| 954 |
| 955 if (em) dm = CDDM_from_editbmesh(em, FALSE, FALSE); |
| 956 else dm = CDDM_from_mesh(me, ob); |
| 957 |
| 958 orco = get_orco_coords_dm(ob, em, layer, &free); |
| 959 |
| 960 if (orco) { |
| 961 CDDM_apply_vert_coords(dm, orco); |
| 962 if (free) MEM_freeN(orco); |
| 963 } |
| 964 |
| 965 return dm; |
| 966 } |
| 967 |
| 968 static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm, |
| 969 DerivedMesh *orcodm, int layer) |
| 970 { |
| 971 float (*orco)[3], (*layerorco)[3]; |
| 972 int totvert, free; |
| 973 |
| 974 totvert = dm->getNumVerts(dm); |
| 975 |
| 976 if (orcodm) { |
| 977 orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco"); |
| 978 free = 1; |
| 979 |
| 980 if (orcodm->getNumVerts(orcodm) == totvert) |
| 981 orcodm->getVertCos(orcodm, orco); |
| 982 else |
| 983 dm->getVertCos(dm, orco); |
| 984 } |
| 985 else |
916 EditFace *efa; | 986 EditFace *efa; |
917 DMVertexAttribs attribs= {{{0}}}; | 987 DMVertexAttribs attribs= {{{0}}}; |
918 GPUVertexAttribs gattribs; | 988 GPUVertexAttribs gattribs; |
919 MTFace *tf; | 989 MTFace *tf; |
920 int transp, new_transp, orig_transp, tfoffset; | 990 int transp, new_transp, orig_transp, tfoffset; |
921 int i, b, matnr, new_matnr, dodraw, layer; | 991 int i, b, matnr, new_matnr, dodraw, layer; |
922 | 992 |
923 dodraw = 0; | 993 dodraw = 0; |
924 matnr = -1; | 994 matnr = -1; |
925 | 995 |
926 transp = GPU_get_material_blend_mode(); | 996 transp = GPU_get_material_blend_mode(); |
927 orig_transp = transp; | 997 orig_transp = transp; |
928 layer = CustomData_get_layer_index(&em->fdata, CD_MTFACE); | 998 layer = CustomData_get_layer_index(&em->fdata, CD_MTFACE); |
929 tfoffset = (layer == -1)? -1: em->fdata.layers[layer].offset; | 999 tfoffset = (layer == -1)? -1: em->fdata.layers[layer].offset; |
930 | 1000 |
LEFT | RIGHT |