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
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.
-rw-r--r--source/blender/blenkernel/BKE_customdata.h1
-rw-r--r--source/blender/blenkernel/intern/customdata.c8
-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
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c13
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c1
8 files changed, 59 insertions, 43 deletions
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 36733d1ced0..a51de2d4ae1 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -259,6 +259,7 @@ int CustomData_get_active_layer_index(const struct CustomData *data, int type);
int CustomData_get_render_layer_index(const struct CustomData *data, int type);
int CustomData_get_clone_layer_index(const struct CustomData *data, int type);
int CustomData_get_stencil_layer_index(const struct CustomData *data, int type);
+int CustomData_get_named_layer(const struct CustomData *data, int type, const char *name);
int CustomData_get_active_layer(const struct CustomData *data, int type);
int CustomData_get_render_layer(const struct CustomData *data, int type);
int CustomData_get_clone_layer(const struct CustomData *data, int type);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 1cefd65bbc5..1f9c067e4a6 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1458,6 +1458,14 @@ int CustomData_get_stencil_layer_index(const CustomData *data, int type)
/* -------------------------------------------------------------------- */
/* index values per layer type */
+int CustomData_get_named_layer(const struct CustomData *data, int type, const char *name)
+{
+ const int named_index = CustomData_get_named_layer_index(data, type, name);
+ const int layer_index = data->typemap[type];
+ BLI_assert(customdata_typemap_is_valid(data));
+ return (named_index != -1) ? named_index - layer_index : -1;
+}
+
int CustomData_get_active_layer(const CustomData *data, int type)
{
const int layer_index = data->typemap[type];
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);
}
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index eb9d1af02cb..8a98b4b055e 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -1284,6 +1284,13 @@ static PointerRNA rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C,
return ptr;
}
+static void rna_Mesh_vertex_color_remove(struct Mesh *me, ReportList *reports, CustomDataLayer *layer)
+{
+ if (ED_mesh_color_remove_named(me, layer->name) == false) {
+ BKE_reportf(reports, RPT_ERROR, "vertex color '%s' not found", layer->name);
+ }
+}
+
static PointerRNA rna_Mesh_tessface_vertex_color_new(struct Mesh *me, struct bContext *C, ReportList *reports,
const char *name)
{
@@ -2408,14 +2415,12 @@ static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_flag(parm, PROP_RNAPTR);
RNA_def_function_return(func, parm);
-#if 0
func = RNA_def_function(srna, "remove", "rna_Mesh_vertex_color_remove");
RNA_def_function_ui_description(func, "Remove a vertex color layer");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ parm = RNA_def_pointer(func, "layer", "MeshLoopColorLayer", "", "The layer to remove");
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
-#endif
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "MeshLoopColorLayer");
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 392655bb1b1..19f128e094d 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -372,6 +372,7 @@ void ED_mesh_faces_remove(struct Mesh *mesh, struct ReportList *reports, int cou
void ED_mesh_material_link(struct Mesh *mesh, struct Material *ma) {}
int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me) {return 0;}
int ED_mesh_uv_texture_add(struct bContext *C, struct Mesh *me) {return 0;}
+bool ED_mesh_color_remove_named(struct Mesh *me, const char *name) { return false; }
void ED_object_constraint_dependency_update(struct Scene *scene, struct Object *ob) {}
void ED_object_constraint_update(struct Object *ob) {}
struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, char *name) {return (struct bDeformGroup *) NULL;}