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:
authorJoshua Leung <aligorith@gmail.com>2009-07-02 07:32:57 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-02 07:32:57 +0400
commitb1a106dd49a8653977cdfd722b1d30abf827fa28 (patch)
tree8e222aadcd1b2bfd92a8ceb42f0cbd0333466b93 /source/blender/makesrna/intern/rna_object.c
parent78939898c735d6f2048e9fc2aa64a3188ff5732f (diff)
NLA SoC: Merge from 2.5
21210 to 21300 Note to self: the next merge will be messy again, since 2 commits occurred this one was complete
Diffstat (limited to 'source/blender/makesrna/intern/rna_object.c')
-rw-r--r--source/blender/makesrna/intern/rna_object.c103
1 files changed, 92 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 3b54409ffb0..2be0d115dc9 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 */
@@ -1148,13 +1227,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);
}