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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons-contrib
Commits
a737f72d
Commit
a737f72d
authored
12 years ago
by
Geo Kgeo
Browse files
Options
Downloads
Patches
Plain Diff
better fix for load factory and New file, use the handler
parent
75b8b27b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
space_view3d_paint_bprojection.py
+83
-92
83 additions, 92 deletions
space_view3d_paint_bprojection.py
with
83 additions
and
92 deletions
space_view3d_paint_bprojection.py
+
83
−
92
View file @
a737f72d
...
...
@@ -9,6 +9,7 @@ bl_info = {
"
category
"
:
"
Paint
"
}
import
bpy
from
bpy.app.handlers
import
persistent
from
bpy.types
import
Panel
,
Operator
from
bpy.props
import
IntProperty
,
FloatProperty
,
BoolProperty
,
IntVectorProperty
,
StringProperty
,
FloatVectorProperty
,
CollectionProperty
from
bpy_extras
import
view3d_utils
...
...
@@ -1223,19 +1224,15 @@ class RotateView3D(Operator):
return
{
'
FINISHED
'
}
def
invoke
(
self
,
context
,
event
):
try
:
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
))
self
.
first_time
=
True
for
sub
in
context
.
object
.
modifiers
:
if
sub
.
type
in
[
'
SUBSURF
'
,
'
MULTIRES
'
]:
self
.
tmp_level
=
sub
.
levels
sub
.
levels
=
0
return
{
'
RUNNING_MODAL
'
}
except
:
reinitkey
()
return
{
'
RUNNING_MODAL
'
}
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
))
self
.
first_time
=
True
for
sub
in
context
.
object
.
modifiers
:
if
sub
.
type
in
[
'
SUBSURF
'
,
'
MULTIRES
'
]:
self
.
tmp_level
=
sub
.
levels
sub
.
levels
=
0
return
{
'
RUNNING_MODAL
'
}
# Oprerator Class to pan the view3D
...
...
@@ -1284,20 +1281,17 @@ class PanView3D(bpy.types.Operator):
return
{
'
RUNNING_MODAL
'
}
def
invoke
(
self
,
context
,
event
):
try
:
bpy
.
data
.
objects
[
'
Empty for BProjection
'
]
context
.
window_manager
.
modal_handler_add
(
self
)
self
.
first_mouse
.
x
=
event
.
mouse_region_x
self
.
first_mouse
.
y
=
event
.
mouse_region_y
for
sub
in
context
.
object
.
modifiers
:
if
sub
.
type
in
[
'
SUBSURF
'
,
'
MULTIRES
'
]:
self
.
tmp_level
=
sub
.
levels
sub
.
levels
=
0
return
{
'
RUNNING_MODAL
'
}
except
:
reinitkey
()
return
{
'
RUNNING_MODAL
'
}
bpy
.
data
.
objects
[
'
Empty for BProjection
'
]
context
.
window_manager
.
modal_handler_add
(
self
)
self
.
first_mouse
.
x
=
event
.
mouse_region_x
self
.
first_mouse
.
y
=
event
.
mouse_region_y
for
sub
in
context
.
object
.
modifiers
:
if
sub
.
type
in
[
'
SUBSURF
'
,
'
MULTIRES
'
]:
self
.
tmp_level
=
sub
.
levels
sub
.
levels
=
0
return
{
'
RUNNING_MODAL
'
}
def
execute
(
self
,
context
):
align_to_view
(
context
)
...
...
@@ -1315,46 +1309,42 @@ class ZoomView3D(Operator):
default
=
1.0
)
def
invoke
(
self
,
context
,
event
):
try
:
ob
=
context
.
object
em
=
bpy
.
data
.
objects
[
BProjection_Empty
]
sd
=
context
.
space_data
width
=
context
.
area
.
regions
[
4
].
width
height
=
context
.
area
.
regions
[
4
].
height
r3d
=
sd
.
region_3d
v_init
=
Vector
((
0.0
,
0.0
,
1.0
))
pos
=
[
width
,
height
]
vtr_b
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
r3d
,
pos
,
v_init
)
pos
=
[
0
,
0
]
vbl_b
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
r3d
,
pos
,
v_init
)
len_b
=
vtr_b
-
vbl_b
bpy
.
ops
.
view3d
.
zoom
(
delta
=
self
.
delta
)
r3d
.
update
()
pos
=
[
width
,
height
]
vtr_a
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
r3d
,
pos
,
v_init
)
pos
=
[
0
,
0
]
vbl_a
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
r3d
,
pos
,
v_init
)
len_a
=
vtr_a
-
vbl_a
fac
=
len_a
.
length
/
len_b
.
length
r3d
.
view_location
-=
ob
.
location
r3d
.
view_location
*=
fac
r3d
.
view_location
+=
ob
.
location
vres
=
Vector
((
em
.
custom_location
.
x
*
fac
,
em
.
custom_location
.
y
*
fac
,
em
.
custom_location
.
z
))
em
.
custom_location
=
vres
align_to_view
(
context
)
return
{
'
FINISHED
'
}
except
:
reinitkey
()
return
{
'
RUNNING_MODAL
'
}
ob
=
context
.
object
em
=
bpy
.
data
.
objects
[
BProjection_Empty
]
sd
=
context
.
space_data
width
=
context
.
area
.
regions
[
4
].
width
height
=
context
.
area
.
regions
[
4
].
height
r3d
=
sd
.
region_3d
v_init
=
Vector
((
0.0
,
0.0
,
1.0
))
pos
=
[
width
,
height
]
vtr_b
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
r3d
,
pos
,
v_init
)
pos
=
[
0
,
0
]
vbl_b
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
r3d
,
pos
,
v_init
)
len_b
=
vtr_b
-
vbl_b
bpy
.
ops
.
view3d
.
zoom
(
delta
=
self
.
delta
)
r3d
.
update
()
pos
=
[
width
,
height
]
vtr_a
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
r3d
,
pos
,
v_init
)
pos
=
[
0
,
0
]
vbl_a
=
view3d_utils
.
region_2d_to_location_3d
(
context
.
region
,
r3d
,
pos
,
v_init
)
len_a
=
vtr_a
-
vbl_a
fac
=
len_a
.
length
/
len_b
.
length
r3d
.
view_location
-=
ob
.
location
r3d
.
view_location
*=
fac
r3d
.
view_location
+=
ob
.
location
vres
=
Vector
((
em
.
custom_location
.
x
*
fac
,
em
.
custom_location
.
y
*
fac
,
em
.
custom_location
.
z
))
em
.
custom_location
=
vres
align_to_view
(
context
)
return
{
'
FINISHED
'
}
def
execute
(
self
,
context
):
align_to_view
(
context
)
...
...
@@ -1368,35 +1358,36 @@ class PresetView3D(Operator):
view
=
StringProperty
(
name
=
"
View
"
,
description
=
"
Select the view
"
,
default
=
'
TOP
'
)
def
invoke
(
self
,
context
,
event
):
try
:
ob
=
context
.
object
em
=
bpy
.
data
.
objects
[
BProjection_Empty
]
origine
=
ob
.
location
sd
=
context
.
space_data
vr_b
=
sd
.
region_3d
.
view_rotation
.
copy
()
vr_b
.
invert
()
pos_init
=
sd
.
region_3d
.
view_location
-
origine
sd
.
region_3d
.
view_location
=
origine
tmp
=
context
.
user_preferences
.
view
.
smooth_view
context
.
user_preferences
.
view
.
smooth_view
=
0
bpy
.
ops
.
view3d
.
viewnumpad
(
type
=
self
.
view
)
align_to_view
(
context
)
context
.
user_preferences
.
view
.
smooth_view
=
tmp
vr_a
=
sd
.
region_3d
.
view_rotation
.
copy
()
pos_init
.
rotate
(
vr_a
*
vr_b
)
sd
.
region_3d
.
view_location
=
pos_init
+
origine
return
{
'
FINISHED
'
}
except
:
reinitkey
()
return
{
'
RUNNING_MODAL
'
}
ob
=
context
.
object
em
=
bpy
.
data
.
objects
[
BProjection_Empty
]
origine
=
ob
.
location
sd
=
context
.
space_data
vr_b
=
sd
.
region_3d
.
view_rotation
.
copy
()
vr_b
.
invert
()
pos_init
=
sd
.
region_3d
.
view_location
-
origine
sd
.
region_3d
.
view_location
=
origine
tmp
=
context
.
user_preferences
.
view
.
smooth_view
context
.
user_preferences
.
view
.
smooth_view
=
0
bpy
.
ops
.
view3d
.
viewnumpad
(
type
=
self
.
view
)
align_to_view
(
context
)
context
.
user_preferences
.
view
.
smooth_view
=
tmp
vr_a
=
sd
.
region_3d
.
view_rotation
.
copy
()
pos_init
.
rotate
(
vr_a
*
vr_b
)
sd
.
region_3d
.
view_location
=
pos_init
+
origine
return
{
'
FINISHED
'
}
@persistent
def
load_handler
(
dummy
):
reinitkey
()
def
register
():
bpy
.
utils
.
register_module
(
__name__
)
createcustomprops
(
bpy
.
context
)
bpy
.
app
.
handlers
.
load_post
.
append
(
load_handler
)
def
unregister
():
bpy
.
utils
.
unregister_module
(
__name__
)
...
...
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