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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-02 02:25:49 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-02 02:25:49 +0400
commit421f44278cebff49a1485251f92a4277934c4e4c (patch)
treecdc18b03a3d2c3f17c892f0c4e1e894e91a9610a /source/blender/makesrna
parentcda566d6464cac92a766df0b065d43d8240e23f2 (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/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c4
-rw-r--r--source/blender/makesrna/intern/rna_context.c12
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c230
-rw-r--r--source/blender/makesrna/intern/rna_object.c103
-rw-r--r--source/blender/makesrna/intern/rna_scene.c5
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c2
6 files changed, 292 insertions, 64 deletions
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 8200a21f4ac..5c4b6a95524 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -535,10 +535,8 @@ static void rna_def_constraint_locate_like(BlenderRNA *brna)
srna= RNA_def_struct(brna, "CopyLocationConstraint", "Constraint");
RNA_def_struct_ui_text(srna, "Copy Location Constraint", "Copies the location of the target.");
- RNA_def_struct_sdna(srna, "bConstraint");
-
prop= RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_PERCENTAGE);
- RNA_def_property_float_sdna(prop, NULL, "headtail");
+ RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1.");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index 378498c8e0a..7fa27348002 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -96,6 +96,12 @@ static PointerRNA rna_Context_scene_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_Scene, CTX_data_scene(C));
}
+static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr)
+{
+ bContext *C= (bContext*)ptr->data;
+ return rna_pointer_inherit_refine(ptr, &RNA_ToolSettings, CTX_data_tool_settings(C));
+}
+
#else
void RNA_def_context(BlenderRNA *brna)
@@ -153,6 +159,12 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Scene");
RNA_def_property_pointer_funcs(prop, "rna_Context_scene_get", NULL, NULL);
+
+ prop= RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "ToolSettings");
+ RNA_def_property_pointer_funcs(prop, "rna_Context_tool_settings_get", NULL, NULL);
+
}
#endif
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 41d64a8dbb9..39fa6f36f23 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -34,10 +34,37 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "BKE_customdata.h"
-
#ifdef RNA_RUNTIME
+#include "DNA_scene_types.h"
+
+#include "BLI_editVert.h"
+
+#include "BKE_customdata.h"
+#include "BKE_depsgraph.h"
+#include "BKE_main.h"
+#include "BKE_mesh.h"
+#include "BKE_utildefines.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+static void rna_Mesh_update_data(bContext *C, PointerRNA *ptr)
+{
+ Main *bmain= CTX_data_main(C);
+ Scene *scene= CTX_data_scene(C);
+ ID *id= ptr->id.data;
+ Object *ob;
+
+ for(ob=bmain->object.first; ob; ob= ob->id.next) {
+ if(ob->data == id) {
+ /* XXX this will loop over all objects again (slow) */
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+ }
+ }
+}
+
static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
{
MVert *mvert= (MVert*)ptr->data;
@@ -183,13 +210,19 @@ static void rna_MeshFace_material_index_range(PointerRNA *ptr, int *min, int *ma
*max= me->totcol-1;
}
+static CustomData *rna_mesh_fdata(Mesh *me)
+{
+ return (me->edit_mesh)? &me->edit_mesh->fdata: &me->fdata;
+}
+
static int rna_CustomDataLayer_length(PointerRNA *ptr, int type)
{
Mesh *me= (Mesh*)ptr->id.data;
+ CustomData *fdata= rna_mesh_fdata(me);
CustomDataLayer *layer;
int i, length= 0;
- for(layer=me->fdata.layers, i=0; i<me->fdata.totlayer; layer++, i++)
+ for(layer=fdata->layers, i=0; i<fdata->totlayer; layer++, i++)
if(layer->type == type)
length++;
@@ -199,64 +232,96 @@ static int rna_CustomDataLayer_length(PointerRNA *ptr, int type)
static int rna_CustomDataLayer_active_get(PointerRNA *ptr, int type, int render)
{
Mesh *me= (Mesh*)ptr->id.data;
- int n= ((CustomDataLayer*)ptr->data) - me->fdata.layers;
+ CustomData *fdata= rna_mesh_fdata(me);
+ int n= ((CustomDataLayer*)ptr->data) - fdata->layers;
- if(render) return (n == CustomData_get_render_layer_index(&me->fdata, type));
- else return (n == CustomData_get_active_layer_index(&me->fdata, type));
+ if(render) return (n == CustomData_get_render_layer_index(fdata, type));
+ else return (n == CustomData_get_active_layer_index(fdata, type));
}
static void rna_CustomDataLayer_active_set(PointerRNA *ptr, int value, int type, int render)
{
Mesh *me= (Mesh*)ptr->id.data;
- int n= ((CustomDataLayer*)ptr->data) - me->fdata.layers;
+ CustomData *fdata= rna_mesh_fdata(me);
+ int n= ((CustomDataLayer*)ptr->data) - fdata->layers;
if(value == 0)
return;
- if(render) CustomData_set_layer_render_index(&me->fdata, type, n);
- else CustomData_set_layer_active_index(&me->fdata, type, n);
+ if(render) CustomData_set_layer_render_index(fdata, type, n);
+ else CustomData_set_layer_active_index(fdata, type, n);
}
-static int rna_uv_layer_check(CollectionPropertyIterator *iter, void *data)
+static int rna_uv_texture_check(CollectionPropertyIterator *iter, void *data)
{
CustomDataLayer *layer= (CustomDataLayer*)data;
return (layer->type != CD_MTFACE);
}
-static void rna_Mesh_uv_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+static void rna_Mesh_uv_textures_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
- rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_uv_layer_check);
+ CustomData *fdata= rna_mesh_fdata(me);
+ rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_uv_texture_check);
}
-static int rna_Mesh_uv_layers_length(PointerRNA *ptr)
+static int rna_Mesh_uv_textures_length(PointerRNA *ptr)
{
return rna_CustomDataLayer_length(ptr, CD_MTFACE);
}
-static PointerRNA rna_Mesh_active_uv_layer_get(PointerRNA *ptr)
+static PointerRNA rna_Mesh_active_uv_texture_get(PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
- int index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE);
- CustomDataLayer *cdl= (index == -1)? NULL: &me->fdata.layers[index];
+ CustomData *fdata= rna_mesh_fdata(me);
+ int index= CustomData_get_active_layer_index(fdata, CD_MTFACE);
+ CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index];
return rna_pointer_inherit_refine(ptr, &RNA_MeshTextureFaceLayer, cdl);
}
-static void rna_Mesh_active_uv_layer_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Mesh_active_uv_texture_set(PointerRNA *ptr, PointerRNA value)
{
Mesh *me= (Mesh*)ptr->data;
+ CustomData *fdata= rna_mesh_fdata(me);
CustomDataLayer *cdl;
int a;
- for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) {
+ for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
if(value.data == cdl) {
- CustomData_set_layer_active_index(&me->fdata, CD_MTFACE, a);
+ CustomData_set_layer_active_index(fdata, CD_MTFACE, a);
+ mesh_update_customdata_pointers(me);
return;
}
}
}
+static int rna_Mesh_active_uv_texture_index_get(PointerRNA *ptr)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ CustomData *fdata= rna_mesh_fdata(me);
+ return CustomData_get_active_layer(fdata, CD_MTFACE);
+}
+
+static void rna_Mesh_active_uv_texture_index_set(PointerRNA *ptr, int value)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ CustomData *fdata= rna_mesh_fdata(me);
+
+ CustomData_set_layer_active(fdata, CD_MTFACE, value);
+ mesh_update_customdata_pointers(me);
+}
+
+static void rna_Mesh_active_uv_texture_index_range(PointerRNA *ptr, int *min, int *max)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ CustomData *fdata= rna_mesh_fdata(me);
+
+ *min= 0;
+ *max= CustomData_number_of_layers(fdata, CD_MTFACE)-1;
+ *max= MAX2(0, *max);
+}
+
static void rna_MeshTextureFace_uv1_get(PointerRNA *ptr, float *values)
{
MTFace *mtface= (MTFace*)ptr->data;
@@ -354,46 +419,84 @@ static void rna_MeshTextureFaceLayer_active_set(PointerRNA *ptr, int value)
rna_CustomDataLayer_active_set(ptr, value, CD_MTFACE, 0);
}
-static int rna_vcol_layer_check(CollectionPropertyIterator *iter, void *data)
+static void rna_MeshTextureFaceLayer_name_set(PointerRNA *ptr, const char *value)
+{
+ Mesh *me= (Mesh*)ptr->id.data;
+ CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
+ BLI_strncpy(cdl->name, value, sizeof(cdl->name));
+ CustomData_set_layer_unique_name(&me->fdata, cdl - me->fdata.layers);
+}
+
+static int rna_vertex_color_check(CollectionPropertyIterator *iter, void *data)
{
CustomDataLayer *layer= (CustomDataLayer*)data;
return (layer->type != CD_MCOL);
}
-static void rna_Mesh_vcol_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+static void rna_Mesh_vertex_colors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
- rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_vcol_layer_check);
+ CustomData *fdata= rna_mesh_fdata(me);
+ rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_vertex_color_check);
}
-static int rna_Mesh_vcol_layers_length(PointerRNA *ptr)
+static int rna_Mesh_vertex_colors_length(PointerRNA *ptr)
{
return rna_CustomDataLayer_length(ptr, CD_MCOL);
}
-static PointerRNA rna_Mesh_active_vcol_layer_get(PointerRNA *ptr)
+static PointerRNA rna_Mesh_active_vertex_color_get(PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
- int index= CustomData_get_active_layer_index(&me->fdata, CD_MCOL);
- CustomDataLayer *cdl= (index == -1)? NULL: &me->fdata.layers[index];
+ CustomData *fdata= rna_mesh_fdata(me);
+ int index= CustomData_get_active_layer_index(fdata, CD_MCOL);
+ CustomDataLayer *cdl= (index == -1)? NULL: &fdata->layers[index];
return rna_pointer_inherit_refine(ptr, &RNA_MeshColorLayer, cdl);
}
-static void rna_Mesh_active_vcol_layer_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Mesh_active_vertex_color_set(PointerRNA *ptr, PointerRNA value)
{
Mesh *me= (Mesh*)ptr->data;
+ CustomData *fdata= rna_mesh_fdata(me);
CustomDataLayer *cdl;
int a;
- for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) {
+ for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
if(value.data == cdl) {
- CustomData_set_layer_active_index(&me->fdata, CD_MCOL, a);
+ CustomData_set_layer_active_index(fdata, CD_MCOL, a);
+ mesh_update_customdata_pointers(me);
return;
}
}
}
+static int rna_Mesh_active_vertex_color_index_get(PointerRNA *ptr)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ CustomData *fdata= rna_mesh_fdata(me);
+ return CustomData_get_active_layer(fdata, CD_MCOL);
+}
+
+static void rna_Mesh_active_vertex_color_index_set(PointerRNA *ptr, int value)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ CustomData *fdata= rna_mesh_fdata(me);
+
+ CustomData_set_layer_active(fdata, CD_MCOL, value);
+ mesh_update_customdata_pointers(me);
+}
+
+static void rna_Mesh_active_vertex_color_index_range(PointerRNA *ptr, int *min, int *max)
+{
+ Mesh *me= (Mesh*)ptr->data;
+ CustomData *fdata= rna_mesh_fdata(me);
+
+ *min= 0;
+ *max= CustomData_number_of_layers(fdata, CD_MCOL)-1;
+ *max= MAX2(0, *max);
+}
+
static void rna_MeshColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
@@ -427,6 +530,14 @@ static void rna_MeshColorLayer_active_set(PointerRNA *ptr, int value)
rna_CustomDataLayer_active_set(ptr, value, CD_MCOL, 0);
}
+static void rna_MeshColorLayer_name_set(PointerRNA *ptr, const char *value)
+{
+ Mesh *me= (Mesh*)ptr->id.data;
+ CustomDataLayer *cdl= (CustomDataLayer*)ptr->data;
+ BLI_strncpy(cdl->name, value, sizeof(cdl->name));
+ CustomData_set_layer_unique_name(&me->fdata, cdl - me->fdata.layers);
+}
+
static void rna_MeshFloatPropertyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
@@ -449,7 +560,8 @@ static int rna_float_layer_check(CollectionPropertyIterator *iter, void *data)
static void rna_Mesh_float_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
- rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_float_layer_check);
+ CustomData *fdata= rna_mesh_fdata(me);
+ rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_float_layer_check);
}
static int rna_Mesh_float_layers_length(PointerRNA *ptr)
@@ -479,7 +591,8 @@ static int rna_MeshIntPropertyLayer_data_length(PointerRNA *ptr)
static void rna_Mesh_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
- rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_int_layer_check);
+ CustomData *fdata= rna_mesh_fdata(me);
+ rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_int_layer_check);
}
static int rna_Mesh_int_layers_length(PointerRNA *ptr)
@@ -509,7 +622,8 @@ static int rna_MeshStringPropertyLayer_data_length(PointerRNA *ptr)
static void rna_Mesh_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
- rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_string_layer_check);
+ CustomData *fdata= rna_mesh_fdata(me);
+ rna_iterator_array_begin(iter, (void*)fdata->layers, sizeof(CustomDataLayer), fdata->totlayer, rna_string_layer_check);
}
static int rna_Mesh_string_layers_length(PointerRNA *ptr)
@@ -568,17 +682,18 @@ static char *rna_MeshVertex_path(PointerRNA *ptr)
static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr)
{
- return BLI_sprintfN("uv_layers[%s]", ((CustomDataLayer*)ptr->data)->name);
+ return BLI_sprintfN("uv_textures[%s]", ((CustomDataLayer*)ptr->data)->name);
}
static char *rna_CustomDataData_path(PointerRNA *ptr, char *collection, int type)
{
Mesh *me= (Mesh*)ptr->id.data;
+ CustomData *fdata= rna_mesh_fdata(me);
CustomDataLayer *cdl;
int a;
size_t b;
- for(cdl=me->fdata.layers, a=0; a<me->fdata.totlayer; cdl++, a++) {
+ for(cdl=fdata->layers, a=0; a<fdata->totlayer; cdl++, a++) {
if(cdl->type == type) {
b= ((char*)ptr->data - ((char*)cdl->data))/CustomData_sizeof(type);
if(b >= 0 && b < me->totface)
@@ -591,17 +706,17 @@ static char *rna_CustomDataData_path(PointerRNA *ptr, char *collection, int type
static char *rna_MeshTextureFace_path(PointerRNA *ptr)
{
- return rna_CustomDataData_path(ptr, "uv_layers", CD_MTFACE);
+ return rna_CustomDataData_path(ptr, "uv_textures", CD_MTFACE);
}
static char *rna_MeshColorLayer_path(PointerRNA *ptr)
{
- return BLI_sprintfN("vcol_layers[%s]", ((CustomDataLayer*)ptr->data)->name);
+ return BLI_sprintfN("vertex_colors[%s]", ((CustomDataLayer*)ptr->data)->name);
}
static char *rna_MeshColor_path(PointerRNA *ptr)
{
- return rna_CustomDataData_path(ptr, "vcol_layers", CD_MCOL);
+ return rna_CustomDataData_path(ptr, "vertex_colors", CD_MCOL);
}
static char *rna_MeshSticky_path(PointerRNA *ptr)
@@ -798,6 +913,7 @@ static void rna_def_mtface(BlenderRNA *brna)
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshTextureFaceLayer_name_set");
RNA_def_property_ui_text(prop, "Name", "");
prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
@@ -935,6 +1051,7 @@ static void rna_def_mcol(BlenderRNA *brna)
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshColorLayer_name_set");
RNA_def_property_ui_text(prop, "Name", "");
prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
@@ -1120,33 +1237,45 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "MeshSticky");
RNA_def_property_ui_text(prop, "Sticky", "Sticky texture coordinates.");
- /* UV layers */
+ /* UV textures */
- prop= RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE);
+ prop= RNA_def_property(srna, "uv_textures", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
- RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0, 0, 0);
+ RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_textures_begin", 0, 0, 0, "rna_Mesh_uv_textures_length", 0, 0, 0, 0);
RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
- RNA_def_property_ui_text(prop, "UV Layers", "");
+ RNA_def_property_ui_text(prop, "UV Textures", "");
- prop= RNA_def_property(srna, "active_uv_layer", PROP_POINTER, PROP_UNSIGNED);
+ prop= RNA_def_property(srna, "active_uv_texture", PROP_POINTER, PROP_UNSIGNED);
RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
- RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_layer_get", "rna_Mesh_active_uv_layer_set", NULL);
+ RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_uv_texture_get", "rna_Mesh_active_uv_texture_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Active UV Layer", "Active UV layer.");
+ RNA_def_property_ui_text(prop, "Active UV Texture", "Active UV texture.");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+
+ prop= RNA_def_property(srna, "active_uv_texture_index", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_funcs(prop, "rna_Mesh_active_uv_texture_index_get", "rna_Mesh_active_uv_texture_index_set", "rna_Mesh_active_uv_texture_index_range");
+ RNA_def_property_ui_text(prop, "Active UV Texture Index", "Active UV texture index.");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
- /* VCol layers */
+ /* Vertex colors */
- prop= RNA_def_property(srna, "vcol_layers", PROP_COLLECTION, PROP_NONE);
+ prop= RNA_def_property(srna, "vertex_colors", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
- RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0, 0, 0);
+ RNA_def_property_collection_funcs(prop, "rna_Mesh_vertex_colors_begin", 0, 0, 0, "rna_Mesh_vertex_colors_length", 0, 0, 0, 0);
RNA_def_property_struct_type(prop, "MeshColorLayer");
- RNA_def_property_ui_text(prop, "Vertex Color Layers", "");
+ RNA_def_property_ui_text(prop, "Vertex Colors", "");
- prop= RNA_def_property(srna, "active_vcol_layer", PROP_POINTER, PROP_UNSIGNED);
+ prop= RNA_def_property(srna, "active_vertex_color", PROP_POINTER, PROP_UNSIGNED);
RNA_def_property_struct_type(prop, "MeshColorLayer");
- RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vcol_layer_get", "rna_Mesh_active_vcol_layer_set", NULL);
+ RNA_def_property_pointer_funcs(prop, "rna_Mesh_active_vertex_color_get", "rna_Mesh_active_vertex_color_set", NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer.");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+
+ prop= RNA_def_property(srna, "active_vertex_color_index", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_funcs(prop, "rna_Mesh_active_vertex_color_index_get", "rna_Mesh_active_vertex_color_index_set", "rna_Mesh_active_vertex_color_index_range");
+ RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index.");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
prop= RNA_def_property(srna, "float_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
@@ -1182,6 +1311,7 @@ static void rna_def_mesh(BlenderRNA *brna)
prop= RNA_def_property(srna, "double_sided", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_TWOSIDED);
RNA_def_property_ui_text(prop, "Double Sided", "Render/display the mesh with double or single sided lighting");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
prop= RNA_def_property(srna, "texco_mesh", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "texcomesh");
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 9b3100c733b..947846f8d8d 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -42,10 +42,13 @@
#ifdef RNA_RUNTIME
+#include "DNA_key_types.h"
+
#include "BKE_armature.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
+#include "BKE_key.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_particle.h"
@@ -131,6 +134,27 @@ static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_VertexGroup, BLI_findlink(&ob->defbase, ob->actdef));
}
+static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
+{
+ Object *ob= (Object*)ptr->id.data;
+ return MAX2(ob->actdef-1, 0);
+}
+
+static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
+{
+ Object *ob= (Object*)ptr->id.data;
+ ob->actdef= value+1;
+}
+
+static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min, int *max)
+{
+ Object *ob= (Object*)ptr->id.data;
+
+ *min= 0;
+ *max= BLI_countlist(&ob->defbase)-1;
+ *max= MAX2(0, *max);
+}
+
void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
{
Object *ob= (Object*)ptr->id.data;
@@ -228,11 +252,23 @@ void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *res
BLI_strncpy(result, "", maxlen);
}
+static int rna_Object_active_material_index_get(PointerRNA *ptr)
+{
+ Object *ob= (Object*)ptr->id.data;
+ return MAX2(ob->actcol-1, 0);
+}
+
+static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
+{
+ Object *ob= (Object*)ptr->id.data;
+ ob->actcol= value+1;
+}
+
static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, int *max)
{
Object *ob= (Object*)ptr->id.data;
- *min= 1;
- *max= ob->totcol;
+ *min= 0;
+ *max= MAX2(ob->totcol-1, 0);
}
static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
@@ -244,14 +280,15 @@ static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *min, int *max)
{
Object *ob= (Object*)ptr->id.data;
- *min= 1;
- *max= BLI_countlist(&ob->particlesystem);
+ *min= 0;
+ *max= BLI_countlist(&ob->particlesystem)-1;
+ *max= MAX2(0, *max);
}
static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
{
Object *ob= (Object*)ptr->id.data;
- return psys_get_current_num(ob) + 1;
+ return psys_get_current_num(ob);
}
static void rna_Object_active_particle_system_index_set(struct PointerRNA *ptr, int value)
@@ -384,6 +421,41 @@ static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
}
}
+static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max)
+{
+ Object *ob= (Object*)ptr->id.data;
+ Key *key= ob_get_key(ob);
+
+ *min= 0;
+ *max= (key)? BLI_countlist(&key->block)-1: 0;
+ *max= MAX2(0, *max);
+}
+
+static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
+{
+ Object *ob= (Object*)ptr->id.data;
+
+ return MAX2(ob->shapenr-1, 0);
+}
+
+static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
+{
+ Object *ob= (Object*)ptr->id.data;
+
+ ob->shapenr= value+1;
+ ob->shapeflag |= OB_SHAPE_TEMPLOCK;
+}
+
+static void rna_Object_shape_key_lock_set(PointerRNA *ptr, int value)
+{
+ Object *ob= (Object*)ptr->id.data;
+
+ if(value) ob->shapeflag |= OB_SHAPE_LOCK;
+ else ob->shapeflag &= ~OB_SHAPE_LOCK;
+
+ ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
+}
+
#else
static void rna_def_vertex_group(BlenderRNA *brna)
@@ -814,7 +886,7 @@ static void rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "actcol");
- RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Object_active_material_index_range");
+ RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range");
RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot.");
/* transform */
@@ -895,8 +967,15 @@ static void rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "active_vertex_group", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "VertexGroup");
- RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", NULL, NULL);
+ RNA_def_property_pointer_funcs(prop, "rna_Object_active_vertex_group_get", "rna_Object_active_vertex_group_set", NULL);
RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data");
+
+ prop= RNA_def_property(srna, "active_vertex_group_index", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "actdef");
+ RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get", "rna_Object_active_vertex_group_index_set", "rna_Object_active_vertex_group_index_range");
+ RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data");
/* empty */
@@ -1171,13 +1250,15 @@ static void rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "shape_key_lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "shapeflag", OB_SHAPE_LOCK);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_boolean_funcs(prop, NULL, "rna_Object_shape_key_lock_set");
RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data");
- prop= RNA_def_property(srna, "active_shape_key", PROP_INT, PROP_NONE);
+ prop= RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "shapenr");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key index.");
+ RNA_def_property_int_funcs(prop, "rna_Object_active_shape_key_index_get", "rna_Object_active_shape_key_index_set", "rna_Object_active_shape_key_index_range");
+ RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index.");
+ RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, "rna_Object_update_data");
RNA_api_object(srna);
}
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 47c9025149a..5f03b7167f4 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -245,6 +245,11 @@ void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, mesh_select_mode_items);
RNA_def_property_ui_text(prop, "Mesh Selection Mode", "Mesh selection and display mode.");
+ prop= RNA_def_property(srna, "vertex_group_weight", PROP_FLOAT, PROP_PERCENTAGE);
+ RNA_def_property_float_sdna(prop, NULL, "vgroup_weight");
+ RNA_def_property_ui_text(prop, "Vertex Group Weight", "Weight to assign in vertex groups.");
+
+ /* Sculpt */
rna_def_sculpt(brna);
}
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index b70112eebed..3df3fad3f15 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -259,6 +259,8 @@ void RNA_api_ui_layout(StructRNA *srna)
func= RNA_def_function(srna, "template_list", "uiTemplateList");
api_ui_item_rna_common(func);
+ parm= RNA_def_pointer(func, "active_data", "AnyType", "", "Data from which to take property for the active element.");
+ RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
parm= RNA_def_string(func, "active_property", "", 0, "", "Identifier of property in data, for the active element.");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_int(func, "rows", 5, 0, INT_MAX, "", "Number of rows to display.", 0, INT_MAX);