Changeset View
Changeset View
Standalone View
Standalone View
source/blender/bmesh/tools/bmesh_bevel.c
| Show First 20 Lines • Show All 805 Lines • ▼ Show 20 Lines | |||||
| * we need to calculate connected face components in UV space. | * we need to calculate connected face components in UV space. | ||||
| */ | */ | ||||
| static void math_layer_info_init(BevelParams *bp, BMesh *bm) | static void math_layer_info_init(BevelParams *bp, BMesh *bm) | ||||
| { | { | ||||
| int f; | int f; | ||||
| bp->math_layer_info.has_math_layers = false; | bp->math_layer_info.has_math_layers = false; | ||||
| bp->math_layer_info.face_component = NULL; | bp->math_layer_info.face_component = NULL; | ||||
| for (int i = 0; i < bm->ldata.totlayer; i++) { | for (int i = 0; i < bm->ldata.totlayer; i++) { | ||||
| if (CustomData_has_layer(&bm->ldata, CD_MLOOPUV)) { | if (CustomData_has_layer(&bm->ldata, CD_PROP_FLOAT2)) { | ||||
| bp->math_layer_info.has_math_layers = true; | bp->math_layer_info.has_math_layers = true; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (!bp->math_layer_info.has_math_layers || (bp->seg % 2) == 0) { | if (!bp->math_layer_info.has_math_layers || (bp->seg % 2) == 0) { | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | #define VEC_VALUE_LEN 6 | ||||
| return face[best_f]; | return face[best_f]; | ||||
| #undef VEC_VALUE_LEN | #undef VEC_VALUE_LEN | ||||
| } | } | ||||
| /* Merge (using average) all the UV values for loops of v's faces. | /* Merge (using average) all the UV values for loops of v's faces. | ||||
| * Caller should ensure that no seams are violated by doing this. */ | * Caller should ensure that no seams are violated by doing this. */ | ||||
| static void bev_merge_uvs(BMesh *bm, BMVert *v) | static void bev_merge_uvs(BMesh *bm, BMVert *v) | ||||
| { | { | ||||
| int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV); | int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_PROP_FLOAT2); | ||||
| for (int i = 0; i < num_of_uv_layers; i++) { | for (int i = 0; i < num_of_uv_layers; i++) { | ||||
| int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i); | int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_PROP_FLOAT2, i); | ||||
| if (cd_loop_uv_offset == -1) { | if (cd_loop_uv_offset == -1) { | ||||
| return; | return; | ||||
| } | } | ||||
| int n = 0; | int n = 0; | ||||
| float uv[2] = {0.0f, 0.0f}; | float uv[2] = {0.0f, 0.0f}; | ||||
| BMIter iter; | BMIter iter; | ||||
| BMLoop *l; | BMLoop *l; | ||||
| BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { | BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { | ||||
| MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); | float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset); | ||||
| add_v2_v2(uv, luv->uv); | add_v2_v2(uv, luv); | ||||
| n++; | n++; | ||||
| } | } | ||||
| if (n > 1) { | if (n > 1) { | ||||
| mul_v2_fl(uv, 1.0f / (float)n); | mul_v2_fl(uv, 1.0f / (float)n); | ||||
| BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { | BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { | ||||
| MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); | float *luv = BM_ELEM_CD_GET_FLOAT_P(l, cd_loop_uv_offset); | ||||
| copy_v2_v2(luv->uv, uv); | copy_v2_v2(luv, uv); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Merge (using average) the UV values for two specific loops of v: those for faces containing v, | /* Merge (using average) the UV values for two specific loops of v: those for faces containing v, | ||||
| * and part of faces that share edge bme. */ | * and part of faces that share edge bme. */ | ||||
| static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v) | static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v) | ||||
| { | { | ||||
| int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV); | int num_of_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_PROP_FLOAT2); | ||||
| BMLoop *l1 = NULL; | BMLoop *l1 = NULL; | ||||
| BMLoop *l2 = NULL; | BMLoop *l2 = NULL; | ||||
| BMIter iter; | BMIter iter; | ||||
| BMLoop *l; | BMLoop *l; | ||||
| BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { | BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { | ||||
| if (l->e == bme) { | if (l->e == bme) { | ||||
| l1 = l; | l1 = l; | ||||
| } | } | ||||
| else if (l->prev->e == bme) { | else if (l->prev->e == bme) { | ||||
| l2 = l; | l2 = l; | ||||
| } | } | ||||
| } | } | ||||
| if (l1 == NULL || l2 == NULL) { | if (l1 == NULL || l2 == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (int i = 0; i < num_of_uv_layers; i++) { | for (int i = 0; i < num_of_uv_layers; i++) { | ||||
| int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i); | int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_PROP_FLOAT2, i); | ||||
| if (cd_loop_uv_offset == -1) { | if (cd_loop_uv_offset == -1) { | ||||
| return; | return; | ||||
| } | } | ||||
| float uv[2] = {0.0f, 0.0f}; | float uv[2] = {0.0f, 0.0f}; | ||||
| MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset); | float *luv = BM_ELEM_CD_GET_FLOAT_P(l1, cd_loop_uv_offset); | ||||
| add_v2_v2(uv, luv->uv); | add_v2_v2(uv, luv); | ||||
| luv = BM_ELEM_CD_GET_VOID_P(l2, cd_loop_uv_offset); | luv = BM_ELEM_CD_GET_FLOAT_P(l2, cd_loop_uv_offset); | ||||
| add_v2_v2(uv, luv->uv); | add_v2_v2(uv, luv); | ||||
| mul_v2_fl(uv, 0.5f); | mul_v2_fl(uv, 0.5f); | ||||
| luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset); | luv = BM_ELEM_CD_GET_FLOAT_P(l1, cd_loop_uv_offset); | ||||
| copy_v2_v2(luv->uv, uv); | copy_v2_v2(luv, uv); | ||||
| luv = BM_ELEM_CD_GET_VOID_P(l2, cd_loop_uv_offset); | luv = BM_ELEM_CD_GET_FLOAT_P(l2, cd_loop_uv_offset); | ||||
| copy_v2_v2(luv->uv, uv); | copy_v2_v2(luv, uv); | ||||
| } | } | ||||
| } | } | ||||
| /* Calculate coordinates of a point a distance d from v on e->e and return it in slideco. */ | /* Calculate coordinates of a point a distance d from v on e->e and return it in slideco. */ | ||||
| static void slide_dist(EdgeHalf *e, BMVert *v, float d, float r_slideco[3]) | static void slide_dist(EdgeHalf *e, BMVert *v, float d, float r_slideco[3]) | ||||
| { | { | ||||
| float dir[3]; | float dir[3]; | ||||
| sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co); | sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co); | ||||
| ▲ Show 20 Lines • Show All 6,853 Lines • Show Last 20 Lines | |||||