Page MenuHome

Changing bbone_easein/out outside of Edit Mode crashes Blender
Closed, ResolvedPublic

Description

System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 770/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 430.64

Blender Version
Broken: version: 2.81 (sub 3), branch: master, commit date: 2019-08-25 19:05, hash: rBaf8e8be7b1c8
Worked: (optional)

Description of error
Rigify keeps crashing when I click Generate.
I was debugging IT to find what's wrong and consistently found the crash at two particular instances where it tries to set a data.bone's bbone_ease_in property.
Rigify's code has it always do this when in object mode, despite this being a edit bone type thing. (it's not literally an editbone but it functionally is).

The code in Rigify should be changed to run this stuff in Edit mode but I assume your priority is to fix the crash.

Exact steps for others to reproduce the error
While in Object or Pose mode, change a pose.bone's bone.bbone_easein property, or change a data.bone's easein property.

bpy.context.object.data.bones[0].bbone_easein = 1
bpy.context.object.pose.bones[0].bone.bbone_easein = 1

Event Timeline

Philipp Oeser (lichtwerk) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Aug 26 2019, 2:11 PM

Can confirm, caused by rBf041d2f1163c: Fix T65671: Armature X-Mirror inconsistencies.

Got a bandaid here, also checking why apparently editmode bbone settings are out of sync from pose/objectmode...

Reading my way into modeswitching on armatures, there is something wrong syncing/updating between editmode and posemode in relation to the bbone settings (as mentioned above -- setting something on EditBone will never really get carried over to PoseBone...)

But regarding the crash, shouldnt we play safe and do something more like (otherwise crashes in rna_Armature_editbone_transform_update)?

1
2
3diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c
4index d3bdcf03d4d..addca6bba92 100644
5--- a/source/blender/makesrna/intern/rna_armature.c
6+++ b/source/blender/makesrna/intern/rna_armature.c
7@@ -613,16 +613,19 @@ static void rna_Armature_transform(bArmature *arm, float *mat)
8
9 /* Settings for curved bbone settings -
10 * The posemode values get applied over the top of the editmode ones. */
11-void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
12+void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone, bool is_editbone)
13 {
14-# define RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone) \
15+# define RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone) \
16 { \
17 if (is_posebone) { \
18 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); \
19 } \
20- else { \
21+ else if (is_editbone){ \
22 RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); \
23 } \
24+ else { \
25+ RNA_def_property_update(prop, 0, "rna_Armature_update_data"); \
26+ } \
27 } \
28 ((void)0)
29
30@@ -634,14 +637,14 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
31 RNA_def_property_ui_range(prop, -M_PI * 2, M_PI * 2, 10, 2);
32 RNA_def_property_ui_text(
33 prop, "Roll In", "Roll offset for the start of the B-Bone, adjusts twist");
34- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
35+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
36
37 prop = RNA_def_property(srna, "bbone_rollout", PROP_FLOAT, PROP_ANGLE);
38 RNA_def_property_float_sdna(prop, NULL, "roll2");
39 RNA_def_property_ui_range(prop, -M_PI * 2, M_PI * 2, 10, 2);
40 RNA_def_property_ui_text(
41 prop, "Roll Out", "Roll offset for the end of the B-Bone, adjusts twist");
42- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
43+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
44
45 if (is_posebone == false) {
46 prop = RNA_def_property(srna, "use_endroll_as_inroll", PROP_BOOLEAN, PROP_NONE);
47@@ -658,28 +661,28 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
48 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
49 RNA_def_property_ui_text(
50 prop, "In X", "X-axis handle offset for start of the B-Bone's curve, adjusts curvature");
51- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
52+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
53
54 prop = RNA_def_property(srna, "bbone_curveiny", PROP_FLOAT, PROP_NONE);
55 RNA_def_property_float_sdna(prop, NULL, "curve_in_y");
56 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
57 RNA_def_property_ui_text(
58 prop, "In Y", "Y-axis handle offset for start of the B-Bone's curve, adjusts curvature");
59- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
60+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
61
62 prop = RNA_def_property(srna, "bbone_curveoutx", PROP_FLOAT, PROP_NONE);
63 RNA_def_property_float_sdna(prop, NULL, "curve_out_x");
64 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
65 RNA_def_property_ui_text(
66 prop, "Out X", "X-axis handle offset for end of the B-Bone's curve, adjusts curvature");
67- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
68+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
69
70 prop = RNA_def_property(srna, "bbone_curveouty", PROP_FLOAT, PROP_NONE);
71 RNA_def_property_float_sdna(prop, NULL, "curve_out_y");
72 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
73 RNA_def_property_ui_text(
74 prop, "Out Y", "Y-axis handle offset for end of the B-Bone's curve, adjusts curvature");
75- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
76+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
77
78 /* Ease In/Out */
79 prop = RNA_def_property(srna, "bbone_easein", PROP_FLOAT, PROP_NONE);
80@@ -687,14 +690,14 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
81 RNA_def_property_ui_range(prop, -5.0f, 5.0f, 1, 3);
82 RNA_def_property_float_default(prop, 1.0f);
83 RNA_def_property_ui_text(prop, "Ease In", "Length of first Bezier Handle (for B-Bones only)");
84- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
85+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
86
87 prop = RNA_def_property(srna, "bbone_easeout", PROP_FLOAT, PROP_NONE);
88 RNA_def_property_float_sdna(prop, NULL, "ease2");
89 RNA_def_property_ui_range(prop, -5.0f, 5.0f, 1, 3);
90 RNA_def_property_float_default(prop, 1.0f);
91 RNA_def_property_ui_text(prop, "Ease Out", "Length of second Bezier Handle (for B-Bones only)");
92- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
93+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
94
95 /* Scale In/Out */
96 prop = RNA_def_property(srna, "bbone_scaleinx", PROP_FLOAT, PROP_NONE);
97@@ -706,7 +709,7 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
98 "Scale In X",
99 "X-axis scale factor for start of the B-Bone, "
100 "adjusts thickness (for tapering effects)");
101- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
102+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
103
104 prop = RNA_def_property(srna, "bbone_scaleiny", PROP_FLOAT, PROP_NONE);
105 RNA_def_property_float_sdna(prop, NULL, "scale_in_y");
106@@ -717,7 +720,7 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
107 "Scale In Y",
108 "Y-axis scale factor for start of the B-Bone, "
109 "adjusts thickness (for tapering effects)");
110- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
111+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
112
113 prop = RNA_def_property(srna, "bbone_scaleoutx", PROP_FLOAT, PROP_NONE);
114 RNA_def_property_float_sdna(prop, NULL, "scale_out_x");
115@@ -728,7 +731,7 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
116 "Scale Out X",
117 "X-axis scale factor for end of the B-Bone, "
118 "adjusts thickness (for tapering effects)");
119- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
120+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
121
122 prop = RNA_def_property(srna, "bbone_scaleouty", PROP_FLOAT, PROP_NONE);
123 RNA_def_property_float_sdna(prop, NULL, "scale_out_y");
124@@ -739,12 +742,12 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
125 "Scale Out Y",
126 "Y-axis scale factor for end of the B-Bone, "
127 "adjusts thickness (for tapering effects)");
128- RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
129+ RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone, is_editbone);
130
131 # undef RNA_DEF_CURVEBONE_UPDATE
132 }
133
134-static void rna_def_bone_common(StructRNA *srna, int editbone)
135+static void rna_def_bone_common(StructRNA *srna, bool is_editbone)
136 {
137 static const EnumPropertyItem prop_bbone_handle_type[] = {
138 {BBONE_HANDLE_AUTO,
139@@ -777,7 +780,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
140 RNA_def_property_string_sdna(prop, NULL, "name");
141 RNA_def_property_ui_text(prop, "Name", "");
142 RNA_def_struct_name_property(srna, prop);
143- if (editbone) {
144+ if (is_editbone) {
145 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_EditBone_name_set");
146 }
147 else {
148@@ -789,7 +792,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
149 prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER);
150 RNA_def_property_boolean_sdna(prop, NULL, "layer", 1);
151 RNA_def_property_array(prop, 32);
152- if (editbone) {
153+ if (is_editbone) {
154 RNA_def_property_boolean_funcs(prop, NULL, "rna_EditBone_layer_set");
155 }
156 else {
157@@ -800,7 +803,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
158
159 prop = RNA_def_property(srna, "use_connect", PROP_BOOLEAN, PROP_NONE);
160 RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_CONNECTED);
161- if (editbone) {
162+ if (is_editbone) {
163 RNA_def_property_boolean_funcs(prop, NULL, "rna_EditBone_connected_set");
164 }
165 else {
166@@ -871,7 +874,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
167 /* Number values */
168 /* envelope deform settings */
169 prop = RNA_def_property(srna, "envelope_distance", PROP_FLOAT, PROP_DISTANCE);
170- if (editbone) {
171+ if (is_editbone) {
172 RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
173 }
174 else {
175@@ -890,7 +893,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
176 RNA_def_property_update(prop, 0, "rna_Armature_update_data");
177
178 prop = RNA_def_property(srna, "head_radius", PROP_FLOAT, PROP_DISTANCE);
179- if (editbone) {
180+ if (is_editbone) {
181 RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
182 }
183 else {
184@@ -904,7 +907,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
185 prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only)");
186
187 prop = RNA_def_property(srna, "tail_radius", PROP_FLOAT, PROP_DISTANCE);
188- if (editbone) {
189+ if (is_editbone) {
190 RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
191 }
192 else {
193@@ -919,7 +922,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
194
195 /* b-bones deform settings */
196 prop = RNA_def_property(srna, "bbone_segments", PROP_INT, PROP_NONE);
197- if (editbone) {
198+ if (is_editbone) {
199 RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
200 }
201 else {
202@@ -931,7 +934,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
203 prop, "B-Bone Segments", "Number of subdivisions of bone (for B-Bones only)");
204
205 prop = RNA_def_property(srna, "bbone_x", PROP_FLOAT, PROP_NONE);
206- if (editbone) {
207+ if (is_editbone) {
208 RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
209 }
210 else {
211@@ -942,7 +945,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
212 RNA_def_property_ui_text(prop, "B-Bone Display X Width", "B-Bone X size");
213
214 prop = RNA_def_property(srna, "bbone_z", PROP_FLOAT, PROP_NONE);
215- if (editbone) {
216+ if (is_editbone) {
217 RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
218 }
219 else {
220@@ -962,8 +965,8 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
221
222 prop = RNA_def_property(srna, "bbone_custom_handle_start", PROP_POINTER, PROP_NONE);
223 RNA_def_property_pointer_sdna(prop, NULL, "bbone_prev");
224- RNA_def_property_struct_type(prop, editbone ? "EditBone" : "Bone");
225- if (editbone) {
226+ RNA_def_property_struct_type(prop, is_editbone ? "EditBone" : "Bone");
227+ if (is_editbone) {
228 RNA_def_property_pointer_funcs(
229 prop, "rna_EditBone_bbone_prev_get", "rna_EditBone_bbone_prev_set", NULL, NULL);
230 RNA_def_property_update(prop, 0, "rna_Armature_dependency_update");
231@@ -986,8 +989,8 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
232
233 prop = RNA_def_property(srna, "bbone_custom_handle_end", PROP_POINTER, PROP_NONE);
234 RNA_def_property_pointer_sdna(prop, NULL, "bbone_next");
235- RNA_def_property_struct_type(prop, editbone ? "EditBone" : "Bone");
236- if (editbone) {
237+ RNA_def_property_struct_type(prop, is_editbone ? "EditBone" : "Bone");
238+ if (is_editbone) {
239 RNA_def_property_pointer_funcs(
240 prop, "rna_EditBone_bbone_next_get", "rna_EditBone_bbone_next_set", NULL, NULL);
241 RNA_def_property_update(prop, 0, "rna_Armature_dependency_update");
242@@ -1029,8 +1032,8 @@ static void rna_def_bone(BlenderRNA *brna)
243 RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP);
244 RNA_def_property_ui_text(prop, "Children", "Bones which are children of this bone");
245
246- rna_def_bone_common(srna, 0);
247- rna_def_bone_curved_common(srna, 0);
248+ rna_def_bone_common(srna, false);
249+ rna_def_bone_curved_common(srna, false, false);
250
251 /* XXX should we define this in PoseChannel wrapping code instead?
252 * But PoseChannels directly get some of their flags from here... */
253@@ -1152,8 +1155,8 @@ static void rna_def_edit_bone(BlenderRNA *brna)
254 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
255 RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update");
256
257- rna_def_bone_common(srna, 1);
258- rna_def_bone_curved_common(srna, 0);
259+ rna_def_bone_common(srna, true);
260+ rna_def_bone_curved_common(srna, false, true);
261
262 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
263 RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_A);
264diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
265index 26f25e4988d..fa13c56e4fa 100644
266--- a/source/blender/makesrna/intern/rna_internal.h
267+++ b/source/blender/makesrna/intern/rna_internal.h
268@@ -223,7 +223,7 @@ bool rna_AnimaData_override_apply(struct Main *bmain,
269 void rna_def_animviz_common(struct StructRNA *srna);
270 void rna_def_motionpath_common(struct StructRNA *srna);
271
272-void rna_def_bone_curved_common(struct StructRNA *srna, bool is_posebone);
273+void rna_def_bone_curved_common(struct StructRNA *srna, bool is_posebone, bool is_editbone);
274
275 void rna_def_texmat_common(struct StructRNA *srna, const char *texspace_editable);
276 void rna_def_mtex_common(struct BlenderRNA *brna,
277diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
278index 7637930f37f..33d7d7d99cf 100644
279--- a/source/blender/makesrna/intern/rna_pose.c
280+++ b/source/blender/makesrna/intern/rna_pose.c
281@@ -1044,7 +1044,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
282 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
283
284 /* Curved bones settings - Applied on top of restpose values */
285- rna_def_bone_curved_common(srna, true);
286+ rna_def_bone_curved_common(srna, true, false);
287
288 /* Custom BBone next/prev sources */
289 prop = RNA_def_property(srna, "bbone_custom_handle_start", PROP_POINTER, PROP_NONE);

CC @Brecht Van Lommel (brecht)
CC @Alexander Gavrilov (angavrilov)
CC @Sebastian Parborg (zeddb)

Philipp Oeser (lichtwerk) raised the priority of this task from Confirmed, Medium to Confirmed, High.Aug 26 2019, 4:08 PM

Would even consider this High priority, we shouldnt break stuff, so that important Addons are unusable imho.
Everyone involved: please put this back to Confirmed, Medium if you think this is exaggerating....

Reading my way into modeswitching on armatures, there is something wrong syncing/updating between editmode and posemode in relation to the bbone settings (as mentioned above -- setting something on EditBone will never really get carried over to PoseBone...)

Please ignore this part (due to my inexperience with rigging... these are not expected to be in sync, final result is the combination of edit and pose...)

Of course my first patch would cause everything to explode, I expected nothing less!

Thanks for the fix @Philipp Oeser (lichtwerk)!

As @Sebastian Parborg (zeddb) said, we want to look into ways to make the split between pose and edit bone properties a bit clearer and more functional. But I'm a total noob at C and a hobby coder so it probably won't happen for a while, unless Sebastian does everything. :P