[Bf-blender-cvs] [00ccb99] fracture_modifier: fix for name and indexbased meshisland and meshconstraint lookup via python inside the FM
Martin Felke
noreply at git.blender.org
Fri Feb 5 12:29:41 CET 2016
Commit: 00ccb99a67cd0dd7f295e99be2ba5852840677c9
Author: Martin Felke
Date: Fri Feb 5 12:29:23 2016 +0100
Branches: fracture_modifier
https://developer.blender.org/rB00ccb99a67cd0dd7f295e99be2ba5852840677c9
fix for name and indexbased meshisland and meshconstraint lookup via python inside the FM
===================================================================
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/editors/object/object_modifier.c
M source/blender/makesdna/DNA_rigidbody_types.h
M source/blender/makesrna/intern/rna_modifier.c
===================================================================
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 64f021e..4bfc223 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1794,7 +1794,7 @@ static void rigidbody_create_shard_physics_constraint(FractureModifierData* fmd,
{
//char id[64];
//sprintf(id, "%d", rbc->id);
- RB_constraint_set_id(rbc->physics_constraint, rbc->id);
+ RB_constraint_set_id(rbc->physics_constraint, rbc->name);
}
}
@@ -2596,7 +2596,7 @@ RigidBodyShardCon *BKE_rigidbody_create_shard_constraint(Scene *scene, short typ
rbc->motor_lin_target_velocity = 1.0f;
rbc->motor_ang_max_impulse = 1.0f;
rbc->motor_ang_target_velocity = 1.0f;
- strcpy(rbc->id, "");
+ strcpy(rbc->name, "");
zero_v3(rbc->pos);
unit_qt(rbc->orn);
rbc->breaking_angle = 0.0f;
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 61616a8..ab9e5e0 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2869,7 +2869,7 @@ static Object* do_convert_constraints(FractureModifierData *fmd, RigidBodyShardC
if (fmd->fracture_mode == MOD_FRACTURE_EXTERNAL)
{
- name = BLI_strdupn(con->id, MAX_ID_NAME);
+ name = BLI_strdupn(con->name, MAX_ID_NAME);
}
else
{
diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h
index ad7cf58..b891705 100644
--- a/source/blender/makesdna/DNA_rigidbody_types.h
+++ b/source/blender/makesdna/DNA_rigidbody_types.h
@@ -286,7 +286,8 @@ typedef struct RigidBodyShardCon {
short num_solver_iterations;/* number of constraint solver iterations made per simulation step */
int flag; /* (eRigidBodyCon_Flag) */
- char id[64];
+ char name[66]; /* MAX_ID_NAME */
+ char pad[2];
float breaking_threshold; /* breaking impulse threshold */
float start_angle; //needed for breaking by angle and dist
@@ -331,6 +332,7 @@ typedef struct RigidBodyShardCon {
float motor_lin_max_impulse; /* maximum force used to reach linear target velocity */
float motor_ang_max_impulse; /* maximum force used to reach angular target velocity */
+ char pad2[4];
} RigidBodyShardCon;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index f786399..c8ebc0e 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -1253,7 +1253,7 @@ static void rna_FractureModifier_mesh_constraint_remove(ID *id, FractureModifier
RigidBodyShardCon *con = con_ptr->data;
if (con && BLI_findindex(&fmd->meshConstraints, con) == -1) {
- BKE_reportf(reports, RPT_ERROR, "MeshConstraint '%s' not in this fracture modifier", con->id);
+ BKE_reportf(reports, RPT_ERROR, "MeshConstraint '%s' not in this fracture modifier", con->name);
return;
}
@@ -1578,17 +1578,19 @@ static char *rna_MeshIsland_path(PointerRNA *ptr)
if (fmd)
{
ModifierData *md = (ModifierData*)fmd;
- int index = mi->id;
+ //int index = mi->id;
char name_esc[sizeof(md->name) * 2];
BLI_strescape(name_esc, md->name, sizeof(name_esc));
-
+#if 0
if (fmd->fracture_mode != MOD_FRACTURE_EXTERNAL)
{
/* in regular fracture modes, meshisland index is 1-based */
index--;
+ return BLI_sprintfN("modifiers[\"%s\"].mesh_islands[%d]", name_esc, index);
}
+#endif
- return BLI_sprintfN("modifiers[\"%s\"].mesh_islands[%d]", name_esc, index);
+ return BLI_sprintfN("modifiers[\'%s\'].mesh_islands[\'%s\']", name_esc, mi->name);
}
else
{ /*should not happen yet, meshislands only exist in modifier*/
@@ -1652,14 +1654,26 @@ static char *rna_MeshConstraint_path(PointerRNA *ptr)
{
char name_esc[sizeof(md->name) * 2];
BLI_strescape(name_esc, md->name, sizeof(name_esc));
- return BLI_sprintfN("modifiers[\"%s\"].mesh_constraints[%d]", name_esc, con->id);
+ return BLI_sprintfN("modifiers[\'%s\'].mesh_constraints[\'%s\']", name_esc, con->name);
}
else
{ /*should not happen yet, meshconstraints only exist in modifier*/
- return BLI_sprintfN("mesh_constraints[%d]", con->id);
+ return BLI_sprintfN("mesh_constraints[%s]", con->name);
}
}
+#if 0
+int rna_FractureModifier_meshIsland_get_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
+{
+
+}
+
+int rna_FractureModifier_meshConstraint_get_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
+{
+
+}
+#endif
+
static void rna_CurveModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
CurveModifierData *cmd = (CurveModifierData *)ptr->data;
@@ -5228,9 +5242,10 @@ static void rna_def_mesh_island(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Rigid Body", "Rigidbody object of this mesh island");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop = RNA_def_property(srna, "id", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "id");
- RNA_def_property_ui_text(prop, "MeshIsland ID", "A name or id of this mesh island");
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "MeshIsland Name", "A name or id of this mesh island");
+ RNA_def_struct_name_property(srna, prop);
//RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "centroid", PROP_FLOAT, PROP_XYZ);
@@ -5259,9 +5274,10 @@ static void rna_def_mesh_constraint(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Mesh Constraint", "A connection between two mesh islands in Fracture Modifier");
RNA_def_struct_path_func(srna, "rna_MeshConstraint_path");
- prop = RNA_def_property(srna, "id", PROP_STRING, PROP_NONE);
- RNA_def_property_string_sdna(prop, NULL, "id");
- RNA_def_property_ui_text(prop, "Constraint ID", "A name or id of this mesh constraint");
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "name");
+ RNA_def_property_ui_text(prop, "Constraint Name", "A name or id of this mesh constraint");
+ RNA_def_struct_name_property(srna, prop);
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "pos");
@@ -6241,6 +6257,7 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
prop = RNA_def_property(srna, "mesh_islands", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MeshIsland");
RNA_def_property_collection_sdna(prop, NULL, "meshIslands", NULL);
+ //RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, "rna_FractureModifier_meshIsland_get_int", NULL, NULL);
RNA_def_property_ui_text(prop, "Mesh Islands", "A single entity inside the modifier, representing a single shard");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
rna_def_fracture_meshislands(brna, prop);
@@ -6249,6 +6266,7 @@ static void rna_def_modifier_fracture(BlenderRNA *brna)
prop = RNA_def_property(srna, "mesh_constraints", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MeshConstraint");
RNA_def_property_collection_sdna(prop, NULL, "meshConstraints", NULL);
+ //RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, "rna_FractureModifier_meshConstraint_get_int", NULL, NULL);
RNA_def_property_ui_text(prop, "Mesh Constraints", "A connection between two Mesh Islands inside the modifier");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
rna_def_fracture_meshconstraints(brna, prop);
More information about the Bf-blender-cvs
mailing list