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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-11-28 16:33:56 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-28 16:33:56 +0300
commita2b370dd6f55d6114da3ec1d86788e9c9786822f (patch)
tree8f5adc8b06e8f9506155e4906dd7ff5d11fdc987 /source
parentc4933cccfa74836ff88a6904abfaf52c8e0cde87 (diff)
py/rna api
- object.modifiers.add()/remove() - armature.edit_bones.active wasnt named correctly
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_particle.h2
-rw-r--r--source/blender/blenkernel/intern/particle.c12
-rw-r--r--source/blender/editors/include/ED_object.h2
-rw-r--r--source/blender/editors/object/object_modifier.c17
-rw-r--r--source/blender/editors/object/object_relations.c6
-rw-r--r--source/blender/editors/physics/particle_object.c2
-rw-r--r--source/blender/makesrna/intern/rna_armature.c2
-rw-r--r--source/blender/makesrna/intern/rna_object.c68
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c4
-rw-r--r--source/blender/makesrna/intern/rna_pose.c2
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c2
11 files changed, 96 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 2291601bd47..2199240d77b 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -222,7 +222,7 @@ void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int tim
void psys_particle_on_emitter(struct ParticleSystemModifierData *psmd, int distr, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor);
struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct ParticleSystem *psys);
-void object_add_particle_system(struct Scene *scene, struct Object *ob);
+struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, char *name);
void object_remove_particle_system(struct Scene *scene, struct Object *ob);
struct ParticleSettings *psys_new_settings(char *name, struct Main *main);
struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part);
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index e241d5808cd..bb2f4128891 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3268,14 +3268,14 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa
/************************************************/
/* ParticleSettings handling */
/************************************************/
-void object_add_particle_system(Scene *scene, Object *ob)
+ModifierData *object_add_particle_system(Scene *scene, Object *ob, char *name)
{
ParticleSystem *psys;
ModifierData *md;
ParticleSystemModifierData *psmd;
if(!ob || ob->type != OB_MESH)
- return;
+ return NULL;
psys = ob->particlesystem.first;
for(; psys; psys=psys->next)
@@ -3293,7 +3293,11 @@ void object_add_particle_system(Scene *scene, Object *ob)
strcpy(psys->name, "ParticleSystem");
md= modifier_new(eModifierType_ParticleSystem);
- sprintf(md->name, "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
+
+ if(name) BLI_strncpy(md->name, name, sizeof(md->name));
+ else sprintf(md->name, "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
+ modifier_unique_name(&ob->modifiers, md);
+
psmd= (ParticleSystemModifierData*) md;
psmd->psys=psys;
BLI_addtail(&ob->modifiers, md);
@@ -3304,6 +3308,8 @@ void object_add_particle_system(Scene *scene, Object *ob)
DAG_scene_sort(scene);
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+
+ return md;
}
void object_remove_particle_system(Scene *scene, Object *ob)
{
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 1ac15aa49f6..69b478c6dfa 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -121,7 +121,7 @@ enum {
MODIFIER_APPLY_SHAPE,
} eModifier_Apply_Mode;
-struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, int type);
+struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, char *name, int type);
int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 7ab49f5c838..88763f63f7b 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -43,6 +43,7 @@
#include "BLI_math.h"
#include "BLI_listbase.h"
+#include "BLI_string.h"
#include "BKE_action.h"
#include "BKE_curve.h"
@@ -78,7 +79,7 @@
/******************************** API ****************************/
-ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int type)
+ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, char *name, int type)
{
ModifierData *md=NULL, *new_md=NULL;
ModifierTypeInfo *mti = modifierType_getInfo(type);
@@ -94,7 +95,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *
/* don't need to worry about the new modifier's name, since that is set to the number
* of particle systems which shouldn't have too many duplicates
*/
- object_add_particle_system(scene, ob);
+ new_md = object_add_particle_system(scene, ob, name);
}
else {
/* get new modifier data to add */
@@ -110,8 +111,12 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *
}
else
BLI_addtail(&ob->modifiers, new_md);
-
+
+ if(name)
+ BLI_strncpy(new_md->name, name, sizeof(new_md->name));
+
/* make sure modifier data has unique name */
+
modifier_unique_name(&ob->modifiers, new_md);
/* special cases */
@@ -148,8 +153,10 @@ int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, Mod
if(obmd==md)
break;
- if(!obmd)
+ if(!obmd) {
+ BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'.", ob->id.name, md->name);
return 0;
+ }
/* special cases */
if(md->type == eModifierType_ParticleSystem) {
@@ -482,7 +489,7 @@ static int modifier_add_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
int type= RNA_enum_get(op->ptr, "type");
- if(!ED_object_modifier_add(op->reports, scene, ob, type))
+ if(!ED_object_modifier_add(op->reports, scene, ob, NULL, type))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index c0979e410fd..749b1e34651 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -620,15 +620,15 @@ static int parent_set_exec(bContext *C, wmOperator *op)
switch (partype) {
case PAR_CURVE: /* curve deform */
- md= ED_object_modifier_add(op->reports, scene, ob, eModifierType_Curve);
+ md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Curve);
((CurveModifierData *)md)->object= par;
break;
case PAR_LATTICE: /* lattice deform */
- md= ED_object_modifier_add(op->reports, scene, ob, eModifierType_Lattice);
+ md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Lattice);
((LatticeModifierData *)md)->object= par;
break;
default: /* armature deform */
- md= ED_object_modifier_add(op->reports, scene, ob, eModifierType_Armature);
+ md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Armature);
((ArmatureModifierData *)md)->object= par;
break;
}
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 1ef3ffa6c34..d29280876d0 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -69,7 +69,7 @@ static int particle_system_add_exec(bContext *C, wmOperator *op)
if(!scene || !ob)
return OPERATOR_CANCELLED;
- object_add_particle_system(scene, ob);
+ object_add_particle_system(scene, ob, NULL);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return OPERATOR_FINISHED;
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
index 7986da818c8..57bb88496d3 100644
--- a/source/blender/makesrna/intern/rna_armature.c
+++ b/source/blender/makesrna/intern/rna_armature.c
@@ -662,7 +662,7 @@ static void rna_def_armature_edit_bones(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_struct_sdna(srna, "bArmature");
RNA_def_struct_ui_text(srna, "Armature EditBones", "Collection of armature edit bones.");
- prop= RNA_def_property(srna, "edit_bones", PROP_POINTER, PROP_NONE);
+ prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "EditBone");
RNA_def_property_pointer_sdna(prop, NULL, "act_edbone");
RNA_def_property_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 7b340595f4a..b1e3d9b2408 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -940,13 +940,13 @@ static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
constraints_set_active(&ob->constraints, (bConstraint *)value.data);
}
-static bConstraint *rna_Object_constraints_new(Object *object, bContext *C, int type)
+static bConstraint *rna_Object_constraint_new(Object *object, bContext *C, int type)
{
WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, object);
return add_ob_constraint(object, NULL, type);
}
-static int rna_Object_constraints_remove(Object *object, bContext *C, int index)
+static int rna_Object_constraint_remove(Object *object, bContext *C, int index)
{
int ok = remove_constraint_index(&object->constraints, index);
if(ok) {
@@ -957,6 +957,16 @@ static int rna_Object_constraints_remove(Object *object, bContext *C, int index)
return ok;
}
+static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, char *name, int type)
+{
+ return ED_object_modifier_add(reports, CTX_data_scene(C), object, name, type);
+}
+
+static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md)
+{
+ return ED_object_modifier_remove(reports, CTX_data_scene(C), object, md);
+}
+
#else
static void rna_def_vertex_group(BlenderRNA *brna)
@@ -1248,7 +1258,7 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
/* Constraint collection */
- func= RNA_def_function(srna, "new", "rna_Object_constraints_new");
+ func= RNA_def_function(srna, "new", "rna_Object_constraint_new");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Add a new constraint to this object");
/* return type */
@@ -1258,7 +1268,7 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
parm= RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add.");
RNA_def_property_flag(parm, PROP_REQUIRED);
- func= RNA_def_function(srna, "remove", "rna_Object_constraints_remove");
+ func= RNA_def_function(srna, "remove", "rna_Object_constraint_remove");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Remove a constraint from this object.");
/* return type */
@@ -1269,6 +1279,55 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_flag(parm, PROP_REQUIRED);
}
+/* armature.bones.* */
+static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "ObjectModifiers");
+ srna= RNA_def_struct(brna, "ObjectModifiers", NULL);
+ RNA_def_struct_sdna(srna, "Object");
+ RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers.");
+
+#if 0
+ prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "EditBone");
+ RNA_def_property_pointer_sdna(prop, NULL, "act_edbone");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone.");
+ //RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update");
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_Armature_act_edit_bone_set", NULL);
+
+ /* todo, redraw */
+// RNA_def_property_collection_active(prop, prop_act);
+#endif
+
+ /* add target */
+ func= RNA_def_function(srna, "new", "rna_Object_modifier_new");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Add a new bone.");
+ parm= RNA_def_string(func, "name", "Name", 0, "", "New name for the bone.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* modifier to add */
+ parm= RNA_def_enum(func, "type", modifier_type_items, 1, "", "Modifier type to add.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ /* return type */
+ parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier.");
+ RNA_def_function_return(func, parm);
+
+ /* remove target */
+ func= RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Remove an existing modifier from the object.");
+ /* target to remove*/
+ parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove.");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+}
+
static void rna_def_object(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1581,6 +1640,7 @@ static void rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Modifier");
RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the geometric data of the Object.");
+ rna_def_object_modifiers(brna, prop);
/* game engine */
prop= RNA_def_property(srna, "game", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 0669344ec82..c601622fcc3 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -485,7 +485,7 @@ static void rna_FieldSettings_shape_update(bContext *C, PointerRNA *ptr)
if(!md) {
if(pd && (pd->shape == PFIELD_SHAPE_SURFACE) && ELEM(pd->forcefield,PFIELD_GUIDE,PFIELD_TEXTURE)==0)
if(ELEM4(ob->type, OB_MESH, OB_SURF, OB_FONT, OB_CURVE))
- ED_object_modifier_add(NULL, scene, ob, eModifierType_Surface);
+ ED_object_modifier_add(NULL, scene, ob, NULL, eModifierType_Surface);
}
else {
if(!pd || pd->shape != PFIELD_SHAPE_SURFACE)
@@ -620,7 +620,7 @@ static void rna_CollisionSettings_dependency_update(bContext *C, PointerRNA *ptr
/* add/remove modifier as needed */
if(ob->pd->deflect && !md)
- ED_object_modifier_add(NULL, scene, ob, eModifierType_Collision);
+ ED_object_modifier_add(NULL, scene, ob, NULL, eModifierType_Collision);
else if(!ob->pd->deflect && md)
ED_object_modifier_remove(NULL, scene, ob, md);
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 8d43d72c02e..8a4aadcba57 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -611,7 +611,7 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro
/* return type */
parm= RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint.");
RNA_def_function_return(func, parm);
- /* object to add */
+ /* constraint to add */
parm= RNA_def_enum(func, "type", constraint_type_items, 1, "", "Constraint type to add.");
RNA_def_property_flag(parm, PROP_REQUIRED);
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index f4d3929b08c..7f9928262c3 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -132,7 +132,7 @@ void ED_node_shader_default(struct Material *ma){}
void ED_screen_animation_timer_update(struct bContext *C, int redraws){}
void ED_base_object_select(struct Base *base, short mode){}
int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md){return 0;}
-int ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, int type){return 0;}
+int ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, char *name, int type){return 0;}
void ED_object_enter_editmode(struct bContext *C, int flag){}
void ED_object_exit_editmode(struct bContext *C, int flag){}
int uiLayoutGetActive(struct uiLayout *layout){return 0;}