Fix some RNA physics accessors creating data.
Accessing data through RNA should never implicitely create it. Objects' and particles' forcefields and collision settings were doing this. Note that UI code also had to be tweaked to properly handle `None` (NULL) cases. Differential Revision: https://developer.blender.org/D11341
This commit is contained in:
parent
adf2f146d8
commit
24deeee09e
|
@ -1803,9 +1803,10 @@ class PARTICLE_PT_force_fields_type1(ParticleButtonsPanel, Panel):
|
|||
|
||||
part = particle_get_settings(context)
|
||||
|
||||
col = layout.column()
|
||||
col.prop(part.force_field_1, "type", text="Type 1")
|
||||
basic_force_field_settings_ui(self, part.force_field_1)
|
||||
if part.force_field_1:
|
||||
col = layout.column()
|
||||
col.prop(part.force_field_1, "type", text="Type 1")
|
||||
basic_force_field_settings_ui(self, part.force_field_1)
|
||||
|
||||
|
||||
class PARTICLE_PT_force_fields_type2(ParticleButtonsPanel, Panel):
|
||||
|
@ -1819,9 +1820,10 @@ class PARTICLE_PT_force_fields_type2(ParticleButtonsPanel, Panel):
|
|||
|
||||
part = particle_get_settings(context)
|
||||
|
||||
col = layout.column()
|
||||
col.prop(part.force_field_2, "type", text="Type 2")
|
||||
basic_force_field_settings_ui(self, part.force_field_2)
|
||||
if part.force_field_2:
|
||||
col = layout.column()
|
||||
col.prop(part.force_field_2, "type", text="Type 2")
|
||||
basic_force_field_settings_ui(self, part.force_field_2)
|
||||
|
||||
|
||||
class PARTICLE_PT_force_fields_type1_falloff(ParticleButtonsPanel, Panel):
|
||||
|
@ -1836,7 +1838,8 @@ class PARTICLE_PT_force_fields_type1_falloff(ParticleButtonsPanel, Panel):
|
|||
|
||||
part = particle_get_settings(context)
|
||||
|
||||
basic_force_field_falloff_ui(self, part.force_field_1)
|
||||
if part.force_field_1:
|
||||
basic_force_field_falloff_ui(self, part.force_field_1)
|
||||
|
||||
|
||||
class PARTICLE_PT_force_fields_type2_falloff(ParticleButtonsPanel, Panel):
|
||||
|
@ -1851,7 +1854,8 @@ class PARTICLE_PT_force_fields_type2_falloff(ParticleButtonsPanel, Panel):
|
|||
|
||||
part = particle_get_settings(context)
|
||||
|
||||
basic_force_field_falloff_ui(self, part.force_field_2)
|
||||
if part.force_field_2:
|
||||
basic_force_field_falloff_ui(self, part.force_field_2)
|
||||
|
||||
|
||||
class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, Panel):
|
||||
|
|
|
@ -79,7 +79,7 @@ class PHYSICS_PT_add(PhysicButtonsPanel, Panel):
|
|||
|
||||
col = flow.column()
|
||||
|
||||
if obj.field.type == 'NONE':
|
||||
if not obj.field or obj.field.type == 'NONE':
|
||||
col.operator("object.forcefield_toggle", text="Force Field", icon='FORCE_FORCE')
|
||||
else:
|
||||
col.operator("object.forcefield_toggle", text="Force Field", icon='X')
|
||||
|
|
|
@ -1502,11 +1502,6 @@ static PointerRNA rna_Object_field_get(PointerRNA *ptr)
|
|||
{
|
||||
Object *ob = (Object *)ptr->owner_id;
|
||||
|
||||
/* weak */
|
||||
if (!ob->pd) {
|
||||
ob->pd = BKE_partdeflect_new(0);
|
||||
}
|
||||
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, ob->pd);
|
||||
}
|
||||
|
||||
|
@ -1518,11 +1513,6 @@ static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
|
|||
return PointerRNA_NULL;
|
||||
}
|
||||
|
||||
/* weak */
|
||||
if (!ob->pd) {
|
||||
ob->pd = BKE_partdeflect_new(0);
|
||||
}
|
||||
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
|
||||
}
|
||||
|
||||
|
|
|
@ -1413,24 +1413,12 @@ static const EnumPropertyItem *rna_Particle_ren_as_itemf(bContext *UNUSED(C),
|
|||
static PointerRNA rna_Particle_field1_get(PointerRNA *ptr)
|
||||
{
|
||||
ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
|
||||
|
||||
/* weak */
|
||||
if (!part->pd) {
|
||||
part->pd = BKE_partdeflect_new(0);
|
||||
}
|
||||
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd);
|
||||
}
|
||||
|
||||
static PointerRNA rna_Particle_field2_get(PointerRNA *ptr)
|
||||
{
|
||||
ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
|
||||
|
||||
/* weak */
|
||||
if (!part->pd2) {
|
||||
part->pd2 = BKE_partdeflect_new(0);
|
||||
}
|
||||
|
||||
return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd2);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue