mesh_snap_utilities_line: New solution for creating framebuffer out of the right rendering context
The way was to delay the initialization of the framebuffer for the test_select method. (This rendering context issue gives a lot of headache)!
This commit is contained in:
parent
62ce90ff1a
commit
a5aec7f5a5
|
@ -22,7 +22,7 @@
|
|||
bl_info = {
|
||||
"name": "Snap_Utilities_Line",
|
||||
"author": "Germano Cavalcante",
|
||||
"version": (5, 9, 2),
|
||||
"version": (5, 9, 3),
|
||||
"blender": (2, 80, 0),
|
||||
"location": "View3D > TOOLS > Line Tool",
|
||||
"description": "Extends Blender Snap controls",
|
||||
|
@ -154,10 +154,6 @@ classes = (
|
|||
)
|
||||
|
||||
def register():
|
||||
from .snap_context_l import global_snap_context_init
|
||||
# This makes sure that the framebuffer is created in the correct context
|
||||
global_snap_context_init(None, None, None)
|
||||
|
||||
for cls in classes:
|
||||
bpy.utils.register_class(cls)
|
||||
|
||||
|
@ -165,9 +161,6 @@ def register():
|
|||
|
||||
|
||||
def unregister():
|
||||
from .snap_context_l import global_snap_context_destroy
|
||||
global_snap_context_destroy()
|
||||
|
||||
unregister_snap_tools()
|
||||
|
||||
for cls in reversed(classes):
|
||||
|
|
|
@ -548,7 +548,7 @@ class SnapContext():
|
|||
self.freed = True
|
||||
|
||||
|
||||
def global_snap_context_init(depsgraph, region, space):
|
||||
def global_snap_context_get(depsgraph, region, space):
|
||||
if _Internal.global_snap_context == None:
|
||||
import atexit
|
||||
|
||||
|
@ -558,15 +558,7 @@ def global_snap_context_init(depsgraph, region, space):
|
|||
atexit.unregister(_Internal.snap_context_free)
|
||||
atexit.register(_Internal.snap_context_free)
|
||||
|
||||
|
||||
def global_snap_context_get(depsgraph, region, space):
|
||||
if (depsgraph and region and space):
|
||||
elif (depsgraph and region and space):
|
||||
_Internal.global_snap_context.update_viewport_context(depsgraph, region, space, True)
|
||||
|
||||
return _Internal.global_snap_context
|
||||
|
||||
|
||||
def global_snap_context_destroy():
|
||||
if _Internal.global_snap_context != None:
|
||||
_Internal.global_snap_context.free()
|
||||
_Internal.global_snap_context = None
|
||||
|
|
|
@ -53,7 +53,12 @@ class SnapWidgetCommon(SnapUtilities):
|
|||
|
||||
self.draw_cache.draw(self.type, self.location, None, None, None)
|
||||
|
||||
def init_delayed(self):
|
||||
self.inited = False
|
||||
|
||||
def init_snapwidget(self, context, snap_edge_and_vert = True):
|
||||
self.inited = True
|
||||
|
||||
self.snap_context_init(context, snap_edge_and_vert)
|
||||
self.snap_context_update(context)
|
||||
self.mode = context.mode
|
||||
|
@ -118,6 +123,9 @@ class SnapPointWidget(SnapWidgetCommon, bpy.types.Gizmo):
|
|||
bl_idname = "VIEW3D_GT_snap_point"
|
||||
|
||||
def test_select(self, context, mval):
|
||||
if not self.inited:
|
||||
self.init_snapwidget(context)
|
||||
|
||||
self.update_snap(context, mval)
|
||||
self.snap_to_grid()
|
||||
|
||||
|
@ -125,11 +133,11 @@ class SnapPointWidget(SnapWidgetCommon, bpy.types.Gizmo):
|
|||
return -1
|
||||
|
||||
def draw(self, context):
|
||||
self.draw_point_and_elem()
|
||||
if self.inited:
|
||||
self.draw_point_and_elem()
|
||||
|
||||
def setup(self):
|
||||
self.init_snapwidget(bpy.context)
|
||||
|
||||
self.init_delayed()
|
||||
|
||||
def context_mode_check(context, widget_group):
|
||||
workspace = context.workspace
|
||||
|
|
Loading…
Reference in New Issue