diff options
Diffstat (limited to 'release/scripts/modules/bpy_extras/io_utils.py')
-rw-r--r-- | release/scripts/modules/bpy_extras/io_utils.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index a0c1c3e5c84..c130f890822 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -21,6 +21,7 @@ __all__ = ( "ExportHelper", "ImportHelper", + "orientation_helper", "orientation_helper_factory", "axis_conversion", "axis_conversion_ensure", @@ -121,7 +122,53 @@ class ImportHelper: return _check_axis_conversion(self) +def orientation_helper(axis_forward='Y', axis_up='Z'): + def wrapper(cls): + def _update_axis_forward(self, context): + if self.axis_forward[-1] == self.axis_up[-1]: + self.axis_up = (self.axis_up[0:-1] + + 'XYZ'[('XYZ'.index(self.axis_up[-1]) + 1) % 3]) + + cls.__annotations__['axis_forward'] = EnumProperty( + name="Forward", + items=( + ('X', "X Forward", ""), + ('Y', "Y Forward", ""), + ('Z', "Z Forward", ""), + ('-X', "-X Forward", ""), + ('-Y', "-Y Forward", ""), + ('-Z', "-Z Forward", ""), + ), + default=axis_forward, + update=_update_axis_forward, + ) + + def _update_axis_up(self, context): + if self.axis_up[-1] == self.axis_forward[-1]: + self.axis_forward = (self.axis_forward[0:-1] + + 'XYZ'[('XYZ'.index(self.axis_forward[-1]) + 1) % 3]) + + cls.__annotations__['axis_up'] = EnumProperty( + name="Up", + items=( + ('X', "X Up", ""), + ('Y', "Y Up", ""), + ('Z', "Z Up", ""), + ('-X', "-X Up", ""), + ('-Y', "-Y Up", ""), + ('-Z', "-Z Up", ""), + ), + default=axis_up, + update=_update_axis_up, + ) + + return cls + + return wrapper + + def orientation_helper_factory(name, axis_forward='Y', axis_up='Z'): + print("WARNING! Using this helper function is deprecated, please switch to orientation_helper decorator instead.") members = {} def _update_axis_forward(self, context): |