diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-05-24 17:34:14 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-05-24 18:40:15 +0300 |
commit | f2cc6c9254be5fe093e112f3b6e2192b392a1843 (patch) | |
tree | ca772903df80752dceb9250eb5090ff7b41f4487 /source/blender/editors/uvedit | |
parent | 7a9ad029dd1d1afe42d54c9c181de887636db7c0 (diff) |
TexFace removal part 2
- Derived-mesh drawing.
- All non UV members of TexFace structs.
MTexPoly is now redundant but keeping with a dummy member,
will check on complete removal later.
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 34 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 120 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 11 |
4 files changed, 14 insertions, 153 deletions
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index eb86d3a5f7d..1cb913c316a 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -179,20 +179,18 @@ static void draw_uvs_shadow(Object *obedit) immUnbindProgram(); } -static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTexPoly *activetf) +static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, const BMFace *efa_act) { BMesh *bm = em->bm; BMFace *efa; BMLoop *l; BMIter iter, liter; - MTexPoly *tf; MLoopUV *luv; Image *ima = sima->image; float aspx, aspy, col[4]; int i; const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); - const int cd_poly_tex_offset = CustomData_get_offset(&bm->pdata, CD_MTEXPOLY); BLI_buffer_declare_static(vec2f, tf_uv_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE); BLI_buffer_declare_static(vec2f, tf_uvorig_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE); @@ -208,7 +206,6 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe const int efa_len = efa->len; float (*tf_uv)[2] = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa_len); float (*tf_uvorig)[2] = (float (*)[2])BLI_buffer_reinit_data(&tf_uvorig_buf, vec2f, efa_len); - tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -224,8 +221,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe BM_elem_flag_enable(efa, BM_ELEM_TAG); } else { - if (tf == activetf) - activetf = NULL; + if (efa == efa_act) { + efa_act = NULL; + } BM_elem_flag_disable(efa, BM_ELEM_TAG); } } @@ -316,8 +314,6 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { - tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); - if (uvedit_face_visible_test(scene, ima, efa)) { const int efa_len = efa->len; float (*tf_uv)[2] = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa_len); @@ -367,8 +363,8 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe immEnd(); } else { - if (tf == activetf) - activetf = NULL; + if (efa == efa_act) + efa_act = NULL; BM_elem_flag_disable(efa, BM_ELEM_TAG); } } @@ -618,7 +614,6 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe BMFace *efa, *efa_act; BMLoop *l; BMIter iter, liter; - MTexPoly *tf, *activetf = NULL; MLoopUV *luv; unsigned char col1[4], col2[4]; float pointsize; @@ -626,11 +621,10 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe Image *ima = sima->image; const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); - const int cd_poly_tex_offset = CustomData_get_offset(&bm->pdata, CD_MTEXPOLY); unsigned int pos; - activetf = EDBM_mtexpoly_active_get(em, &efa_act, false, false); /* will be set to NULL if hidden */ + efa_act = EDBM_mtexpoly_active_get(em, false, false); /* will be set to NULL if hidden */ ts = scene->toolsettings; drawfaces = draw_uvs_face_check(scene); @@ -675,7 +669,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe /* 2. draw colored faces */ if (sima->flag & SI_DRAW_STRETCH) { - draw_uvs_stretch(sima, scene, em, activetf); + draw_uvs_stretch(sima, scene, em, efa_act); } else if (!(sima->flag & SI_NO_DRAWFACES)) { /* draw transparent faces */ @@ -690,7 +684,6 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe for (unsigned int i = 0; i < em->tottri; i++) { efa = em->looptris[i][0]->f; - tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (uvedit_face_visible_test(scene, ima, efa)) { const bool is_select = uvedit_face_select_test(scene, efa, cd_loop_uv_offset); BM_elem_flag_enable(efa, BM_ELEM_TAG); @@ -720,14 +713,12 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe /* would be nice to do this within a draw loop but most below are optional, so it would involve too many checks */ BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { - tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); - if (uvedit_face_visible_test(scene, ima, efa)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); } else { - if (tf == activetf) - activetf = NULL; + if (efa == efa_act) + efa_act = NULL; BM_elem_flag_disable(efa, BM_ELEM_TAG); } } @@ -765,11 +756,8 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, SceneLayer *sl, Object *obe BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); - if (tf) { - draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, shdr_pos); - } + draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset, shdr_pos); } immUnbindProgram(); diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h index e028c08091c..6ca46941404 100644 --- a/source/blender/editors/uvedit/uvedit_intern.h +++ b/source/blender/editors/uvedit/uvedit_intern.h @@ -32,7 +32,6 @@ #ifndef __UVEDIT_INTERN_H__ #define __UVEDIT_INTERN_H__ -struct MTexPoly; struct Image; struct Object; struct Scene; @@ -53,7 +52,6 @@ void uv_poly_center(struct BMFace *f, float r_cent[2], const int cd_loop_uv_off typedef struct NearestHit { struct BMFace *efa; - struct MTexPoly *tf; struct BMLoop *l; struct MLoopUV *luv, *luv_next; int lindex; /* index of loop within face */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 8a0d5b0b6e9..02257a08c21 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -266,43 +266,6 @@ void ED_uvedit_assign_image(Main *UNUSED(bmain), Scene *scene, Object *obedit, I } -/* dotile - 1, set the tile flag (from the space image) - * 2, set the tile index for the faces. */ -static bool uvedit_set_tile(Object *obedit, Image *ima, int curtile) -{ - BMEditMesh *em; - BMFace *efa; - BMIter iter; - MTexPoly *tf; - int cd_poly_tex_offset; - - /* verify if we have something to do */ - if (!ima || !ED_uvedit_test(obedit)) - return false; - - if ((ima->tpageflag & IMA_TILES) == 0) - return false; - - /* skip assigning these procedural images... */ - if (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) - return false; - - em = BKE_editmesh_from_object(obedit); - - cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); - - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); - - if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) - tf->tile = curtile; /* set tile index */ - } - - DAG_id_tag_update(obedit->data, 0); - - return true; -} - /*********************** space conversion *********************/ static void uvedit_pixel_to_float(SpaceImage *sima, float *dist, float pixeldist) @@ -731,7 +694,6 @@ static bool uvedit_center(Scene *scene, Image *ima, Object *obedit, float cent[2 void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float co[2], NearestHit *hit) { - MTexPoly *tf; BMFace *efa; BMLoop *l; BMIter iter, liter; @@ -740,7 +702,6 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float int i; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); mindist_squared = 1e10f; memset(hit, 0, sizeof(*hit)); @@ -748,7 +709,6 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float BM_mesh_elem_index_ensure(em->bm, BM_VERT); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa)) continue; @@ -759,7 +719,6 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float dist_squared = dist_squared_to_line_segment_v2(co, luv->uv, luv_next->uv); if (dist_squared < mindist_squared) { - hit->tf = tf; hit->efa = efa; hit->l = l; @@ -775,13 +734,11 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float static void uv_find_nearest_face(Scene *scene, Image *ima, BMEditMesh *em, const float co[2], NearestHit *hit) { - MTexPoly *tf; BMFace *efa; BMIter iter; float mindist, dist, cent[2]; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); mindist = 1e10f; memset(hit, 0, sizeof(*hit)); @@ -792,7 +749,6 @@ static void uv_find_nearest_face(Scene *scene, Image *ima, BMEditMesh *em, const hit->luv = hit->luv_next = NULL; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa)) continue; @@ -801,7 +757,6 @@ static void uv_find_nearest_face(Scene *scene, Image *ima, BMEditMesh *em, const dist = len_manhattan_v2v2(co, cent); if (dist < mindist) { - hit->tf = tf; hit->efa = efa; mindist = dist; } @@ -825,13 +780,11 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em, BMFace *efa; BMLoop *l; BMIter iter, liter; - MTexPoly *tf; MLoopUV *luv; float mindist, dist; int i; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); /*this will fill in hit.vert1 and hit.vert2*/ uv_find_nearest_edge(scene, ima, em, co, hit); @@ -844,7 +797,6 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em, BM_mesh_elem_index_ensure(em->bm, BM_VERT); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa)) continue; @@ -867,7 +819,6 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em, hit->l = l; hit->luv = luv; hit->luv_next = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset); - hit->tf = tf; hit->efa = efa; hit->lindex = i; } @@ -2619,7 +2570,6 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object BMFace *efa; BMLoop *l; BMIter iter, liter; - /* MTexPoly *tf; */ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_VERTEX) { @@ -2708,7 +2658,6 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object BMFace *efa; BMLoop *l; BMIter iter, liter; - /* MTexPoly *tf; */ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); @@ -3862,73 +3811,6 @@ static void UV_OT_cursor_set(wmOperatorType *ot) "Cursor location in normalized (0.0-1.0) coordinates", -10.0f, 10.0f); } -/********************** set tile operator **********************/ - -static int set_tile_exec(bContext *C, wmOperator *op) -{ - Image *ima = CTX_data_edit_image(C); - int tile[2]; - Object *obedit = CTX_data_edit_object(C); - - RNA_int_get_array(op->ptr, "tile", tile); - - if (uvedit_set_tile(obedit, ima, tile[0] + ima->xrep * tile[1])) { - WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL); - - return OPERATOR_FINISHED; - } - - return OPERATOR_CANCELLED; -} - -static int set_tile_invoke(bContext *C, wmOperator *op, const wmEvent *event) -{ - SpaceImage *sima = CTX_wm_space_image(C); - Image *ima = CTX_data_edit_image(C); - ARegion *ar = CTX_wm_region(C); - float fx, fy; - int tile[2]; - - if (!ima || !(ima->tpageflag & IMA_TILES)) - return OPERATOR_CANCELLED; - - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); - - if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { - fx = fx * ima->xrep; - fy = fy * ima->yrep; - - tile[0] = fx; - tile[1] = fy; - - sima->curtile = tile[1] * ima->xrep + tile[0]; - RNA_int_set_array(op->ptr, "tile", tile); - } - - return set_tile_exec(C, op); -} - -static void UV_OT_tile_set(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Set Tile"; - ot->description = "Set UV image tile coordinates"; - ot->idname = "UV_OT_tile_set"; - - /* api callbacks */ - ot->exec = set_tile_exec; - ot->invoke = set_tile_invoke; - ot->poll = ED_operator_image_active; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ - RNA_def_int_vector(ot->srna, "tile", 2, NULL, 0, INT_MAX, "Tile", "Tile coordinate", 0, 10); -} - - static int uv_seams_from_islands_exec(bContext *C, wmOperator *op) { UvVertMap *vmap; @@ -4183,7 +4065,6 @@ void ED_operatortypes_uvedit(void) WM_operatortype_append(UV_OT_hide); WM_operatortype_append(UV_OT_cursor_set); - WM_operatortype_append(UV_OT_tile_set); } void ED_keymap_uvedit(wmKeyConfig *keyconf) @@ -4263,7 +4144,6 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) /* cursor */ WM_keymap_add_item(keymap, "UV_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "UV_OT_tile_set", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0); /* menus */ WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_snap", SKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 6df73051701..c362a8a6f2d 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1443,7 +1443,7 @@ static void uv_sphere_project(float target[2], float source[3], float center[3], target[0] -= 1.0f; } -static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf)) +static void uv_map_mirror(BMEditMesh *em, BMFace *efa) { BMLoop *l; BMIter liter; @@ -1480,7 +1480,6 @@ static int sphere_project_exec(bContext *C, wmOperator *op) BMFace *efa; BMLoop *l; BMIter iter, liter; - MTexPoly *tf; MLoopUV *luv; float center[3], rotmat[4][4]; @@ -1505,8 +1504,7 @@ static int sphere_project_exec(bContext *C, wmOperator *op) uv_sphere_project(luv->uv, l->v->co, center, rotmat); } - tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - uv_map_mirror(em, efa, tf); + uv_map_mirror(em, efa); } uv_map_clip_correct(scene, obedit, em, op); @@ -1559,7 +1557,6 @@ static int cylinder_project_exec(bContext *C, wmOperator *op) BMFace *efa; BMLoop *l; BMIter iter, liter; - MTexPoly *tf; MLoopUV *luv; float center[3], rotmat[4][4]; @@ -1584,8 +1581,7 @@ static int cylinder_project_exec(bContext *C, wmOperator *op) uv_cylinder_project(luv->uv, l->v->co, center, rotmat); } - tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - uv_map_mirror(em, efa, tf); + uv_map_mirror(em, efa); } uv_map_clip_correct(scene, obedit, em, op); @@ -1621,7 +1617,6 @@ void ED_uvedit_unwrap_cube_project(Object *ob, BMesh *bm, float cube_size, bool BMFace *efa; BMLoop *l; BMIter iter, liter; - /* MTexPoly *tf; */ /* UNUSED */ MLoopUV *luv; float *loc, dx, dy; int cox, coy; |