diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-02 02:25:49 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-02 02:25:49 +0400 |
commit | 421f44278cebff49a1485251f92a4277934c4e4c (patch) | |
tree | cdc18b03a3d2c3f17c892f0c4e1e894e91a9610a /source/blender/editors | |
parent | cda566d6464cac92a766df0b065d43d8240e23f2 (diff) |
2.5: Lists for vertex groups, shape keys, uvs, vertex colors.
RNA
* Added the relevant active_*_index properties, with proper
get/set/range, updates and notifiers.
* Context.tool_settings.
* ToolSettings.vertex_group_weight.
Operators
* MESH_OT_uv_texture_add/remove
* MESH_OT_vertex_color_add/remove
* MESH_OT_sticky_add/remove
* OBJECT_OT_vertex_group_add/remove/assign/remove_from/
select/deselect/copy/copy_to_linked
* OBJECT_OT_shape_key_add/remove
UI
* Some updates and cleanups in list template code.
Known issue: when going in & out of editmode, uv textures and vertex
colors dissappear. I thought me->edit_mesh would be NULL when not in
edit mode but it is not?
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 4 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 204 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 9 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_layers.c | 424 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 6 | ||||
-rw-r--r-- | source/blender/editors/object/editkey.c | 144 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 14 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 12 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c (renamed from source/blender/editors/mesh/editdeform.c) | 274 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/space_buttons.c | 1 |
13 files changed, 936 insertions, 166 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 937f6384f6a..8952305d6ab 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -110,7 +110,6 @@ void undo_push_mesh(struct bContext *C, char *name); struct EditFace *EM_get_actFace(struct EditMesh *em, int sloppy); void EM_set_actFace(struct EditMesh *em, struct EditFace *efa); float EM_face_area(struct EditFace *efa); -void EM_add_data_layer(struct EditMesh *em, struct CustomData *data, int type); void EM_select_edge(struct EditEdge *eed, int sel); void EM_select_face(struct EditFace *efa, int sel); @@ -134,6 +133,9 @@ struct UvVertMap *EM_make_uv_vert_map(struct EditMesh *em, int selected, int do_ struct UvMapVert *EM_get_uv_map_vert(struct UvVertMap *vmap, unsigned int v); void EM_free_uv_vert_map(struct UvVertMap *vmap); +void EM_add_data_layer(struct EditMesh *em, struct CustomData *data, int type); +void EM_free_data_layer(struct EditMesh *em, struct CustomData *data, int type); + /* editmesh_mods.c */ extern unsigned int em_vertoffs, em_solidoffs, em_wireoffs; diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 5000dca3743..cc8b936b04f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -617,7 +617,7 @@ void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand); void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type); void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname); void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); -ListBase uiTemplateList(uiLayout *layout, struct PointerRNA *ptr, char *propname, char *activeprop, int rows, int columns, int compact); +ListBase uiTemplateList(uiLayout *layout, struct PointerRNA *ptr, char *propname, struct PointerRNA *activeptr, char *activeprop, int rows, int columns, int compact); void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); void uiTemplateOperatorSearch(uiLayout *layout); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index fcea74cc22b..00ec875bd86 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2184,7 +2184,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, RNA_property_int_range(ptr, prop, &hardmin, &hardmax); RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step); - if(min == max) { + if(type != ROW && min == max) { min= hardmin; max= hardmax; } @@ -2199,7 +2199,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, RNA_property_float_range(ptr, prop, &hardmin, &hardmax); RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); - if(min == max) { + if(type != ROW && min == max) { min= hardmin; max= hardmax; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 8b3f2bf4100..8f1d57b28ed 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1486,93 +1486,63 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname) /************************* List Template **************************/ -#if 0 -typedef struct ListItem { - PointerRNA ptr; - PropertyRNA *prop; - PropertyRNA *activeprop; - - PointerRNA activeptr; - int activei; - - int selected; -} ListItem; - -static void list_item_cb(bContext *C, void *arg_item, void *arg_unused) -{ - ListItem *item= (ListItem*)arg_item; - PropertyType activetype; - char *activename; - - if(item->selected) { - activetype= RNA_property_type(item->activeprop); - - if(activetype == PROP_POINTER) - RNA_property_pointer_set(&item->ptr, item->activeprop, item->activeptr); - else if(activetype == PROP_INT) - RNA_property_int_set(&item->ptr, item->activeprop, item->activei); - else if(activetype == PROP_STRING) { - activename= RNA_struct_name_get_alloc(&item->activeptr, NULL, 0); - RNA_property_string_set(&item->ptr, item->activeprop, activename); - MEM_freeN(activename); - } - } -} -#endif - -ListBase uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, char *activepropname, int rows, int columns, int compact) +ListBase uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, PointerRNA *activeptr, char *activepropname, int rows, int columns, int compact) { CollectionPointerLink *link; - PropertyRNA *prop, *activeprop; + PropertyRNA *prop= NULL, *activeprop; PropertyType type, activetype; - PointerRNA activeptr; uiLayout *box, *row, *col; uiBlock *block; uiBut *but; + Panel *pa; ListBase lb; - char *name, *activename= NULL, str[32]; - int i= 1, activei= 0, len, items, found; - static int scroll = 1; + char *name, str[32]; + int i= 0, activei= 0, len, items, found, min, max; lb.first= lb.last= NULL; /* validate arguments */ - if(!ptr->data) + block= uiLayoutGetBlock(layout); + pa= block->panel; + + if(!pa) { + printf("uiTemplateList: only works inside a panel.\n"); return lb; - - prop= RNA_struct_find_property(ptr, propname); - if(!prop) { - printf("uiTemplateList: property not found: %s\n", propname); + } + + if(!activeptr->data) return lb; + + if(ptr->data) { + prop= RNA_struct_find_property(ptr, propname); + if(!prop) { + printf("uiTemplateList: property not found: %s\n", propname); + return lb; + } } - activeprop= RNA_struct_find_property(ptr, activepropname); + activeprop= RNA_struct_find_property(activeptr, activepropname); if(!activeprop) { printf("uiTemplateList: property not found: %s\n", activepropname); return lb; } - type= RNA_property_type(prop); - if(type != PROP_COLLECTION) { - printf("uiTemplateList: expected collection property.\n"); - return lb; + if(prop) { + type= RNA_property_type(prop); + if(type != PROP_COLLECTION) { + printf("uiTemplateList: expected collection property.\n"); + return lb; + } } activetype= RNA_property_type(activeprop); - if(!ELEM3(activetype, PROP_POINTER, PROP_INT, PROP_STRING)) { - printf("uiTemplateList: expected pointer, integer or string property.\n"); + if(activetype != PROP_INT) { + printf("uiTemplateList: expected integer property.\n"); return lb; } /* get active data */ - if(activetype == PROP_POINTER) - activeptr= RNA_property_pointer_get(ptr, activeprop); - else if(activetype == PROP_INT) - activei= RNA_property_int_get(ptr, activeprop); - else if(activetype == PROP_STRING) - activename= RNA_property_string_get_alloc(ptr, activeprop, NULL, 0); - - block= uiLayoutGetBlock(layout); + activei= RNA_property_int_get(activeptr, activeprop); if(compact) { /* compact layout */ @@ -1580,111 +1550,105 @@ ListBase uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, char row= uiLayoutRow(layout, 1); - RNA_PROP_BEGIN(ptr, itemptr, prop) { - if(activetype == PROP_POINTER) - found= (activeptr.data == itemptr.data); - else if(activetype == PROP_INT) + if(ptr->data && prop) { + /* create list items */ + RNA_PROP_BEGIN(ptr, itemptr, prop) { found= (activei == i); - else if(activetype == PROP_STRING) - found= (strcmp(activename, name) == 0); - - if(found) { - name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); - if(name) { - uiItemL(row, name, RNA_struct_ui_icon(itemptr.type)); - MEM_freeN(name); + + if(found) { + /* create button */ + name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); + if(name) { + uiItemL(row, name, RNA_struct_ui_icon(itemptr.type)); + MEM_freeN(name); + } + + /* add to list to return */ + link= MEM_callocN(sizeof(CollectionPointerLink), "uiTemplateList return"); + link->ptr= itemptr; + BLI_addtail(&lb, link); } - link= MEM_callocN(sizeof(CollectionPointerLink), "uiTemplateList return"); - link->ptr= itemptr; - BLI_addtail(&lb, link); + i++; } - - i++; + RNA_PROP_END; } - RNA_PROP_END; - if(i == 1) + /* if not found, add in dummy button */ + if(i == 0) uiItemL(row, "", 0); - sprintf(str, "%d :", i-1); - but= uiDefIconTextButR(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, ptr, activepropname, 0, 0, 0, 0, 0, ""); - if(i == 1) + /* next/prev button */ + sprintf(str, "%d :", i); + but= uiDefIconTextButR(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activepropname, 0, 0, 0, 0, 0, ""); + if(i == 0) uiButSetFlag(but, UI_BUT_DISABLED); } else { + /* default rows/columns */ if(rows == 0) rows= 5; if(columns == 0) columns= 1; - items= rows*columns; - + /* layout */ box= uiLayoutBox(layout); row= uiLayoutRow(box, 0); col = uiLayoutColumn(row, 1); uiBlockSetEmboss(block, UI_EMBOSSN); - len= RNA_property_collection_length(ptr, prop); - scroll= MIN2(scroll, len-items+1); - scroll= MAX2(scroll, 1); + /* init numbers */ + RNA_property_int_range(activeptr, activeprop, &min, &max); - RNA_PROP_BEGIN(ptr, itemptr, prop) { - if(i >= scroll && i<scroll+items) { - name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); + len= max - min + 1; + items= rows*columns; - if(name) { -#if 0 - ListItem *item= MEM_callocN(sizeof(ListItem), "uiTemplateList ListItem"); - - item->ptr= *ptr; - item->prop= prop; - item->activeprop= activeprop; - item->activeptr= itemptr; - item->activei= i; - - if(activetype == PROP_POINTER) - item->selected= (activeptr.data == itemptr.data)? i: -1; - else if(activetype == PROP_INT) - item->selected= (activei == i)? i: -1; - else if(activetype == PROP_STRING) - item->selected= (strcmp(activename, name) == 0)? i: -1; -#endif + pa->list_scroll= MIN2(pa->list_scroll, len-items); + pa->list_scroll= MAX2(pa->list_scroll, 0); - //but= uiDefIconTextButI(block, ROW, 0, RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, &item->selected, 0, i, 0, 0, ""); - but= uiDefIconTextButR(block, ROW, 0, RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, ptr, activepropname, 0/*&item->selected*/, 0, i, 0, 0, ""); - uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT); - //uiButSetNFunc(but, list_item_cb, item, NULL); + if(ptr->data && prop) { + /* create list items */ + RNA_PROP_BEGIN(ptr, itemptr, prop) { + if(i >= pa->list_scroll && i<pa->list_scroll+items) { + name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); - MEM_freeN(name); + if(name) { + /* create button */ + but= uiDefIconTextButR(block, ROW, 0, RNA_struct_ui_icon(itemptr.type), name, 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, ""); + uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT); + MEM_freeN(name); + } + + /* add to list to return */ link= MEM_callocN(sizeof(CollectionPointerLink), "uiTemplateList return"); link->ptr= itemptr; BLI_addtail(&lb, link); } - } - i++; + i++; + } + RNA_PROP_END; } - RNA_PROP_END; - while(i < scroll+items) { - if(i >= scroll) + /* add dummy buttons to fill space */ + while(i < pa->list_scroll+items) { + if(i >= pa->list_scroll) uiItemL(col, "", 0); i++; } uiBlockSetEmboss(block, UI_EMBOSS); + /* add scrollbar */ if(len > items) { col= uiLayoutColumn(row, 0); - uiDefButI(block, SCROLL, 0, "", 0,0,UI_UNIT_X*0.75,UI_UNIT_Y*items, &scroll, 1, len-items+1, items, 0, ""); + uiDefButI(block, SCROLL, 0, "", 0,0,UI_UNIT_X*0.75,UI_UNIT_Y*items, &pa->list_scroll, 0, len-items, items, 0, ""); } - - //uiDefButI(block, SCROLL, 0, "", 0,0,UI_UNIT_X*15,UI_UNIT_Y*0.75, &scroll, 1, 16-5, 5, 0, ""); } + /* return items in list */ return lb; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index ddf31c0db66..ed2d00cb00d 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1679,12 +1679,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat rect1= *rect; if(horizontal) { - fac= (rect->xmax - rect->xmin)/(size-1); + fac= (rect->xmax - rect->xmin)/(size); rect1.xmin= rect1.xmin + ceil(fac*(value - but->softmin)); rect1.xmax= rect1.xmin + ceil(fac*(but->a1 - but->softmin)); } else { - fac= (rect->ymax - rect->ymin)/(size-1); + fac= (rect->ymax - rect->ymin)/(size); rect1.ymax= rect1.ymax - ceil(fac*(value - but->softmin)); rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin)); } diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 83a4211dda1..22e3b4060a4 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -234,5 +234,14 @@ void MESH_OT_colors_mirror(struct wmOperatorType *ot); void MESH_OT_delete(struct wmOperatorType *ot); void MESH_OT_rip(struct wmOperatorType *ot); +/* ******************* mesh_layers.c */ + +void MESH_OT_uv_texture_add(struct wmOperatorType *ot); +void MESH_OT_uv_texture_remove(struct wmOperatorType *ot); +void MESH_OT_vertex_color_add(struct wmOperatorType *ot); +void MESH_OT_vertex_color_remove(struct wmOperatorType *ot); +void MESH_OT_sticky_add(struct wmOperatorType *ot); +void MESH_OT_sticky_remove(struct wmOperatorType *ot); + #endif // MESH_INTERN_H diff --git a/source/blender/editors/mesh/mesh_layers.c b/source/blender/editors/mesh/mesh_layers.c new file mode 100644 index 00000000000..99d50d1a9b0 --- /dev/null +++ b/source/blender/editors/mesh/mesh_layers.c @@ -0,0 +1,424 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> +#include <math.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_customdata_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_windowmanager_types.h" + +#include "BKE_context.h" +#include "BKE_customdata.h" +#include "BKE_depsgraph.h" +#include "BKE_displist.h" +#include "BKE_global.h" +#include "BKE_mesh.h" + +#include "BLI_editVert.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_mesh.h" +#include "ED_view3d.h" + +#include "mesh_intern.h" + +static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer) +{ + CustomData *data= (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata; + void *actlayerdata, *rndlayerdata, *clonelayerdata, *masklayerdata, *layerdata=layer->data; + int type= layer->type; + int index= CustomData_get_layer_index(data, type); + int i, actindex, rndindex, cloneindex, maskindex; + + /* ok, deleting a non-active layer needs to preserve the active layer indices. + to do this, we store a pointer to the .data member of both layer and the active layer, + (to detect if we're deleting the active layer or not), then use the active + layer data pointer to find where the active layer has ended up. + + this is necassary because the deletion functions only support deleting the active + layer. */ + actlayerdata = data->layers[CustomData_get_active_layer_index(data, type)].data; + rndlayerdata = data->layers[CustomData_get_render_layer_index(data, type)].data; + clonelayerdata = data->layers[CustomData_get_clone_layer_index(data, type)].data; + masklayerdata = data->layers[CustomData_get_mask_layer_index(data, type)].data; + CustomData_set_layer_active(data, type, layer - &data->layers[index]); + + if(me->edit_mesh) { + EM_free_data_layer(me->edit_mesh, data, type); + } + else { + CustomData_free_layer_active(data, type, me->totface); + mesh_update_customdata_pointers(me); + } + + if(!CustomData_has_layer(data, type)) + if(type == CD_MCOL && (G.f & G_VERTEXPAINT)) + G.f &= ~G_VERTEXPAINT; /* get out of vertexpaint mode */ + + /* reconstruct active layer */ + if (actlayerdata != layerdata) { + /* find index */ + actindex = CustomData_get_layer_index(data, type); + for (i=actindex; i<data->totlayer; i++) { + if (data->layers[i].data == actlayerdata) { + actindex = i - actindex; + break; + } + } + + /* set index */ + CustomData_set_layer_active(data, type, actindex); + } + + if (rndlayerdata != layerdata) { + /* find index */ + rndindex = CustomData_get_layer_index(data, type); + for (i=rndindex; i<data->totlayer; i++) { + if (data->layers[i].data == rndlayerdata) { + rndindex = i - rndindex; + break; + } + } + + /* set index */ + CustomData_set_layer_render(data, type, rndindex); + } + + if (clonelayerdata != layerdata) { + /* find index */ + cloneindex = CustomData_get_layer_index(data, type); + for (i=cloneindex; i<data->totlayer; i++) { + if (data->layers[i].data == clonelayerdata) { + cloneindex = i - cloneindex; + break; + } + } + + /* set index */ + CustomData_set_layer_clone(data, type, cloneindex); + } + + if (masklayerdata != layerdata) { + /* find index */ + maskindex = CustomData_get_layer_index(data, type); + for (i=maskindex; i<data->totlayer; i++) { + if (data->layers[i].data == masklayerdata) { + maskindex = i - maskindex; + break; + } + } + + /* set index */ + CustomData_set_layer_mask(data, type, maskindex); + } +} + +/*********************** UV texture operators ************************/ + +static int uv_texture_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Mesh *me; + EditMesh *em; + int layernum; + + if(!ob || ob->type!=OB_MESH) + return OPERATOR_CANCELLED; + + me= (Mesh*)ob->data; + + if(scene->obedit == ob) { + em= me->edit_mesh; + + layernum= CustomData_number_of_layers(&em->fdata, CD_MTFACE); + if(layernum >= MAX_MTFACE) + return OPERATOR_CANCELLED; + + EM_add_data_layer(em, &em->fdata, CD_MTFACE); + CustomData_set_layer_active(&em->fdata, CD_MTFACE, layernum); + } + else if(ob) { + layernum= CustomData_number_of_layers(&me->fdata, CD_MTFACE); + if(layernum >= MAX_MTFACE) + return OPERATOR_CANCELLED; + + if(me->mtface) + CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface); + else + CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface); + + CustomData_set_layer_active(&me->fdata, CD_MTFACE, layernum); + mesh_update_customdata_pointers(me); + } + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void MESH_OT_uv_texture_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add UV Texture"; + ot->idname= "MESH_OT_uv_texture_add"; + + /* api callbacks */ + ot->exec= uv_texture_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int uv_texture_remove_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Mesh *me; + CustomDataLayer *cdl; + int index; + + if(!ob || ob->type!=OB_MESH) + return OPERATOR_CANCELLED; + + me= (Mesh*)ob->data; + index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); + cdl= (index == -1)? NULL: &me->fdata.layers[index]; + + if(!cdl) + return OPERATOR_CANCELLED; + + delete_customdata_layer(me, cdl); + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void MESH_OT_uv_texture_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove UV Texture"; + ot->idname= "MESH_OT_uv_texture_remove"; + + /* api callbacks */ + ot->exec= uv_texture_remove_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/*********************** vertex color operators ************************/ + +static int vertex_color_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Mesh *me; + EditMesh *em; + MCol *mcol; + int layernum; + + if(!ob || ob->type!=OB_MESH) + return OPERATOR_CANCELLED; + + me= (Mesh*)ob->data; + + if(scene->obedit == ob) { + em= me->edit_mesh; + + layernum= CustomData_number_of_layers(&em->fdata, CD_MCOL); + if(layernum >= MAX_MCOL) + return OPERATOR_CANCELLED; + + EM_add_data_layer(em, &em->fdata, CD_MCOL); + CustomData_set_layer_active(&em->fdata, CD_MCOL, layernum); + } + else { + layernum= CustomData_number_of_layers(&me->fdata, CD_MCOL); + if(layernum >= MAX_MCOL) + return OPERATOR_CANCELLED; + + mcol= me->mcol; + + if(me->mcol) + CustomData_add_layer(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mcol, me->totface); + else + CustomData_add_layer(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface); + + CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum); + mesh_update_customdata_pointers(me); + + if(!mcol) + shadeMeshMCol(scene, ob, me); + } + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void MESH_OT_vertex_color_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Vertex Color"; + ot->idname= "MESH_OT_vertex_color_add"; + + /* api callbacks */ + ot->exec= vertex_color_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int vertex_color_remove_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Mesh *me; + CustomDataLayer *cdl; + int index; + + if(!ob || ob->type!=OB_MESH) + return OPERATOR_CANCELLED; + + me= (Mesh*)ob->data; + index= CustomData_get_active_layer_index(&me->fdata, CD_MCOL); + cdl= (index == -1)? NULL: &me->fdata.layers[index]; + + if(!cdl) + return OPERATOR_CANCELLED; + + delete_customdata_layer(me, cdl); + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void MESH_OT_vertex_color_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Vertex Color"; + ot->idname= "MESH_OT_vertex_color_remove"; + + /* api callbacks */ + ot->exec= vertex_color_remove_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/*********************** sticky operators ************************/ + +static int sticky_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Mesh *me; + + if(!ob || ob->type!=OB_MESH) + return OPERATOR_CANCELLED; + + me= (Mesh*)ob->data; + + if(me->msticky) + return OPERATOR_CANCELLED; + + // XXX RE_make_sticky(); + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void MESH_OT_sticky_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Sticky"; + ot->idname= "MESH_OT_sticky_add"; + + /* api callbacks */ + ot->exec= sticky_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int sticky_remove_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Mesh *me; + + if(!ob || ob->type!=OB_MESH) + return OPERATOR_CANCELLED; + + me= (Mesh*)ob->data; + + if(!me->msticky) + return OPERATOR_CANCELLED; + + CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert); + me->msticky= NULL; + + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void MESH_OT_sticky_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Sticky"; + ot->idname= "MESH_OT_sticky_remove"; + + /* api callbacks */ + ot->exec= sticky_remove_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 5a86180a60f..2a9357ed0f0 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -183,6 +183,12 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_knife_cut); WM_operatortype_append(MESH_OT_rip); + WM_operatortype_append(MESH_OT_uv_texture_add); + WM_operatortype_append(MESH_OT_uv_texture_remove); + WM_operatortype_append(MESH_OT_vertex_color_add); + WM_operatortype_append(MESH_OT_vertex_color_remove); + WM_operatortype_append(MESH_OT_sticky_add); + WM_operatortype_append(MESH_OT_sticky_remove); } /* note mesh keymap also for other space? */ diff --git a/source/blender/editors/object/editkey.c b/source/blender/editors/object/editkey.c index 913046c5ab8..1c31c7c7653 100644 --- a/source/blender/editors/object/editkey.c +++ b/source/blender/editors/object/editkey.c @@ -55,6 +55,7 @@ #include "BKE_action.h" #include "BKE_anim.h" +#include "BKE_context.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" #include "BKE_global.h" @@ -70,11 +71,15 @@ #include "ED_object.h" +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + #include "object_intern.h" /* XXX */ static void BIF_undo_push() {} -static void error() {} /* XXX */ #if 0 // XXX old animation system @@ -394,25 +399,6 @@ void insert_curvekey(Scene *scene, Curve *cu, short rel) /* ******************** */ -void insert_shapekey(Scene *scene, Object *ob) -{ - if(get_mesh(ob) && get_mesh(ob)->mr) { - error("Cannot create shape keys on a multires mesh."); - } - else { - Key *key; - - if(ob->type==OB_MESH) insert_meshkey(scene, ob->data, 1); - else if ELEM(ob->type, OB_CURVE, OB_SURF) insert_curvekey(scene, ob->data, 1); - else if(ob->type==OB_LATTICE) insert_lattkey(scene, ob->data, 1); - - key= ob_get_key(ob); - ob->shapenr= BLI_countlist(&key->block); - - BIF_undo_push("Add Shapekey"); - } -} - void delete_key(Scene *scene, Object *ob) { KeyBlock *kb, *rkb; @@ -473,6 +459,123 @@ void delete_key(Scene *scene, Object *ob) BIF_undo_push("Delete Shapekey"); } +/********************** shape key operators *********************/ + +static int shape_key_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Key *key; + + if(!ob) + return OPERATOR_CANCELLED; + + if(ob->type==OB_MESH) insert_meshkey(scene, ob->data, 1); + else if ELEM(ob->type, OB_CURVE, OB_SURF) insert_curvekey(scene, ob->data, 1); + else if(ob->type==OB_LATTICE) insert_lattkey(scene, ob->data, 1); + + key= ob_get_key(ob); + ob->shapenr= BLI_countlist(&key->block); + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_shape_key_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Shape Key"; + ot->idname= "OBJECT_OT_shape_key_add"; + + /* api callbacks */ + ot->exec= shape_key_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int shape_key_remove_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Scene *scene= CTX_data_scene(C); + Main *bmain= CTX_data_main(C); + KeyBlock *kb, *rkb; + Key *key; + //IpoCurve *icu; + + if(!ob) + return OPERATOR_CANCELLED; + + key= ob_get_key(ob); + if(key==NULL) + return OPERATOR_CANCELLED; + + kb= BLI_findlink(&key->block, ob->shapenr-1); + + if(kb) { + for(rkb= key->block.first; rkb; rkb= rkb->next) + if(rkb->relative == ob->shapenr-1) + rkb->relative= 0; + + BLI_remlink(&key->block, kb); + key->totkey--; + if(key->refkey== kb) + key->refkey= key->block.first; + + if(kb->data) MEM_freeN(kb->data); + MEM_freeN(kb); + + for(kb= key->block.first; kb; kb= kb->next) + if(kb->adrcode>=ob->shapenr) + kb->adrcode--; + +#if 0 // XXX old animation system + if(key->ipo) { + + for(icu= key->ipo->curve.first; icu; icu= icu->next) { + if(icu->adrcode==ob->shapenr-1) { + BLI_remlink(&key->ipo->curve, icu); + free_ipo_curve(icu); + break; + } + } + for(icu= key->ipo->curve.first; icu; icu= icu->next) + if(icu->adrcode>=ob->shapenr) + icu->adrcode--; + } +#endif // XXX old animation system + + if(ob->shapenr>1) ob->shapenr--; + } + + if(key->totkey==0) { + if(GS(key->from->name)==ID_ME) ((Mesh *)key->from)->key= NULL; + else if(GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL; + else if(GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL; + + free_libblock_us(&(bmain->key), key); + } + + DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_shape_key_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Shape Key"; + ot->idname= "OBJECT_OT_shape_key_remove"; + + /* api callbacks */ + ot->exec= shape_key_remove_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + void move_keys(Object *ob) { #if 0 @@ -560,3 +663,4 @@ void move_keys(Object *ob) BIF_undo_push("Move Shapekey(s)"); #endif } + diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 1eb867e19a0..a52acdd4e1e 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -92,5 +92,19 @@ void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot); /* editconstraint.c */ void OBJECT_OT_constraint_add(struct wmOperatorType *ot); +/* object_vgroup.c */ +void OBJECT_OT_vertex_group_add(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_remove(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_assign(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_remove_from(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_select(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_deselect(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_copy_to_linked(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_copy(struct wmOperatorType *ot); + +/* editkey.c */ +void OBJECT_OT_shape_key_add(struct wmOperatorType *ot); +void OBJECT_OT_shape_key_remove(struct wmOperatorType *ot); + #endif /* ED_OBJECT_INTERN_H */ diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index cfee6a55152..6fa78a53840 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -104,6 +104,18 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_modifier_mdef_bind); WM_operatortype_append(OBJECT_OT_constraint_add); + + WM_operatortype_append(OBJECT_OT_vertex_group_add); + WM_operatortype_append(OBJECT_OT_vertex_group_remove); + WM_operatortype_append(OBJECT_OT_vertex_group_assign); + WM_operatortype_append(OBJECT_OT_vertex_group_remove_from); + WM_operatortype_append(OBJECT_OT_vertex_group_select); + WM_operatortype_append(OBJECT_OT_vertex_group_deselect); + WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_linked); + WM_operatortype_append(OBJECT_OT_vertex_group_copy); + + WM_operatortype_append(OBJECT_OT_shape_key_add); + WM_operatortype_append(OBJECT_OT_shape_key_remove); } void ED_keymap_object(wmWindowManager *wm) diff --git a/source/blender/editors/mesh/editdeform.c b/source/blender/editors/object/object_vgroup.c index 3ccd4d56ece..fb71fc09108 100644 --- a/source/blender/editors/mesh/editdeform.c +++ b/source/blender/editors/object/object_vgroup.c @@ -48,19 +48,26 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" +#include "BKE_context.h" #include "BKE_customdata.h" -#include "BKE_DerivedMesh.h" -#include "BKE_depsgraph.h" #include "BKE_deform.h" +#include "BKE_depsgraph.h" +#include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_lattice.h" #include "BKE_mesh.h" #include "BKE_utildefines.h" +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + #include "ED_mesh.h" #include "ED_view3d.h" -#include "mesh_intern.h" + +#include "object_intern.h" /* XXX */ static void BIF_undo_push() {} @@ -719,18 +726,13 @@ void add_vert_to_defgroup (Object *ob, bDeformGroup *dg, int vertnum, } /* Only available in editmode */ -void assign_verts_defgroup (Object *obedit, float weight) +void assign_verts_defgroup (Object *ob, float weight) { - Object *ob; EditVert *eve; bDeformGroup *dg, *eg; MDeformWeight *newdw; MDeformVert *dvert; int i, done; - -// XXX if(multires_level1_test()) return; - - ob= obedit; if (!ob) return; @@ -883,18 +885,13 @@ float get_vert_defgroup (Object *ob, bDeformGroup *dg, int vertnum) /* Only available in editmode */ /* removes from active defgroup, if allverts==0 only selected vertices */ -void remove_verts_defgroup (Object *obedit, int allverts) +void remove_verts_defgroup (Object *ob, int allverts) { - Object *ob; EditVert *eve; MDeformVert *dvert; MDeformWeight *newdw; bDeformGroup *dg, *eg; int i; - -// XXX if(multires_level1_test()) return; - - ob= obedit; if (!ob) return; @@ -966,14 +963,10 @@ void remove_verts_defgroup (Object *obedit, int allverts) /* Only available in editmode */ /* removes from all defgroup, if allverts==0 only selected vertices */ -void remove_verts_defgroups(Object *obedit, int allverts) +void remove_verts_defgroups(Object *ob, int allverts) { - Object *ob; int actdef, defCount; - -// XXX if (multires_level1_test()) return; - ob= obedit; if (ob == NULL) return; actdef= ob->actdef; @@ -1107,4 +1100,245 @@ void vgroup_operation_with_menu(Object *ob) } } +/********************** vertex group operators *********************/ + +static int vertex_group_add_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Scene *scene= CTX_data_scene(C); + + if(!ob) + return OPERATOR_CANCELLED; + + add_defgroup(ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_vertex_group_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Vertex Group"; + ot->idname= "OBJECT_OT_vertex_group_add"; + + /* api callbacks */ + ot->exec= vertex_group_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int vertex_group_remove_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Scene *scene= CTX_data_scene(C); + + if(!ob) + return OPERATOR_CANCELLED; + + if(scene->obedit == ob) { + del_defgroup(ob); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } + else { + del_defgroup_in_object_mode(ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + } + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Vertex Group"; + ot->idname= "OBJECT_OT_vertex_group_remove"; + + /* api callbacks */ + ot->exec= vertex_group_remove_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int vertex_group_assign_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + ToolSettings *ts= CTX_data_tool_settings(C); + Object *ob= CTX_data_edit_object(C); + + if(!ob) + return OPERATOR_CANCELLED; + + assign_verts_defgroup(ob, ts->vgroup_weight); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Assign Vertex Group"; + ot->idname= "OBJECT_OT_vertex_group_assign"; + + /* api callbacks */ + ot->exec= vertex_group_assign_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int vertex_group_remove_from_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_edit_object(C); + + if(!ob) + return OPERATOR_CANCELLED; + + remove_verts_defgroup(ob, 0); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove from Vertex Group"; + ot->idname= "OBJECT_OT_vertex_group_remove_from"; + + /* api callbacks */ + ot->exec= vertex_group_remove_from_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int vertex_group_select_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_edit_object(C); + + if(!ob) + return OPERATOR_CANCELLED; + + sel_verts_defgroup(ob, 1); /* runs countall() */ + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_vertex_group_select(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Select Vertex Group"; + ot->idname= "OBJECT_OT_vertex_group_select"; + + /* api callbacks */ + ot->exec= vertex_group_select_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int vertex_group_deselect_exec(bContext *C, wmOperator *op) +{ + Object *ob= CTX_data_edit_object(C); + + if(!ob) + return OPERATOR_CANCELLED; + + sel_verts_defgroup(ob, 0); /* runs countall() */ + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Deselect Vertex Group"; + ot->idname= "OBJECT_OT_vertex_group_deselect"; + + /* api callbacks */ + ot->exec= vertex_group_deselect_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int vertex_group_copy_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + + if(!ob) + return OPERATOR_CANCELLED; + + duplicate_defgroup(ob); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_vertex_group_copy(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Vertex Group"; + ot->idname= "OBJECT_OT_vertex_group_copy"; + + /* api callbacks */ + ot->exec= vertex_group_copy_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; + Base *base; + int retval= OPERATOR_CANCELLED; + + if(!ob) + return retval; + + for(base=scene->base.first; base; base= base->next) { + if(base->object->type==ob->type) { + if(base->object!=ob && base->object->data==ob->data) { + BLI_freelistN(&base->object->defbase); + BLI_duplicatelist(&base->object->defbase, &ob->defbase); + base->object->actdef= ob->actdef; + + DAG_object_flush_update(scene, base->object, OB_RECALC_DATA); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, base->object); + + retval = OPERATOR_FINISHED; + } + } + } + + return retval; +} + +void OBJECT_OT_vertex_group_copy_to_linked(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Vertex Group to Linked"; + ot->idname= "OBJECT_OT_vertex_group_copy_to_linked"; + + /* api callbacks */ + ot->exec= vertex_group_copy_to_linked_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index f9732551545..b89a13ce218 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -331,6 +331,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case NC_SCENE: switch(wmn->data) { case ND_FRAME: + case ND_MODE: ED_area_tag_redraw(sa); break; |