blender/release/scripts/modules
Dalai Felinto e0db647d35 Fix region_2d_to_origin_3d not working with ortho view
In some cases when:
* the viewport was in the camera mode
* the camera was ortho
* the view was not fitting (as oppose to use HOME)

region_2d_to_origin_3d would misbehave (and consequently region_2d_to_location_3d).

Sample addon to test it:
```
import bpy

from bpy_extras.view3d_utils import (
    region_2d_to_location_3d,
    )

from mathutils import (
    Vector,
    )

class MoveXYOperator(bpy.types.Operator):
    """Translate the view using mouse events"""
    bl_idname = "view3d.move_xy"
    bl_label = "Move XY"

    @classmethod
    def poll(cls, context):
        return context.object

    def modal(self, context, event):
        if event.type == 'MOUSEMOVE':
            self.move(context, event)

        elif event.type in {'LEFTMOUSE', 'RIGHTMOUSE', 'ESC'}:
            return {'FINISHED'}

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        if context.space_data.type == 'VIEW_3D':
            self.ob = context.object
            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "Active space must be a View3d")
            return {'CANCELLED'}

    def move(self, context, event):
        xy = region_2d_to_location_3d(
                context.region,
                context.space_data.region_3d,
                (event.mouse_region_x, event.mouse_region_y),
                Vector(),
                ).xy

        self.ob.location.xy = xy

def register():
    bpy.utils.register_class(MoveXYOperator)

def unregister():
    bpy.utils.unregister_class(MoveXYOperator)

if __name__ == "__main__":
    register()
```
2016-06-14 18:03:07 -03:00
..
bl_i18n_utils Usual UI/i18n message cleanup (get rid of last remaining 'addon' too). 2016-06-01 20:38:30 +02:00
bl_previews_utils Batch-previews generation: add option to control whether we save backup .blend1 file or not. 2016-03-01 17:46:21 +01:00
bpy Docs: Support out-of-source reference-API builds 2016-06-12 11:31:28 +10:00
bpy_extras Fix region_2d_to_origin_3d not working with ortho view 2016-06-14 18:03:07 -03:00
console Cleanup: use static sets where possible 2014-09-18 17:45:31 +10:00
addon_utils.py addon_utils: improve docstrings 2016-01-07 23:33:51 +11:00
animsys_refactor.py Cleanup: remove redundant 'object' parent class 2014-10-28 18:42:06 +01:00
blend_render_info.py Maintenance: Shebang lines fix for some python scripts 2013-11-18 20:41:22 +11:00
bpy_restrict_state.py cleanup: pep8 2015-01-29 15:35:06 +11:00
bpy_types.py Add warning to Mesh.from_pydata 2016-05-25 21:35:45 +10:00
bpyml_ui.py cleanup: pep8 2015-01-29 15:35:06 +11:00
bpyml.py Cleanup: remove redundant 'object' parent class 2014-10-28 18:42:06 +01:00
console_python.py Use contextlib for temporary py console overrides 2016-02-04 17:40:02 +11:00
console_shell.py update console shell for changes in api 2013-12-29 00:51:51 +11:00
graphviz_export.py style cleanup 2012-06-19 22:17:19 +00:00
keyingsets_utils.py Bendy Bones: Advanced B-Bones for Easier + Simple Rigging 2016-05-18 03:19:06 +12:00
nodeitems_utils.py Cleanup: pep8 2015-09-01 13:03:38 +10:00
progress_report.py Fix T46437: Make progress report py helper resitent to 'zero steps' passed value... 2015-10-10 17:21:09 +02:00
rna_info.py Cleanup: pep8 2015-06-07 17:28:02 +10:00
rna_keymap_ui.py Minor adjustments to keymap editor layouts 2016-02-20 00:46:17 +01:00
rna_prop_ui.py Fix T46891: Error removing PropertyGroup 2015-11-30 11:03:49 +11:00
rna_xml.py Cleanup: pep8 2015-06-07 17:28:02 +10:00
sys_info.py Cleanup: pep8 2016-02-01 00:47:10 +11:00