@ -32,6 +32,8 @@ stop_modal_executor = False
|
|||||||
modal_executor_queue = None
|
modal_executor_queue = None
|
||||||
|
|
||||||
# OPERATORS
|
# OPERATORS
|
||||||
|
|
||||||
|
|
||||||
class SessionStartOperator(bpy.types.Operator):
|
class SessionStartOperator(bpy.types.Operator):
|
||||||
bl_idname = "session.start"
|
bl_idname = "session.start"
|
||||||
bl_label = "start"
|
bl_label = "start"
|
||||||
@ -96,7 +98,7 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
if client.state == 0:
|
if client.state == 0:
|
||||||
settings.is_admin = False
|
settings.is_admin = False
|
||||||
self.report(
|
self.report(
|
||||||
@ -104,8 +106,6 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
"A session is already hosted on this address")
|
"A session is already hosted on this address")
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Init user settings
|
# Init user settings
|
||||||
usr = presence.User(
|
usr = presence.User(
|
||||||
username=settings.username,
|
username=settings.username,
|
||||||
@ -114,14 +114,14 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
settings.client_color.b,
|
settings.client_color.b,
|
||||||
1),
|
1),
|
||||||
)
|
)
|
||||||
|
|
||||||
settings.user_uuid = client.add(usr,owner=settings.username)
|
settings.user_uuid = client.add(usr, owner=settings.username)
|
||||||
client.commit(settings.user_uuid)
|
client.commit(settings.user_uuid)
|
||||||
|
|
||||||
if settings.init_scene and self.host:
|
if settings.init_scene and self.host:
|
||||||
for scene in bpy.data.scenes:
|
for scene in bpy.data.scenes:
|
||||||
scene_uuid = client.add(scene)
|
scene_uuid = client.add(scene)
|
||||||
|
|
||||||
# for node in client.list():
|
# for node in client.list():
|
||||||
client.commit(scene_uuid)
|
client.commit(scene_uuid)
|
||||||
delayables.append(delayable.ClientUpdate(
|
delayables.append(delayable.ClientUpdate(
|
||||||
@ -139,10 +139,10 @@ class SessionStartOperator(bpy.types.Operator):
|
|||||||
# Register blender main thread tools
|
# Register blender main thread tools
|
||||||
for d in delayables:
|
for d in delayables:
|
||||||
d.register()
|
d.register()
|
||||||
|
|
||||||
global modal_executor_queue
|
global modal_executor_queue
|
||||||
modal_executor_queue = queue.Queue()
|
modal_executor_queue = queue.Queue()
|
||||||
bpy.ops.wm.modal_executor_operator()
|
bpy.ops.session.apply_armature_operator()
|
||||||
|
|
||||||
self.report(
|
self.report(
|
||||||
{'INFO'},
|
{'INFO'},
|
||||||
@ -163,7 +163,7 @@ class SessionStopOperator(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
global client, delayables, stop_modal_executor
|
global client, delayables, stop_modal_executor
|
||||||
|
|
||||||
stop_modal_executor= True
|
stop_modal_executor = True
|
||||||
settings = context.window_manager.session
|
settings = context.window_manager.session
|
||||||
settings.is_admin = False
|
settings.is_admin = False
|
||||||
assert(client)
|
assert(client)
|
||||||
@ -177,7 +177,7 @@ class SessionStopOperator(bpy.types.Operator):
|
|||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
presence.renderer.stop()
|
presence.renderer.stop()
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@ -274,7 +274,8 @@ class SessionSnapUserOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
target_client = client.get(uuid=self.target_client)
|
target_client = client.get(uuid=self.target_client)
|
||||||
if target_client:
|
if target_client:
|
||||||
rv3d.view_matrix = mathutils.Matrix(target_client.data['view_matrix'])
|
rv3d.view_matrix = mathutils.Matrix(
|
||||||
|
target_client.data['view_matrix'])
|
||||||
else:
|
else:
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
@ -320,9 +321,10 @@ class SessionCommit(bpy.types.Operator):
|
|||||||
client.push(self.target)
|
client.push(self.target)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
class ModalExecutorOperator(bpy.types.Operator):
|
|
||||||
|
class ApplyArmatureOperator(bpy.types.Operator):
|
||||||
"""Operator which runs its self from a timer"""
|
"""Operator which runs its self from a timer"""
|
||||||
bl_idname = "wm.modal_executor_operator"
|
bl_idname = "session.apply_armature_operator"
|
||||||
bl_label = "Modal Executor Operator"
|
bl_label = "Modal Executor Operator"
|
||||||
|
|
||||||
_timer = None
|
_timer = None
|
||||||
@ -344,8 +346,9 @@ class ModalExecutorOperator(bpy.types.Operator):
|
|||||||
try:
|
try:
|
||||||
client.apply(node)
|
client.apply(node)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("fail to apply {}: {}".format(node_ref.uuid,e))
|
logger.error(
|
||||||
|
"fail to apply {}: {}".format(node_ref.uuid, e))
|
||||||
|
|
||||||
return {'PASS_THROUGH'}
|
return {'PASS_THROUGH'}
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
@ -361,7 +364,7 @@ class ModalExecutorOperator(bpy.types.Operator):
|
|||||||
wm.event_timer_remove(self._timer)
|
wm.event_timer_remove(self._timer)
|
||||||
|
|
||||||
stop_modal_executor = False
|
stop_modal_executor = False
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
SessionStartOperator,
|
SessionStartOperator,
|
||||||
@ -371,7 +374,7 @@ classes = (
|
|||||||
SessionPropertyRightOperator,
|
SessionPropertyRightOperator,
|
||||||
SessionApply,
|
SessionApply,
|
||||||
SessionCommit,
|
SessionCommit,
|
||||||
ModalExecutorOperator,
|
ApplyArmatureOperator,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -380,6 +383,7 @@ def register():
|
|||||||
for cls in classes:
|
for cls in classes:
|
||||||
register_class(cls)
|
register_class(cls)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
global client
|
global client
|
||||||
|
|
||||||
@ -391,5 +395,6 @@ def unregister():
|
|||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
unregister_class(cls)
|
unregister_class(cls)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
Reference in New Issue
Block a user