fix(ui): snap client is back
This commit is contained in:
13
client.py
13
client.py
@ -7,7 +7,6 @@ import threading
|
|||||||
import time
|
import time
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from random import randint
|
from random import randint
|
||||||
from uuid import uuid4
|
|
||||||
import copy
|
import copy
|
||||||
import queue
|
import queue
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
@ -174,10 +173,10 @@ class RCFClientAgent(object):
|
|||||||
self.publisher.setsockopt(zmq.SNDHWM, 60)
|
self.publisher.setsockopt(zmq.SNDHWM, 60)
|
||||||
self.publisher.linger = 0
|
self.publisher.linger = 0
|
||||||
self.serial, peer = zpipe(self.ctx)
|
self.serial, peer = zpipe(self.ctx)
|
||||||
self.serial_agent = threading.Thread(
|
# self.serial_agent = threading.Thread(
|
||||||
target=serialization_agent, args=(self.ctx, peer), name="serial-agent")
|
# target=serialization_agent, args=(self.ctx, peer), name="serial-agent")
|
||||||
self.serial_agent.daemon = True
|
# self.serial_agent.daemon = True
|
||||||
self.serial_agent.start()
|
# self.serial_agent.start()
|
||||||
|
|
||||||
def control_message(self):
|
def control_message(self):
|
||||||
msg = self.pipe.recv_multipart()
|
msg = self.pipe.recv_multipart()
|
||||||
@ -209,7 +208,7 @@ class RCFClientAgent(object):
|
|||||||
|
|
||||||
if value:
|
if value:
|
||||||
rcfmsg = message.RCFMessage(
|
rcfmsg = message.RCFMessage(
|
||||||
key=key, id=self.id,uuid=value['uuid'], mtype="", body=value)
|
key=key, id=self.id, mtype="", body=value)
|
||||||
|
|
||||||
rcfmsg.store(self.property_map)
|
rcfmsg.store(self.property_map)
|
||||||
rcfmsg.send(self.publisher)
|
rcfmsg.send(self.publisher)
|
||||||
@ -228,7 +227,7 @@ class RCFClientAgent(object):
|
|||||||
|
|
||||||
if value:
|
if value:
|
||||||
rcfmsg = message.RCFMessage(
|
rcfmsg = message.RCFMessage(
|
||||||
key=key, id=self.id,uuid=value['uuid'], mtype="", body=value)
|
key=key, id=self.id, mtype="", body=value)
|
||||||
|
|
||||||
rcfmsg.store(self.property_map)
|
rcfmsg.store(self.property_map)
|
||||||
rcfmsg.send(self.publisher)
|
rcfmsg.send(self.publisher)
|
||||||
|
15
helpers.py
15
helpers.py
@ -30,10 +30,7 @@ def load(key, value):
|
|||||||
target = resolve_bpy_path(key)
|
target = resolve_bpy_path(key)
|
||||||
target_type = key.split('/')[0]
|
target_type = key.split('/')[0]
|
||||||
|
|
||||||
try:
|
|
||||||
target.uuid = value['uuid']
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
if target_type == 'Object':
|
if target_type == 'Object':
|
||||||
load_object(target=target, data=value,
|
load_object(target=target, data=value,
|
||||||
create=True)
|
create=True)
|
||||||
@ -94,8 +91,6 @@ def load_client(client=None, data=None):
|
|||||||
D.objects[obj.name].hide_select = False
|
D.objects[obj.name].hide_select = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def load_mesh(target=None, data=None, create=False):
|
def load_mesh(target=None, data=None, create=False):
|
||||||
import bmesh
|
import bmesh
|
||||||
|
|
||||||
@ -331,20 +326,18 @@ def dump(key):
|
|||||||
data = None
|
data = None
|
||||||
|
|
||||||
|
|
||||||
target.uuid = str(uuid4)
|
|
||||||
|
|
||||||
if target_type == 'Material':
|
if target_type == 'Material':
|
||||||
data = dump_datablock_attibute(target, ['name', 'node_tree','uuid'], 7)
|
data = dump_datablock_attibute(target, ['name', 'node_tree','id'], 7)
|
||||||
elif target_type == 'Grease Pencil':
|
elif target_type == 'Grease Pencil':
|
||||||
data = dump_datablock_attibute(
|
data = dump_datablock_attibute(
|
||||||
target, ['name', 'layers', 'materials','uuid'], 9)
|
target, ['name', 'layers', 'materials','id'], 9)
|
||||||
elif target_type == 'Camera':
|
elif target_type == 'Camera':
|
||||||
data = dump_datablock(target, 1)
|
data = dump_datablock(target, 1)
|
||||||
elif target_type == 'Light':
|
elif target_type == 'Light':
|
||||||
data = dump_datablock(target, 1)
|
data = dump_datablock(target, 1)
|
||||||
elif target_type == 'Mesh':
|
elif target_type == 'Mesh':
|
||||||
data = dump_datablock_attibute(
|
data = dump_datablock_attibute(
|
||||||
target, ['name', 'polygons', 'edges', 'vertices','uuid'], 6)
|
target, ['name', 'polygons', 'edges', 'vertices','id'], 6)
|
||||||
elif target_type == 'Object':
|
elif target_type == 'Object':
|
||||||
data = dump_datablock(target, 1)
|
data = dump_datablock(target, 1)
|
||||||
elif target_type == 'Collection':
|
elif target_type == 'Collection':
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
from uuid import uuid4
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from .libs import umsgpack
|
from .libs import umsgpack
|
||||||
from .libs import zmq
|
from .libs import zmq
|
||||||
@ -22,14 +20,11 @@ class RCFMessage(object):
|
|||||||
id = None # User (string)
|
id = None # User (string)
|
||||||
mtype = None # data mtype (string)
|
mtype = None # data mtype (string)
|
||||||
body = None # data blob
|
body = None # data blob
|
||||||
uuid = None
|
|
||||||
|
|
||||||
def __init__(self, key=None, uuid=None, id=None, mtype=None, body=None):
|
|
||||||
if uuid is None:
|
|
||||||
uuid = uuid4().bytes
|
|
||||||
|
|
||||||
|
def __init__(self, key=None, id=None, mtype=None, body=None):
|
||||||
self.key = key
|
self.key = key
|
||||||
self.uuid = uuid
|
|
||||||
self.mtype = mtype
|
self.mtype = mtype
|
||||||
self.body = body
|
self.body = body
|
||||||
self.id = id
|
self.id = id
|
||||||
|
27
operators.py
27
operators.py
@ -6,7 +6,6 @@ import asyncio
|
|||||||
import queue
|
import queue
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
import subprocess
|
import subprocess
|
||||||
import uuid
|
|
||||||
import bgl
|
import bgl
|
||||||
import blf
|
import blf
|
||||||
import bpy
|
import bpy
|
||||||
@ -15,7 +14,6 @@ import gpu
|
|||||||
import mathutils
|
import mathutils
|
||||||
from bpy_extras import view3d_utils
|
from bpy_extras import view3d_utils
|
||||||
from gpu_extras.batch import batch_for_shader
|
from gpu_extras.batch import batch_for_shader
|
||||||
from uuid import uuid4
|
|
||||||
|
|
||||||
from . import client, ui, draw, helpers
|
from . import client, ui, draw, helpers
|
||||||
from .libs import umsgpack
|
from .libs import umsgpack
|
||||||
@ -140,9 +138,8 @@ def init_datablocks():
|
|||||||
|
|
||||||
for datatype in SUPPORTED_TYPES:
|
for datatype in SUPPORTED_TYPES:
|
||||||
for item in getattr(bpy.data, helpers.CORRESPONDANCE[datatype]):
|
for item in getattr(bpy.data, helpers.CORRESPONDANCE[datatype]):
|
||||||
item.uuid = str(uuid4())
|
item.id= bpy.context.scene.session_settings.username
|
||||||
key = "{}/{}".format(datatype, item.name)
|
key = "{}/{}".format(datatype, item.name)
|
||||||
print(key)
|
|
||||||
client_instance.add(key)
|
client_instance.add(key)
|
||||||
|
|
||||||
|
|
||||||
@ -346,22 +343,23 @@ class session_stop(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
global server
|
global server
|
||||||
global client_instance, client_keys
|
global client_instance, client_keys, client_state
|
||||||
|
|
||||||
net_settings = context.scene.session_settings
|
net_settings = context.scene.session_settings
|
||||||
|
|
||||||
|
|
||||||
if server:
|
if server:
|
||||||
server.kill()
|
server.kill()
|
||||||
del server
|
time.sleep(0.25)
|
||||||
server = None
|
server = None
|
||||||
if client_instance:
|
if client_instance:
|
||||||
client_instance.exit()
|
client_instance.exit()
|
||||||
|
time.sleep(0.25)
|
||||||
del client_instance
|
del client_instance
|
||||||
client_instance = None
|
client_instance = None
|
||||||
del client_keys
|
|
||||||
client_keys = None
|
client_keys = None
|
||||||
net_settings.is_running = False
|
net_settings.is_running = False
|
||||||
|
client_state = 1
|
||||||
unregister_ticks()
|
unregister_ticks()
|
||||||
else:
|
else:
|
||||||
logger.debug("No server/client_instance running.")
|
logger.debug("No server/client_instance running.")
|
||||||
@ -415,12 +413,13 @@ class session_snapview(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
global client_instance
|
global client_instance
|
||||||
|
|
||||||
area, region, rv3d = net_draw.view3d_find()
|
area, region, rv3d = draw.view3d_find()
|
||||||
|
|
||||||
for k, v in client_instance.property_map.items():
|
client = client_instance.get("Client/{}".format(self.target_client))
|
||||||
if v.mtype == 'client_instance' and v.id.decode() == self.target_client_instance:
|
if client:
|
||||||
rv3d.view_location = v.body['location'][1]
|
rv3d.view_location = client[0][1]['location'][0]
|
||||||
rv3d.view_distance = 30.0
|
rv3d.view_distance = 30.0
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
@ -513,7 +512,7 @@ def register():
|
|||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
register_class(cls)
|
register_class(cls)
|
||||||
bpy.types.ID.uuid = bpy.props.StringProperty(default="None")
|
bpy.types.ID.id = bpy.props.StringProperty(default="None")
|
||||||
bpy.types.Scene.session_settings = bpy.props.PointerProperty(
|
bpy.types.Scene.session_settings = bpy.props.PointerProperty(
|
||||||
type=session_settings)
|
type=session_settings)
|
||||||
bpy.app.handlers.depsgraph_update_post.append(depsgraph_update)
|
bpy.app.handlers.depsgraph_update_post.append(depsgraph_update)
|
||||||
@ -544,7 +543,7 @@ def unregister():
|
|||||||
unregister_class(cls)
|
unregister_class(cls)
|
||||||
|
|
||||||
del bpy.types.Scene.session_settings
|
del bpy.types.Scene.session_settings
|
||||||
|
del bpy.types.ID.id
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
Reference in New Issue
Block a user