diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-10 08:52:16 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-10 08:52:16 +0300 |
commit | 3ad8fd44c4047d0ee95eca50de066ad87419c738 (patch) | |
tree | ecc07527b1f39de1f2b660318dcbeca02d405956 /source/blender | |
parent | 6a324428554a5a01da58af810fd18f7b12a1f373 (diff) |
request from Jedrzej Slewczuk's:
Option for tagging creases (Ctrl+RMB) to also re-unwrap the mesh.
In 2.42 this could be done by setting rt==8 (very hidden), now its a little less hidden (in the toolbar).
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_uvedit.h | 6 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_mods.c | 11 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 42 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 4 |
5 files changed, 52 insertions, 17 deletions
diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index a0c4148c055..b975be54f5f 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -66,11 +66,15 @@ void uvedit_uv_select(struct Scene *scene, struct EditFace *efa, struct MTFace * int ED_uvedit_nearest_uv(struct Scene *scene, struct Object *obedit, struct Image *ima, float co[2], float uv[2]); -/* uvedit_unwrap.c */ +/* uvedit_unwrap_ops.c */ void ED_uvedit_live_unwrap_begin(struct Scene *scene, struct Object *obedit); void ED_uvedit_live_unwrap_re_solve(void); void ED_uvedit_live_unwrap_end(short cancel); +/* single call up unwrap using scene settings, used for edge tag unwrapping */ +void ED_unwrap_lscm(struct Scene *scene, struct Object *obedit, const short sel); + +/* uvedit_draw.c */ void draw_uvedit_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene, struct Object *obedit); #endif /* ED_UVEDIT_H */ diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 50ea99f46ba..5075ae94f8d 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -79,6 +79,7 @@ editmesh_mods.c, UI level access, no geometry changes #include "ED_mesh.h" #include "ED_screen.h" #include "ED_view3d.h" +#include "ED_uvedit.h" #include "BIF_gl.h" @@ -2201,7 +2202,15 @@ static void mouse_mesh_shortest_path(bContext *C, short mval[2]) me->drawflag |= ME_DRAWBWEIGHTS; break; } - + + /* live unwrap while tagging */ + if( (vc.scene->toolsettings->edge_mode_live_unwrap) && + (vc.scene->toolsettings->edge_mode == EDGE_MODE_TAG_SEAM) && + (CustomData_has_layer(&em->fdata, CD_MTFACE)) + ) { + ED_unwrap_lscm(vc.scene, vc.obedit, FALSE); /* unwrap all not just sel */ + } + DAG_id_tag_update(vc.obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index e0dbe8407d3..d4e6b3b98b9 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -812,41 +812,57 @@ static void uv_map_clip_correct(EditMesh *em, wmOperator *op) /* ******************** Unwrap operator **************** */ +/* assumes UV layer is checked, doesn't run update funcs */ +void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel) +{ + EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data); + + const short fill_holes= scene->toolsettings->uvcalc_flag & UVCALC_FILLHOLES; + const short correct_aspect= !(scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT); + + ParamHandle *handle= construct_param_handle(scene, em, 0, fill_holes, sel, correct_aspect); + + param_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0); + param_lscm_solve(handle); + param_lscm_end(handle); + + param_pack(handle, scene->toolsettings->uvcalc_margin); + + param_flush(handle); + + param_delete(handle); + + BKE_mesh_end_editmesh(obedit->data, em); +} + static int unwrap_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); - EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data); - ParamHandle *handle; int method = RNA_enum_get(op->ptr, "method"); int fill_holes = RNA_boolean_get(op->ptr, "fill_holes"); int correct_aspect = RNA_boolean_get(op->ptr, "correct_aspect"); /* add uvs if they don't exist yet */ if(!ED_uvedit_ensure_uvs(C, scene, obedit)) { - BKE_mesh_end_editmesh(obedit->data, em); return OPERATOR_CANCELLED; } /* remember last method for live unwrap */ scene->toolsettings->unwrapper = method; - handle= construct_param_handle(scene, em, 0, fill_holes, 1, correct_aspect); - - param_lscm_begin(handle, PARAM_FALSE, method == 0); - param_lscm_solve(handle); - param_lscm_end(handle); - - param_pack(handle, scene->toolsettings->uvcalc_margin); + if(fill_holes) scene->toolsettings->uvcalc_flag |= UVCALC_FILLHOLES; + else scene->toolsettings->uvcalc_flag &= ~UVCALC_FILLHOLES; - param_flush(handle); + if(correct_aspect) scene->toolsettings->uvcalc_flag &= ~UVCALC_NO_ASPECT_CORRECT; + else scene->toolsettings->uvcalc_flag |= UVCALC_NO_ASPECT_CORRECT; - param_delete(handle); + /* execute unwrap */ + ED_unwrap_lscm(scene, obedit, FALSE); DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - BKE_mesh_end_editmesh(obedit->data, em); return OPERATOR_FINISHED; } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 13e8e1fb862..00818f3b92c 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -726,9 +726,11 @@ typedef struct ToolSettings { /* Alt+RMB option */ char edge_mode; + char edge_mode_live_unwrap; /* Transform */ - short snap_mode, snap_flag, snap_target; + char snap_mode; + short snap_flag, snap_target; short proportional, prop_mode; char proportional_objects; /* proportional edit, object mode */ char pad[3]; @@ -1176,7 +1178,7 @@ typedef enum SculptFlags { /* toolsettings->uvcalc_flag */ #define UVCALC_FILLHOLES 1 -/*#define UVCALC_NO_ASPECT_CORRECT 2*/ /* would call this UVCALC_ASPECT_CORRECT, except it should be default with old file */ +#define UVCALC_NO_ASPECT_CORRECT 2 /* would call this UVCALC_ASPECT_CORRECT, except it should be default with old file */ #define UVCALC_TRANSFORM_CORRECT 4 /* adjust UV's while transforming to avoid distortion */ /* toolsettings->uv_flag */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index ae798460294..db3ecb5dd5d 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1206,6 +1206,10 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, edge_tag_items); RNA_def_property_ui_text(prop, "Edge Tag Mode", "The edge flag to tag when selecting the shortest path"); + prop= RNA_def_property(srna, "edge_path_live_unwrap", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "edge_mode_live_unwrap", 1); + RNA_def_property_ui_text(prop, "Live Unwrap", "Tagging edges re-calculates unwrap"); + /* etch-a-ton */ prop= RNA_def_property(srna, "use_bone_sketching", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "bone_sketching", BONE_SKETCHING); |