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:
Diffstat (limited to 'source/blender/makesrna/intern/rna_object.c')
-rw-r--r--source/blender/makesrna/intern/rna_object.c152
1 files changed, 124 insertions, 28 deletions
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 0b8afef0364..d436e4719ea 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -506,7 +506,7 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value)
ob->dup_group = grp;
else
BKE_report(NULL, RPT_ERROR,
- "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle");
+ "Cannot set dupli-group as object belongs in group being instanced, thus causing a cycle");
}
static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
@@ -547,8 +547,7 @@ static void rna_Object_active_vertex_group_index_range(PointerRNA *ptr, int *min
Object *ob = (Object *)ptr->id.data;
*min = 0;
- *max = BLI_countlist(&ob->defbase) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&ob->defbase) - 1);
}
void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
@@ -658,7 +657,7 @@ static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, in
{
Object *ob = (Object *)ptr->id.data;
*min = 0;
- *max = MAX2(ob->totcol - 1, 0);
+ *max = max_ii(ob->totcol - 1, 0);
}
/* returns active base material */
@@ -684,8 +683,7 @@ static void rna_Object_active_particle_system_index_range(PointerRNA *ptr, int *
{
Object *ob = (Object *)ptr->id.data;
*min = 0;
- *max = BLI_countlist(&ob->particlesystem) - 1;
- *max = MAX2(0, *max);
+ *max = max_ii(0, BLI_countlist(&ob->particlesystem) - 1);
}
static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
@@ -851,11 +849,11 @@ static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
if (value) {
ob->matbits[index] = 1;
- /* ob->colbits |= (1<<index); */ /* DEPRECATED */
+ /* ob->colbits |= (1 << index); */ /* DEPRECATED */
}
else {
ob->matbits[index] = 0;
- /* ob->colbits &= ~(1<<index); */ /* DEPRECATED */
+ /* ob->colbits &= ~(1 << index); */ /* DEPRECATED */
}
}
@@ -1036,8 +1034,8 @@ static unsigned int rna_Object_layer_validate__internal(const int *values, unsig
return 0;
for (i = 0; i < 20; i++) {
- if (values[i]) lay |= (1 << i);
- else lay &= ~(1 << i);
+ if (values[i]) lay |= (1 << i);
+ else lay &= ~(1 << i);
}
return lay;
@@ -1072,8 +1070,9 @@ static void rna_GameObjectSettings_state_get(PointerRNA *ptr, int *values)
int all_states = (ob->scaflag & OB_ALLSTATE ? 1 : 0);
memset(values, 0, sizeof(int) * OB_MAX_STATES);
- for (i = 0; i < OB_MAX_STATES; i++)
+ for (i = 0; i < OB_MAX_STATES; i++) {
values[i] = (ob->state & (1 << i)) | all_states;
+ }
}
static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values)
@@ -1111,6 +1110,65 @@ static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values)
}
}
+static void rna_GameObjectSettings_col_group_get(PointerRNA *ptr, int *values)
+{
+ Object *ob = (Object*)ptr->data;
+ int i;
+
+ for (i = 0; i < OB_MAX_COL_MASKS; i++) {
+ values[i] = (ob->col_group & (1 << i));
+ }
+}
+
+static void rna_GameObjectSettings_col_group_set(PointerRNA *ptr, const int *values)
+{
+ Object *ob = (Object*)ptr->data;
+ int i, tot = 0;
+
+ /* ensure we always have some group selected */
+ for (i = 0; i < OB_MAX_COL_MASKS; i++)
+ if (values[i])
+ tot++;
+
+ if (tot == 0)
+ return;
+
+ for (i = 0; i < OB_MAX_COL_MASKS; i++) {
+ if (values[i]) ob->col_group |= (1 << i);
+ else ob->col_group &= ~(1 << i);
+ }
+}
+
+static void rna_GameObjectSettings_col_mask_get(PointerRNA *ptr, int *values)
+{
+ Object *ob = (Object*)ptr->data;
+ int i;
+
+ for (i = 0; i < OB_MAX_COL_MASKS; i++) {
+ values[i] = (ob->col_mask & (1 << i));
+ }
+}
+
+static void rna_GameObjectSettings_col_mask_set(PointerRNA *ptr, const int *values)
+{
+ Object *ob = (Object*)ptr->data;
+ int i, tot = 0;
+
+ /* ensure we always have some mask selected */
+ for (i = 0; i < OB_MAX_COL_MASKS; i++)
+ if (values[i])
+ tot++;
+
+ if (tot == 0)
+ return;
+
+ for (i = 0; i < OB_MAX_COL_MASKS; i++) {
+ if (values[i]) ob->col_mask |= (1 << i);
+ else ob->col_mask &= ~(1 << i);
+ }
+}
+
+
static void rna_Object_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
{
Object *ob = (Object *)ptr->id.data;
@@ -1199,14 +1257,17 @@ static bConstraint *rna_Object_constraints_new(Object *object, int type)
return add_ob_constraint(object, NULL, type);
}
-static void rna_Object_constraints_remove(Object *object, ReportList *reports, bConstraint *con)
+static void rna_Object_constraints_remove(Object *object, ReportList *reports, PointerRNA *con_ptr)
{
+ bConstraint *con = con_ptr->data;
if (BLI_findindex(&object->constraints, con) == -1) {
BKE_reportf(reports, RPT_ERROR, "Constraint '%s' not found in object '%s'", con->name, object->id.name + 2);
return;
}
remove_constraint(&object->constraints, con);
+ RNA_POINTER_INVALIDATE(con_ptr);
+
ED_object_constraint_update(object);
ED_object_constraint_set_active(object, NULL);
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
@@ -1228,9 +1289,15 @@ static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, Report
return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
}
-static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md)
+static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, PointerRNA *md_ptr)
{
- ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md);
+ ModifierData *md = md_ptr->data;
+ if (ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md) == FALSE) {
+ /* error is already set */
+ return;
+ }
+
+ RNA_POINTER_INVALIDATE(md_ptr);
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
}
@@ -1264,9 +1331,16 @@ static bDeformGroup *rna_Object_vgroup_new(Object *ob, const char *name)
return defgroup;
}
-static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup)
+static void rna_Object_vgroup_remove(Object *ob, ReportList *reports, PointerRNA *defgroup_ptr)
{
+ bDeformGroup *defgroup = defgroup_ptr->data;
+ if (BLI_findindex(&ob->defbase, defgroup) == -1) {
+ BKE_reportf(reports, RPT_ERROR, "DeformGroup '%s' not in object '%s'", defgroup->name, ob->id.name + 2);
+ return;
+ }
+
ED_vgroup_delete(ob, defgroup);
+ RNA_POINTER_INVALIDATE(defgroup_ptr);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
}
@@ -1284,7 +1358,7 @@ static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *re
Object *ob = (Object *)id;
if (ED_vgroup_object_is_edit_mode(ob)) {
- BKE_reportf(reports, RPT_ERROR, "VertexGroup.add(): Can't be called while object is in edit mode");
+ BKE_report(reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode");
return;
}
@@ -1299,7 +1373,7 @@ static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList *
Object *ob = (Object *)id;
if (ED_vgroup_object_is_edit_mode(ob)) {
- BKE_reportf(reports, RPT_ERROR, "VertexGroup.remove(): Can't be called while object is in edit mode");
+ BKE_report(reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode");
return;
}
@@ -1314,7 +1388,7 @@ static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *report
float weight = ED_vgroup_vert_weight((Object *)id, dg, index);
if (weight < 0) {
- BKE_reportf(reports, RPT_ERROR, "Vertex not in group");
+ BKE_report(reports, RPT_ERROR, "Vertex not in group");
}
return weight;
}
@@ -1345,6 +1419,12 @@ int rna_Camera_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
return ((Object *)value.id.data)->type == OB_CAMERA;
}
+int rna_DupliObject_index_get(PointerRNA *ptr)
+{
+ DupliObject *dob = (DupliObject *)ptr->data;
+ return dob->persistent_id[0];
+}
+
#else
static int rna_matrix_dimsize_4x4[] = {4, 4};
@@ -1578,6 +1658,17 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0, 1000.0);
RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall");
+ prop = RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER);
+ RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1);
+ RNA_def_property_array(prop, OB_MAX_COL_MASKS);
+ RNA_def_property_ui_text(prop, "Collision Group", "The collision group of the object");
+ RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_group_get", "rna_GameObjectSettings_col_group_set");
+
+ prop = RNA_def_property(srna, "collision_mask", PROP_BOOLEAN, PROP_LAYER_MEMBER);
+ RNA_def_property_boolean_sdna(prop, NULL, "col_mask", 1);
+ RNA_def_property_array(prop, OB_MAX_COL_MASKS);
+ RNA_def_property_ui_text(prop, "Collision Mask", "The groups this object can collide with");
+ RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_mask_get", "rna_GameObjectSettings_col_mask_set");
/* lock position */
prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE);
@@ -1745,7 +1836,8 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
/* constraint to remove */
parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
RNA_def_function_ui_description(func, "Remove all constraint from this object");
@@ -1796,7 +1888,8 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove an existing modifier from the object");
/* modifier to remove */
parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
/* clear all modifiers */
func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
@@ -1874,9 +1967,11 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Delete vertex group from object");
parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+ RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
RNA_def_function_ui_description(func, "Delete all vertex groups from object");
@@ -2564,22 +2659,23 @@ static void rna_def_dupli_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Hide", "Don't show dupli object in viewport or render");
prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "index");
+ RNA_def_property_int_funcs(prop, "rna_DupliObject_index_get", NULL, NULL);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Index", "Index in the lowest-level dupli list");
-
- prop = RNA_def_property(srna, "particle_index", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "particle_index");
+
+ prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Persistent ID", "Persistent identifier for inter-frame matching of objects with motion blur");
+
+ prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Particle Index", "Index in the lowest-level particle dupli list");
+ RNA_def_property_ui_text(prop, "Particle System", "Particle system that this dupli object was instanced from");
prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION);
- RNA_def_property_float_sdna(prop, NULL, "orco");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Generated Coordinates", "Generated coordinates in parent object space");
prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "uv");
RNA_def_property_array(prop, 2);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE);
RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space");