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 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 int i; | 1681 int i; |
1682 | 1682 |
1683 DM_add_vert_layer(&bmdm->dm, CD_MDEFORMVERT, CD_CALLOC, NULL); | 1683 DM_add_vert_layer(&bmdm->dm, CD_MDEFORMVERT, CD_CALLOC, NULL); |
1684 | 1684 |
1685 BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH,
i) { | 1685 BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH,
i) { |
1686 DM_set_vert_data(&bmdm->dm, i, CD_MDEFORMVERT, | 1686 DM_set_vert_data(&bmdm->dm, i, CD_MDEFORMVERT, |
1687 CustomData_bmesh_get(&bm->vdata, eve->h
ead.data, CD_MDEFORMVERT)); | 1687 CustomData_bmesh_get(&bm->vdata, eve->h
ead.data, CD_MDEFORMVERT)); |
1688 } | 1688 } |
1689 } | 1689 } |
1690 | 1690 |
1691 if (CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) { | |
1692 BMIter iter; | |
1693 BMVert *eve; | |
1694 int i; | |
1695 | |
1696 DM_add_vert_layer(&bmdm->dm, CD_MVERT_SKIN, CD_CALLOC, NULL); | |
1697 | |
1698 eve = BM_iter_new(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL); | |
1699 for (i=0; eve; eve=BM_iter_step(&iter), i++) | |
1700 DM_set_vert_data(&bmdm->dm, i, CD_MVERT_SKIN, | |
1701 CustomData_bmesh_get(&b
m->vdata, eve->head.data, | |
1702
CD_MVERT_SKIN)); | |
1703 } | |
1704 | |
1705 if (vertexCos) { | 1691 if (vertexCos) { |
1706 BMFace *efa; | 1692 BMFace *efa; |
1707 BMVert *eve; | 1693 BMVert *eve; |
1708 BMIter fiter; | |
1709 BMIter viter; | |
1710 int i; | |
1711 | |
1712 BM_mesh_elem_index_ensure(bm, BM_VERT); | |
1713 | |
1714 bmdm->vertexNos = MEM_callocN(sizeof(*bmdm->vertexNos) * bm->tot
vert, "bmdm_vno"); | |
1715 bmdm->polyNos = MEM_mallocN(sizeof(*bmdm->polyNos) * bm->totface
, "bmdm_pno"); | |
1716 | |
1717 BM_ITER_MESH_INDEX (efa, &fiter, bm, BM_FACES_OF_MESH, i) { | |
1718 BM_elem_index_set(efa, i); /* set_inline */ | |
1719 BM_face_normal_update_vcos(bm, efa, bmdm->polyNos[i], (f
loat const (*)[3])vertexCos); | |
1720 } | |
1721 bm->elem_index_dirty &= ~BM_FACE; | |
1722 | |
1723 BM_ITER_MESH_INDEX (eve, &viter, bm, BM_VERTS_OF_MESH, i) { | |
1724 float *no = bmdm->vertexNos[i]; | |
1725 BM_ITER_ELEM (efa, &fiter, eve, BM_FACES_OF_VERT) { | |
1726 add_v3_v3(no, bmdm->polyNos[BM_elem_index_get(ef
a)]); | |
1727 } | |
1728 | |
1729 /* following Mesh convention; we use vertex coordinate i
tself | |
1730 * for normal in this case */ | |
1731 if (normalize_v3(no) == 0.0f) { | |
1732 copy_v3_v3(no, vertexCos[i]); | |
1733 normalize_v3(no); | |
1734 } | |
1735 } | |
1736 } | |
1737 | |
1738 return (DerivedMesh *)bmdm; | |
1739 } | |
1740 | |
1741 /** | |
1742 * \brief Return the BMEditMesh for a given object | |
1743 * | |
1744 * \note this function assumes this is a mesh object, | |
1745 * don't add NULL data check here. caller must do that | |
1746 */ | |
1747 BMEditMesh *BMEdit_FromObject(Object *ob) | |
1748 { | |
1749 BLI_assert(ob->type == OB_MESH); | |
1750 return ((Mesh *)ob->data)->edit_btmesh; | |
1751 } | |
LEFT | RIGHT |