Page MenuHome

Make hook centre available as property and add an operator to reset hook object offset.
Needs RevisionPublic

Authored by Gottfried Hofmann (gottfried) on May 15 2014, 7:56 PM.

Details

Summary

This patch adds an operator to set the location of a hook object back to it's center.

It solves the problem discussed here: http://blender.stackexchange.com/questions/9367/how-to-reset-hook-position

Use-case: When posing an object with the laplacian deform modifier, an operation to reset the location of the hook objects back to their center position is desirable (like with normal rigging where you can reset the location of a bone etc.)

Diff Detail

Event Timeline

Gottfried Hofmann (gottfried) updated this revision to Unknown Object (????).Jul 9 2014, 3:10 PM

General comments...

  • Seems useful functionality to have.
  • Would do this in C, dont think theres really benefits to using Python for this.
  • This access all scene objects, even hidden/unselected objects.
  • An object can be a hook for more then one other object (we can ignore this case... just to note that there isn't any right answer in that case - it could report a warning).
  • Changing the 'location' may not be correct, probably it should take parenting into account and set the objects position using BKE_object_apply_mat4 or similar.
Sergey Sharybin (sergey) requested changes to this revision.Jan 14 2015, 4:56 PM

Some code issues, which Cambo might point a bit more of those.

But there are bigger concerns, like what if object is used by several hook modifiers or several objects with hook modifiers? Which location you'll be resetting it to in this case?

Not totally happy with iterating all the objects, but not sure how to do it more clear (if this is something we really need?).

Could also be a part of some addon i guess..

release/scripts/startup/bl_operators/object.py
942

Use Operator instead of bpy.types.Operator.

944

object.clear_hook_offset is more proper name i guess.

955

Don't construct temp list, do if check in the loop instead.

959

Extra space around operator.

This revision now requires changes to proceed.Jan 14 2015, 4:56 PM

Will agree with Cambo tho, if it is done in C then iterating objects might be not so huge a deal :)