03806d0b67
This commit implements described in the #104573. The goal is to fix the confusion of the submodule hashes change, which are not ideal for any of the supported git-module configuration (they are either always visible causing confusion, or silently staged and committed, also causing confusion). This commit replaces submodules with a checkout of addons and addons_contrib, covered by the .gitignore, and locale and developer tools are moved to the main repository. This also changes the paths: - /release/scripts are moved to the /scripts - /source/tools are moved to the /tools - /release/datafiles/locale is moved to /locale This is done to avoid conflicts when using bisect, and also allow buildbot to automatically "recover" wgen building older or newer branches/patches. Running `make update` will initialize the local checkout to the changed repository configuration. Another aspect of the change is that the make update will support Github style of remote organization (origin remote pointing to thy fork, upstream remote pointing to the upstream blender/blender.git). Pull Request #104755
78 lines
2.3 KiB
Python
78 lines
2.3 KiB
Python
import bpy
|
|
from mathutils import Vector
|
|
from bpy.props import FloatVectorProperty
|
|
|
|
|
|
class ViewOperator(bpy.types.Operator):
|
|
"""Translate the view using mouse events"""
|
|
bl_idname = "view3d.modal_operator"
|
|
bl_label = "Simple View Operator"
|
|
|
|
offset: FloatVectorProperty(
|
|
name="Offset",
|
|
size=3,
|
|
)
|
|
|
|
def execute(self, context):
|
|
v3d = context.space_data
|
|
rv3d = v3d.region_3d
|
|
|
|
rv3d.view_location = self._initial_location + Vector(self.offset)
|
|
|
|
def modal(self, context, event):
|
|
v3d = context.space_data
|
|
rv3d = v3d.region_3d
|
|
|
|
if event.type == 'MOUSEMOVE':
|
|
self.offset = (self._initial_mouse - Vector((event.mouse_x, event.mouse_y, 0.0))) * 0.02
|
|
self.execute(context)
|
|
context.area.header_text_set("Offset %.4f %.4f %.4f" % tuple(self.offset))
|
|
|
|
elif event.type == 'LEFTMOUSE':
|
|
context.area.header_text_set(None)
|
|
return {'FINISHED'}
|
|
|
|
elif event.type in {'RIGHTMOUSE', 'ESC'}:
|
|
rv3d.view_location = self._initial_location
|
|
context.area.header_text_set(None)
|
|
return {'CANCELLED'}
|
|
|
|
return {'RUNNING_MODAL'}
|
|
|
|
def invoke(self, context, event):
|
|
|
|
if context.space_data.type == 'VIEW_3D':
|
|
v3d = context.space_data
|
|
rv3d = v3d.region_3d
|
|
|
|
if rv3d.view_perspective == 'CAMERA':
|
|
rv3d.view_perspective = 'PERSP'
|
|
|
|
self._initial_mouse = Vector((event.mouse_x, event.mouse_y, 0.0))
|
|
self._initial_location = rv3d.view_location.copy()
|
|
|
|
context.window_manager.modal_handler_add(self)
|
|
return {'RUNNING_MODAL'}
|
|
else:
|
|
self.report({'WARNING'}, "Active space must be a View3d")
|
|
return {'CANCELLED'}
|
|
|
|
|
|
def menu_func(self, context):
|
|
self.layout.operator(ViewOperator.bl_idname, text="Simple View Modal Operator")
|
|
|
|
|
|
# Register and add to the "view" menu (required to also use F3 search "Simple View Modal Operator" for quick access).
|
|
def register():
|
|
bpy.utils.register_class(ViewOperator)
|
|
bpy.types.VIEW3D_MT_view.append(menu_func)
|
|
|
|
|
|
def unregister():
|
|
bpy.utils.unregister_class(ViewOperator)
|
|
bpy.types.VIEW3D_MT_view.remove(menu_func)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
register()
|