Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-03-22 00:15:39 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-03-22 00:15:39 +0400
commitfa1cd9ce9b841510588ff899c2fd8be5a7293ae0 (patch)
tree57e756272e22ff8ab381f8531ae1f68ea9267af7 /source/blender/editors
parent21c55d5304f5e1093d0f8e96cec5bd1014b08c16 (diff)
python api: add functionality to remove vertex color layers.
note: that this intentionally removes check to exit vpaint mode when a vertex color layer is removed, since being in vertex-paint mode without a vertex color layer is supported. also minor change to drawing camera limits while picking from previous commit.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_mesh.h5
-rw-r--r--source/blender/editors/mesh/mesh_data.c58
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c2
-rw-r--r--source/blender/editors/space_view3d/drawobject.c14
4 files changed, 40 insertions, 39 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 8d389946e4a..07073e46642 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -259,8 +259,9 @@ int ED_mesh_uv_texture_remove(struct bContext *C, struct Object *ob, struct Mesh
int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me);
int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum);
int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me, const char *name, int active_set);
-int ED_mesh_color_remove(struct bContext *C, struct Object *ob, struct Mesh *me);
-int ED_mesh_color_remove_named(struct bContext *C, struct Object *ob, struct Mesh *me, const char *name);
+bool ED_mesh_color_remove_index(struct Mesh *me, const int n);
+bool ED_mesh_color_remove_active(struct Mesh *me);
+bool ED_mesh_color_remove_named(struct Mesh *me, const char *name);
/* mesh backup */
typedef struct BMBackup {
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index b6b2550bd45..751529faf82 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -123,9 +123,8 @@ static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_t
}
#define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data)
-static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer)
+static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer)
{
- Mesh *me = ob->data;
CustomData *data;
void *actlayerdata, *rndlayerdata, *clonelayerdata, *stencillayerdata, *layerdata = layer->data;
int type = layer->type;
@@ -162,9 +161,6 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
BKE_mesh_update_customdata_pointers(me, true);
}
- if (!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL && (ob->mode & OB_MODE_VERTEX_PAINT)))
- ED_object_toggle_modes(C, OB_MODE_VERTEX_PAINT);
-
/* reconstruct active layer */
if (actlayerdata != layerdata) {
/* find index */
@@ -435,8 +431,8 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me)
if (!cdlp || !cdlu)
return 0;
- delete_customdata_layer(C, ob, cdlp);
- delete_customdata_layer(C, ob, cdlu);
+ delete_customdata_layer(ob->data, cdlp);
+ delete_customdata_layer(ob->data, cdlu);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
@@ -498,42 +494,46 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes
return layernum;
}
-int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me)
+bool ED_mesh_color_remove_index(Mesh *me, const int n)
{
CustomData *ldata = GET_CD_DATA(me, ldata);
CustomDataLayer *cdl;
int index;
- index = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL);
+ index = CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, n);
cdl = (index == -1) ? NULL : &ldata->layers[index];
if (!cdl)
- return 0;
+ return false;
- delete_customdata_layer(C, ob, cdl);
+ delete_customdata_layer(me, cdl);
DAG_id_tag_update(&me->id, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
+ WM_main_add_notifier(NC_GEOM | ND_DATA, me);
- return 1;
+ return true;
}
-
-int ED_mesh_color_remove_named(bContext *C, Object *ob, Mesh *me, const char *name)
+bool ED_mesh_color_remove_active(Mesh *me)
{
CustomData *ldata = GET_CD_DATA(me, ldata);
- CustomDataLayer *cdl;
- int index;
-
- index = CustomData_get_named_layer_index(ldata, CD_MLOOPCOL, name);
- cdl = (index == -1) ? NULL : &ldata->layers[index];
-
- if (!cdl)
- return 0;
-
- delete_customdata_layer(C, ob, cdl);
- DAG_id_tag_update(&me->id, 0);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
+ const int n = CustomData_get_active_layer(ldata, CD_MLOOPCOL);
+ if (n != -1) {
+ return ED_mesh_color_remove_index(me, n);
+ }
+ else {
+ return false;
+ }
+}
- return 1;
+bool ED_mesh_color_remove_named(Mesh *me, const char *name)
+{
+ CustomData *ldata = GET_CD_DATA(me, ldata);
+ const int n = CustomData_get_named_layer(ldata, CD_MLOOPCOL, name);
+ if (n != -1) {
+ return ED_mesh_color_remove_index(me, n);
+ }
+ else {
+ return false;
+ }
}
/*********************** UV texture operators ************************/
@@ -725,7 +725,7 @@ static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (!ED_mesh_color_remove(C, ob, me))
+ if (!ED_mesh_color_remove_active(me))
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 48316cfccb7..73d3c02c9f1 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -225,7 +225,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
if (!exists)
ED_mesh_color_add(C, scene, ob, ob->data, name, 1);
else
- ED_mesh_color_remove_named(C, ob, ob->data, name);
+ ED_mesh_color_remove_named(ob->data, name);
}
/* Vertex Weight Layer */
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 9e8ab735564..5a537f6f6c5 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -1416,15 +1416,15 @@ static void draw_limit_line(float sta, float end, const short dflag, unsigned in
glVertex3f(0.0, 0.0, -end);
glEnd();
- glPointSize(3.0);
- glBegin(GL_POINTS);
- if (!(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR | DRAW_SCENESET))) {
+ if (!(dflag & DRAW_PICKING)) {
+ glPointSize(3.0);
+ glBegin(GL_POINTS);
cpack(col);
+ glVertex3f(0.0, 0.0, -sta);
+ glVertex3f(0.0, 0.0, -end);
+ glEnd();
+ glPointSize(1.0);
}
- glVertex3f(0.0, 0.0, -sta);
- glVertex3f(0.0, 0.0, -end);
- glEnd();
- glPointSize(1.0);
}