Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons-contrib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons-contrib
Commits
70433a3f
Commit
70433a3f
authored
Mar 5, 2013
by
Geo Kgeo
Browse files
Options
Downloads
Patches
Plain Diff
BProjection: add new feature, new clone method
parent
6158e7a4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
space_view3d_paint_bprojection.py
+163
-23
163 additions, 23 deletions
space_view3d_paint_bprojection.py
with
163 additions
and
23 deletions
space_view3d_paint_bprojection.py
+
163
−
23
View file @
70433a3f
bl_info
=
{
bl_info
=
{
"
name
"
:
"
BProjection
"
,
"
name
"
:
"
BProjection
_mega_test
"
,
"
description
"
:
"
Help Clone tool
"
,
"
description
"
:
"
Help Clone tool
"
,
"
author
"
:
"
kgeogeo
"
,
"
author
"
:
"
kgeogeo
"
,
"
version
"
:
(
2
,
0
),
"
version
"
:
(
2
,
0
),
...
@@ -24,6 +24,8 @@ BProjection_Texture = 'Texture for BProjection'
...
@@ -24,6 +24,8 @@ BProjection_Texture = 'Texture for BProjection'
# Main function for align the plan to view
# Main function for align the plan to view
def
align_to_view
(
context
):
def
align_to_view
(
context
):
global
last_mouse
last_mouse
=
Vector
((
0
,
0
))
ob
=
context
.
object
ob
=
context
.
object
em
=
bpy
.
data
.
objects
[
BProjection_Empty
]
em
=
bpy
.
data
.
objects
[
BProjection_Empty
]
rotation
=
em
.
custom_rotation
rotation
=
em
.
custom_rotation
...
@@ -252,6 +254,16 @@ def update_activeviewname(self, context):
...
@@ -252,6 +254,16 @@ def update_activeviewname(self, context):
if
self
.
custom_active
:
if
self
.
custom_active
:
em
.
custom_active_view
=
self
.
custom_active_view
em
.
custom_active_view
=
self
.
custom_active_view
def
update_style_clone
(
self
,
context
):
km
=
context
.
window_manager
.
keyconfigs
.
default
.
keymaps
[
'
Image Paint
'
]
for
kmi
in
km
.
keymap_items
:
if
self
.
custom_style_clone
:
if
kmi
.
idname
==
'
paint.image_paint
'
:
kmi
.
idname
=
'
paint.bp_paint
'
else
:
if
kmi
.
idname
==
'
paint.bp_paint
'
:
kmi
.
idname
=
'
paint.image_paint
'
class
custom_props
(
bpy
.
types
.
PropertyGroup
):
class
custom_props
(
bpy
.
types
.
PropertyGroup
):
custom_fnlevel
=
IntProperty
(
name
=
"
Fast navigate level
"
,
description
=
"
Increase or decrease the SubSurf level, decrease make navigation faster
"
,
default
=
0
)
custom_fnlevel
=
IntProperty
(
name
=
"
Fast navigate level
"
,
description
=
"
Increase or decrease the SubSurf level, decrease make navigation faster
"
,
default
=
0
)
...
@@ -299,6 +311,7 @@ class custom_props(bpy.types.PropertyGroup):
...
@@ -299,6 +311,7 @@ class custom_props(bpy.types.PropertyGroup):
# other properties
# other properties
custom_active
=
BoolProperty
(
name
=
"
custom_active
"
,
default
=
True
)
custom_active
=
BoolProperty
(
name
=
"
custom_active
"
,
default
=
True
)
custom_expand
=
BoolProperty
(
name
=
"
expand
"
,
default
=
False
)
custom_expand
=
BoolProperty
(
name
=
"
expand
"
,
default
=
False
)
custom_style_clone
=
BoolProperty
(
name
=
"
custom_style_clone
"
,
default
=
False
)
custom_active_view
=
StringProperty
(
name
=
"
custom_active_view
"
,
default
=
"
View
"
,
update
=
update_activeviewname
)
custom_active_view
=
StringProperty
(
name
=
"
custom_active_view
"
,
default
=
"
View
"
,
update
=
update_activeviewname
)
...
@@ -388,6 +401,8 @@ def createcustomprops(context):
...
@@ -388,6 +401,8 @@ def createcustomprops(context):
Ob
.
custom_rotc3d
=
BoolProperty
(
name
=
"
rotc3d
"
,
default
=
False
)
Ob
.
custom_rotc3d
=
BoolProperty
(
name
=
"
rotc3d
"
,
default
=
False
)
Ob
.
custom_scac3d
=
BoolProperty
(
name
=
"
scac3d
"
,
default
=
False
)
Ob
.
custom_scac3d
=
BoolProperty
(
name
=
"
scac3d
"
,
default
=
False
)
Ob
.
custom_expand
=
BoolProperty
(
name
=
"
expand
"
,
default
=
True
)
Ob
.
custom_expand
=
BoolProperty
(
name
=
"
expand
"
,
default
=
True
)
Ob
.
custom_style_clone
=
BoolProperty
(
name
=
"
custom_style_clone
"
,
default
=
False
,
update
=
update_style_clone
)
Ob
.
custom_active_view
=
StringProperty
(
name
=
"
custom_active_view
"
,
default
=
"
View
"
)
Ob
.
custom_active_view
=
StringProperty
(
name
=
"
custom_active_view
"
,
default
=
"
View
"
)
try
:
try
:
Ob
.
custom_active_object
=
StringProperty
(
name
=
"
custom_active_object
"
,
default
=
context
.
object
.
name
)
Ob
.
custom_active_object
=
StringProperty
(
name
=
"
custom_active_object
"
,
default
=
context
.
object
.
name
)
...
@@ -400,7 +415,7 @@ def removecustomprops():
...
@@ -400,7 +415,7 @@ def removecustomprops():
list_prop
=
[
'
custom_location
'
,
'
custom_rotation
'
,
'
custom_old_rotation
'
,
'
custom_scale
'
,
'
custom_old_scale
'
,
'
custom_c3d
'
,
list_prop
=
[
'
custom_location
'
,
'
custom_rotation
'
,
'
custom_old_rotation
'
,
'
custom_scale
'
,
'
custom_old_scale
'
,
'
custom_c3d
'
,
'
custom_rotc3d
'
,
'
custom_scaleuv
'
,
'
custom_flipuvx
'
,
'
custom_flipuvy
'
,
'
custom_linkscale
'
,
'
custom_rotc3d
'
,
'
custom_scaleuv
'
,
'
custom_flipuvx
'
,
'
custom_flipuvy
'
,
'
custom_linkscale
'
,
'
custom_linkscaleuv
'
,
'
custom_old_scaleuv
'
,
'
custom_offsetuv
'
,
'
custom_old_offsetuv
'
,
'
custom_scac3d
'
,
'
custom_sub
'
,
'
custom_linkscaleuv
'
,
'
custom_old_scaleuv
'
,
'
custom_offsetuv
'
,
'
custom_old_offsetuv
'
,
'
custom_scac3d
'
,
'
custom_sub
'
,
'
custom_expand
'
,
'
custom_active_view
'
,
'
custom_propscaleuv
'
,
'
custom_props
'
,
'
custom_propscale
'
]
'
custom_expand
'
,
'
custom_style_clone
'
,
'
custom_active_view
'
,
'
custom_propscaleuv
'
,
'
custom_props
'
,
'
custom_propscale
'
]
for
prop
in
list_prop
:
for
prop
in
list_prop
:
try
:
try
:
del
bpy
.
data
.
objects
[
BProjection_Empty
][
prop
]
del
bpy
.
data
.
objects
[
BProjection_Empty
][
prop
]
...
@@ -644,7 +659,11 @@ class BProjection(Panel):
...
@@ -644,7 +659,11 @@ class BProjection(Panel):
row
=
box
.
column
(
align
=
True
)
row
=
box
.
column
(
align
=
True
)
row
.
prop
(
ob
,
"
custom_fnlevel
"
)
row
.
prop
(
ob
,
"
custom_fnlevel
"
)
row
=
box
.
column
(
align
=
True
)
row
=
box
.
column
(
align
=
True
)
if
not
em
.
custom_style_clone
:
row
.
prop
(
em
,
"
custom_style_clone
"
,
text
=
"
Style Clone Normal
"
,
icon
=
'
RENDERLAYERS
'
)
else
:
row
.
prop
(
em
,
"
custom_style_clone
"
,
text
=
"
Style Clone New
"
,
icon
=
'
RENDERLAYERS
'
)
row
=
box
.
column
(
align
=
True
)
if
ob
==
bpy
.
data
.
objects
[
em
.
custom_active_object
]:
if
ob
==
bpy
.
data
.
objects
[
em
.
custom_active_object
]:
for
item
in
em
.
custom_props
:
for
item
in
em
.
custom_props
:
...
@@ -821,7 +840,7 @@ class AddBProjectionPlane(Operator):
...
@@ -821,7 +840,7 @@ class AddBProjectionPlane(Operator):
bpy
.
ops
.
object
.
create_view
()
bpy
.
ops
.
object
.
create_view
()
km
=
bpy
.
data
.
window_managers
[
'
WinMan
'
].
keyconfigs
[
'
Blender
'
].
keymaps
[
'
3D View
'
]
km
=
bpy
.
data
.
window_managers
[
'
WinMan
'
].
keyconfigs
[
'
Blender
'
].
keymaps
[
'
3D View
'
]
l
=
[
'
view3d.rotate
'
,
'
view3d.move
'
,
'
view3d.zoom
'
,
'
view3d.viewnumpad
'
,
'
MOUSE
'
,
'
KEYBOARD
'
,
'
MIDDLEMOUSE
'
,
'
WHEELINMOUSE
'
,
'
WHEELOUTMOUSE
'
,
'
NUMPAD_1
'
,
'
NUMPAD_3
'
,
'
NUMPAD_7
'
]
l
=
[
'
view3d.rotate
'
,
'
view3d.move
'
,
'
view3d.zoom
'
,
'
view3d.viewnumpad
'
,
'
paint.bp_paint
'
,
'
MOUSE
'
,
'
KEYBOARD
'
,
'
LEFT
'
,
'
MIDDLEMOUSE
'
,
'
WHEELINMOUSE
'
,
'
WHEELOUTMOUSE
'
,
'
NUMPAD_1
'
,
'
NUMPAD_3
'
,
'
NUMPAD_7
'
]
for
kmi
in
km
.
keymap_items
:
for
kmi
in
km
.
keymap_items
:
if
kmi
.
idname
in
l
and
kmi
.
map_type
in
l
and
kmi
.
type
in
l
:
if
kmi
.
idname
in
l
and
kmi
.
map_type
in
l
and
kmi
.
type
in
l
:
try
:
try
:
...
@@ -842,6 +861,7 @@ class AddBProjectionPlane(Operator):
...
@@ -842,6 +861,7 @@ class AddBProjectionPlane(Operator):
kmi
.
idname
=
'
view3d.pan_view3d
'
kmi
.
idname
=
'
view3d.pan_view3d
'
km
=
context
.
window_manager
.
keyconfigs
.
default
.
keymaps
[
'
Image Paint
'
]
km
=
context
.
window_manager
.
keyconfigs
.
default
.
keymaps
[
'
Image Paint
'
]
kmi
=
km
.
keymap_items
.
new
(
"
object.intuitivescale
"
,
'
LEFTMOUSE
'
,
'
PRESS
'
,
shift
=
True
)
kmi
=
km
.
keymap_items
.
new
(
"
object.intuitivescale
"
,
'
LEFTMOUSE
'
,
'
PRESS
'
,
shift
=
True
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_grab
"
,
'
G
'
,
'
PRESS
'
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_grab
"
,
'
G
'
,
'
PRESS
'
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_rotate
"
,
'
R
'
,
'
PRESS
'
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_rotate
"
,
'
R
'
,
'
PRESS
'
)
...
@@ -849,6 +869,7 @@ class AddBProjectionPlane(Operator):
...
@@ -849,6 +869,7 @@ class AddBProjectionPlane(Operator):
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_scaleuv
"
,
'
U
'
,
'
PRESS
'
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_scaleuv
"
,
'
U
'
,
'
PRESS
'
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_offsetuv
"
,
'
Y
'
,
'
PRESS
'
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_offsetuv
"
,
'
Y
'
,
'
PRESS
'
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_clear_prop
"
,
'
C
'
,
'
PRESS
'
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_clear_prop
"
,
'
C
'
,
'
PRESS
'
)
kmi
=
km
.
keymap_items
.
new
(
"
object.bp_toggle_alpha
"
,
'
Q
'
,
'
PRESS
'
)
align_to_view
(
context
)
align_to_view
(
context
)
context
.
space_data
.
cursor_location
=
em
.
location
context
.
space_data
.
cursor_location
=
em
.
location
...
@@ -958,8 +979,12 @@ def reinitkey():
...
@@ -958,8 +979,12 @@ def reinitkey():
kmi
.
idname
=
'
view3d.move
'
kmi
.
idname
=
'
view3d.move
'
km
=
bpy
.
context
.
window_manager
.
keyconfigs
.
default
.
keymaps
[
'
Image Paint
'
]
km
=
bpy
.
context
.
window_manager
.
keyconfigs
.
default
.
keymaps
[
'
Image Paint
'
]
#to do
for
kmi
in
(
kmi
for
kmi
in
km
.
keymap_items
if
kmi
.
idname
in
{
"
object.intuitivescale
"
,
"
object.bp_grab
"
,
"
object.bp_rotate
"
,
"
object.bp_scale
"
,
"
object.bp_scaleuv
"
,
"
object.bp_clear_prop
"
,
"
object.bp_offsetuv
"
,
}):
for
kmi
in
km
.
keymap_items
:
if
kmi
.
idname
==
'
paint.bp_paint
'
:
kmi
.
idname
=
'
paint.image_paint
'
for
kmi
in
(
kmi
for
kmi
in
km
.
keymap_items
if
kmi
.
idname
in
{
"
object.intuitivescale
"
,
"
object.bp_grab
"
,
"
object.bp_rotate
"
,
"
object.bp_scale
"
,
"
object.bp_scaleuv
"
,
"
object.bp_clear_prop
"
,
"
object.bp_offsetuv
"
,
"
object.bp_toggle_alpha
"
,
}):
km
.
keymap_items
.
remove
(
kmi
)
km
.
keymap_items
.
remove
(
kmi
)
# Oprerator Class to remove what is no more needed
# Oprerator Class to remove what is no more needed
...
@@ -1069,6 +1094,120 @@ class ChangeObject(Operator):
...
@@ -1069,6 +1094,120 @@ class ChangeObject(Operator):
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
#Paint from the bp_plan
last_mouse
=
Vector
((
0
,
0
))
def
move_bp
(
self
,
context
,
cm
,
fm
):
em
=
bpy
.
data
.
objects
[
'
Empty for BProjection
'
]
deltax
=
cm
.
x
-
round
(
fm
.
x
)
deltay
=
cm
.
y
-
round
(
fm
.
y
)
sd
=
context
.
space_data
l
=
sd
.
region_3d
vr
=
l
.
view_rotation
.
copy
()
vr
.
invert
()
v_init
=
Vector
((
0.0
,
0.0
,
1.0
))
pos
=
[
-
deltax
,
-
deltay
]
v
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
l
,
pos
,
v_init
)
pos
=
[
0
,
0
]
vbl
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
l
,
pos
,
v_init
)
loc
=
vbl
-
v
loc
.
rotate
(
vr
)
em
.
custom_location
-=
loc
self
.
first_mouse
=
cm
class
BP_Paint
(
bpy
.
types
.
Operator
):
bl_idname
=
"
paint.bp_paint
"
bl_label
=
"
Paint BProjection Plane
"
first_mouse
=
Vector
((
0
,
0
))
@classmethod
def
poll
(
cls
,
context
):
return
1
def
modal
(
self
,
context
,
event
):
global
last_mouse
em
=
bpy
.
data
.
objects
[
'
Empty for BProjection
'
]
sd
=
context
.
space_data
center
=
view3d_utils
.
location_3d_to_region_2d
(
context
.
region
,
sd
.
region_3d
,
em
.
location
)
vec_init
=
self
.
first_mouse
-
center
vec_act
=
Vector
((
event
.
mouse_region_x
,
event
.
mouse_region_y
))
-
center
print
(
event
.
type
)
if
event
.
type
==
'
MOUSEMOVE
'
:
#'INBETWEEN_MOUSEMOVE':
move_bp
(
self
,
context
,
Vector
((
event
.
mouse_region_x
,
event
.
mouse_region_y
))
-
self
.
v_offset
,
self
.
first_mouse
)
bpy
.
ops
.
paint
.
image_paint
(
stroke
=
[{
"
name
"
:
""
,
"
location
"
:(
0
,
0
,
0
),
"
mouse
"
:(
event
.
mouse_region_x
,
event
.
mouse_region_y
),
"
pressure
"
:
1
,
"
pen_flip
"
:
False
,
"
time
"
:
0
,
"
is_start
"
:
False
}])
if
event
.
type
==
'
LEFTMOUSE
'
:
em
.
custom_c3d
=
True
bpy
.
data
.
materials
[
'
Material for BProjection
'
].
alpha
=
self
.
alpha
em
.
custom_location
=
self
.
first_location
return
{
'
FINISHED
'
}
if
event
.
type
==
'
ESC
'
or
event
.
type
==
'
RIGHTMOUSE
'
:
em
.
custom_c3d
=
True
bpy
.
data
.
materials
[
'
Material for BProjection
'
].
alpha
=
self
.
alpha
em
.
custom_location
=
self
.
first_location
return
{
'
FINISHED
'
}
return
{
'
PASS_THROUGH
'
}
def
invoke
(
self
,
context
,
event
):
em
=
bpy
.
data
.
objects
[
'
Empty for BProjection
'
]
context
.
window_manager
.
modal_handler_add
(
self
)
self
.
first_mouse
=
Vector
((
event
.
mouse_region_x
,
event
.
mouse_region_y
))
sd
=
context
.
space_data
l
=
sd
.
region_3d
v_init
=
Vector
((
0.0
,
0.0
,
1.0
))
context
.
scene
.
cursor_location
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
l
,
[
event
.
mouse_region_x
,
event
.
mouse_region_y
],
v_init
)
self
.
first_location
=
em
.
custom_location
.
copy
()
self
.
v_offset
=
Vector
((
context
.
region
.
width
,
context
.
region
.
height
))
-
Vector
((
event
.
mouse_region_x
,
event
.
mouse_region_y
))
move_bp
(
self
,
context
,
Vector
((
event
.
mouse_region_x
,
event
.
mouse_region_y
))
-
self
.
v_offset
,
self
.
first_mouse
)
em
.
custom_c3d
=
False
self
.
alpha
=
bpy
.
data
.
materials
[
'
Material for BProjection
'
].
alpha
em
.
custom_location
.
z
=
-
10
bpy
.
data
.
materials
[
'
Material for BProjection
'
].
alpha
=
0
bpy
.
ops
.
paint
.
image_paint
(
stroke
=
[{
"
name
"
:
""
,
"
location
"
:(
0
,
0
,
0
),
"
mouse
"
:(
event
.
mouse_region_x
,
event
.
mouse_region_y
),
"
pressure
"
:
1
,
"
pen_flip
"
:
False
,
"
time
"
:
0
,
"
is_start
"
:
False
}])
return
{
'
RUNNING_MODAL
'
}
# Oprerator Class toggle the alpha of the plane
temp_alpha
=
1.0
class
ApplyImage
(
Operator
):
bl_idname
=
"
object.bp_toggle_alpha
"
bl_label
=
"
Toggle Alpha of the BP
"
def
execute
(
self
,
context
):
global
temp_alpha
if
temp_alpha
!=
0
:
bpy
.
data
.
materials
[
'
Material for BProjection
'
].
alpha
=
temp_alpha
temp_alpha
=
0
else
:
temp_alpha
=
bpy
.
data
.
materials
[
'
Material for BProjection
'
].
alpha
bpy
.
data
.
materials
[
'
Material for BProjection
'
].
alpha
=
0
return
{
'
FINISHED
'
}
#reinit the values of the bp_plane
#reinit the values of the bp_plane
class
BP_Clear_Props
(
Operator
):
class
BP_Clear_Props
(
Operator
):
bl_idname
=
"
object.bp_clear_prop
"
bl_idname
=
"
object.bp_clear_prop
"
...
@@ -1254,10 +1393,13 @@ class BP_Scale(bpy.types.Operator):
...
@@ -1254,10 +1393,13 @@ class BP_Scale(bpy.types.Operator):
em
=
bpy
.
data
.
objects
[
'
Empty for BProjection
'
]
em
=
bpy
.
data
.
objects
[
'
Empty for BProjection
'
]
sd
=
context
.
space_data
sd
=
context
.
space_data
if
event
.
shift
:
center
=
view3d_utils
.
location_3d_to_region_2d
(
context
.
region
,
sd
.
region_3d
,
em
.
location
)
fac
=
0.1
vec_init
=
self
.
first_mouse
-
center
else
:
vec_act
=
Vector
((
event
.
mouse_region_x
,
event
.
mouse_region_y
))
-
center
fac
=
1
scale_fac
=
vec_act
.
length
/
vec_init
.
length
if
event
.
ctrl
:
scale_fac
=
round
(
scale_fac
,
1
)
if
event
.
type
==
'
X
'
and
event
.
value
==
'
PRESS
'
:
if
event
.
type
==
'
X
'
and
event
.
value
==
'
PRESS
'
:
if
self
.
axe_x
==
True
and
self
.
axe_y
==
True
:
if
self
.
axe_x
==
True
and
self
.
axe_y
==
True
:
...
@@ -1277,11 +1419,6 @@ class BP_Scale(bpy.types.Operator):
...
@@ -1277,11 +1419,6 @@ class BP_Scale(bpy.types.Operator):
self
.
axe_y
=
True
self
.
axe_y
=
True
self
.
axe_x
=
False
self
.
axe_x
=
False
center
=
view3d_utils
.
location_3d_to_region_2d
(
context
.
region
,
sd
.
region_3d
,
em
.
location
)
vec_init
=
self
.
first_mouse
-
center
vec_act
=
Vector
((
event
.
mouse_region_x
,
event
.
mouse_region_y
))
-
center
scale_fac
=
vec_act
.
length
/
vec_init
.
length
if
event
.
type
==
'
MOUSEMOVE
'
:
if
event
.
type
==
'
MOUSEMOVE
'
:
if
self
.
axe_x
:
if
self
.
axe_x
:
...
@@ -1328,19 +1465,22 @@ class BP_Rotate(bpy.types.Operator):
...
@@ -1328,19 +1465,22 @@ class BP_Rotate(bpy.types.Operator):
em
=
bpy
.
data
.
objects
[
'
Empty for BProjection
'
]
em
=
bpy
.
data
.
objects
[
'
Empty for BProjection
'
]
sd
=
context
.
space_data
sd
=
context
.
space_data
center
=
view3d_utils
.
location_3d_to_region_2d
(
context
.
region
,
sd
.
region_3d
,
em
.
location
)
center
=
view3d_utils
.
location_3d_to_region_2d
(
context
.
region
,
sd
.
region_3d
,
em
.
location
if
em
.
custom_rotc3d
else
context
.
scene
.
cursor_location
)
vec_init
=
self
.
first_mouse
-
center
vec_init
=
self
.
first_mouse
-
center
vec_act
=
Vector
((
event
.
mouse_region_x
,
event
.
mouse_region_y
))
-
center
vec_act
=
Vector
((
event
.
mouse_region_x
,
event
.
mouse_region_y
))
-
center
rot
=
-
vec_init
.
angle_signed
(
vec_act
)
*
180
/
pi
rot
=
-
vec_init
.
angle_signed
(
vec_act
)
*
180
/
pi
if
event
.
shift
:
if
event
.
shift
:
fac
=
0.1
rot
=
rot
else
:
else
:
fac
=
1
rot
=
int
(
rot
)
if
event
.
ctrl
:
rot
=
int
(
rot
/
5
)
*
5
if
event
.
type
==
'
MOUSEMOVE
'
:
if
event
.
type
==
'
MOUSEMOVE
'
:
em
.
custom_rotation
=
self
.
first_rotation
+
rot
*
fac
em
.
custom_rotation
=
self
.
first_rotation
+
rot
if
event
.
type
==
'
LEFTMOUSE
'
:
if
event
.
type
==
'
LEFTMOUSE
'
:
return
{
'
FINISHED
'
}
return
{
'
FINISHED
'
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment