forcefield_toggle_exec() doesn't always enable force field #40080

Closed
opened 2014-05-08 01:02:27 +02:00 by Brent Baccala · 6 comments

System Information
Ubuntu 14.10 on a Gateway MP6954

Blender Version
Broken: 2.69 (and 2.70a)

When called from Python, forcefield_toggle_exec() doesn't always enable a force field, although the problem doesn't seem to manifest itself from the GUI.

Examining source/blender/editors/object/object_edit.c we find this function:

static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{

      Object *ob = CTX_data_active_object(C);
      if (ob->pd == NULL)
              ob->pd = object_add_collision_fields(PFIELD_FORCE);
      if (ob->pd->forcefield == 0)
              ob->pd->forcefield = PFIELD_FORCE;
      else
              ob->pd->forcefield = 0;
      
      ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob);
      WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
      WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
      return OPERATOR_FINISHED;

}

If ob->pd is NULL, then object_add_collision_fields will add a field of type PFIELD_FORCE. ob->pd->forcefield will be non-zero, and will immediately set to zero.

This is probably not the desired behavior, and the fix is obvious.

**System Information** Ubuntu 14.10 on a Gateway MP6954 **Blender Version** Broken: 2.69 (and 2.70a) When called from Python, forcefield_toggle_exec() doesn't always enable a force field, although the problem doesn't seem to manifest itself from the GUI. Examining source/blender/editors/object/object_edit.c we find this function: static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ``` Object *ob = CTX_data_active_object(C); ``` ``` if (ob->pd == NULL) ob->pd = object_add_collision_fields(PFIELD_FORCE); ``` ``` if (ob->pd->forcefield == 0) ob->pd->forcefield = PFIELD_FORCE; else ob->pd->forcefield = 0; ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); ``` ``` return OPERATOR_FINISHED; ``` } If ob->pd is NULL, then object_add_collision_fields will add a field of type PFIELD_FORCE. ob->pd->forcefield will be non-zero, and will immediately set to zero. This is probably not the desired behavior, and the fix is obvious.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @BrentBaccala

Added subscriber: @BrentBaccala

This issue was referenced by blender/blender-addons-contrib@cd60c18be1

This issue was referenced by blender/blender-addons-contrib@cd60c18be17d31a651fc449b35657c1c3cdc845d

This issue was referenced by blender/blender@cd60c18be1

This issue was referenced by blender/blender@cd60c18be17d31a651fc449b35657c1c3cdc845d
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Member

Closed by commit blender/blender@cd60c18be1.

Closed by commit blender/blender@cd60c18be1.
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#40080
No description provided.