fix(ui): snap client is back
This commit is contained in:
parent
4222bf62f5
commit
7ea45f6068
13
client.py
13
client.py
@ -7,7 +7,6 @@ import threading
|
||||
import time
|
||||
from enum import Enum
|
||||
from random import randint
|
||||
from uuid import uuid4
|
||||
import copy
|
||||
import queue
|
||||
lock = threading.Lock()
|
||||
@ -174,10 +173,10 @@ class RCFClientAgent(object):
|
||||
self.publisher.setsockopt(zmq.SNDHWM, 60)
|
||||
self.publisher.linger = 0
|
||||
self.serial, peer = zpipe(self.ctx)
|
||||
self.serial_agent = threading.Thread(
|
||||
target=serialization_agent, args=(self.ctx, peer), name="serial-agent")
|
||||
self.serial_agent.daemon = True
|
||||
self.serial_agent.start()
|
||||
# self.serial_agent = threading.Thread(
|
||||
# target=serialization_agent, args=(self.ctx, peer), name="serial-agent")
|
||||
# self.serial_agent.daemon = True
|
||||
# self.serial_agent.start()
|
||||
|
||||
def control_message(self):
|
||||
msg = self.pipe.recv_multipart()
|
||||
@ -209,7 +208,7 @@ class RCFClientAgent(object):
|
||||
|
||||
if value:
|
||||
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.send(self.publisher)
|
||||
@ -228,7 +227,7 @@ class RCFClientAgent(object):
|
||||
|
||||
if value:
|
||||
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.send(self.publisher)
|
||||
|
17
helpers.py
17
helpers.py
@ -30,10 +30,7 @@ def load(key, value):
|
||||
target = resolve_bpy_path(key)
|
||||
target_type = key.split('/')[0]
|
||||
|
||||
try:
|
||||
target.uuid = value['uuid']
|
||||
except:
|
||||
pass
|
||||
|
||||
if target_type == 'Object':
|
||||
load_object(target=target, data=value,
|
||||
create=True)
|
||||
@ -91,9 +88,7 @@ def load_client(client=None, data=None):
|
||||
if client_data['active_objects'] and obj.name in client_data['active_objects']:
|
||||
D.objects[obj.name].hide_select = True
|
||||
else:
|
||||
D.objects[obj.name].hide_select = False
|
||||
|
||||
|
||||
D.objects[obj.name].hide_select = False
|
||||
|
||||
|
||||
def load_mesh(target=None, data=None, create=False):
|
||||
@ -330,21 +325,19 @@ def dump(key):
|
||||
target_type = key.split('/')[0]
|
||||
data = None
|
||||
|
||||
|
||||
target.uuid = str(uuid4)
|
||||
|
||||
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':
|
||||
data = dump_datablock_attibute(
|
||||
target, ['name', 'layers', 'materials','uuid'], 9)
|
||||
target, ['name', 'layers', 'materials','id'], 9)
|
||||
elif target_type == 'Camera':
|
||||
data = dump_datablock(target, 1)
|
||||
elif target_type == 'Light':
|
||||
data = dump_datablock(target, 1)
|
||||
elif target_type == 'Mesh':
|
||||
data = dump_datablock_attibute(
|
||||
target, ['name', 'polygons', 'edges', 'vertices','uuid'], 6)
|
||||
target, ['name', 'polygons', 'edges', 'vertices','id'], 6)
|
||||
elif target_type == 'Object':
|
||||
data = dump_datablock(target, 1)
|
||||
elif target_type == 'Collection':
|
||||
|
@ -1,5 +1,3 @@
|
||||
from uuid import uuid4
|
||||
|
||||
try:
|
||||
from .libs import umsgpack
|
||||
from .libs import zmq
|
||||
@ -22,14 +20,11 @@ class RCFMessage(object):
|
||||
id = None # User (string)
|
||||
mtype = None # data mtype (string)
|
||||
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.uuid = uuid
|
||||
|
||||
self.mtype = mtype
|
||||
self.body = body
|
||||
self.id = id
|
||||
|
41
operators.py
41
operators.py
@ -6,7 +6,6 @@ import asyncio
|
||||
import queue
|
||||
from operator import itemgetter
|
||||
import subprocess
|
||||
import uuid
|
||||
import bgl
|
||||
import blf
|
||||
import bpy
|
||||
@ -15,7 +14,6 @@ import gpu
|
||||
import mathutils
|
||||
from bpy_extras import view3d_utils
|
||||
from gpu_extras.batch import batch_for_shader
|
||||
from uuid import uuid4
|
||||
|
||||
from . import client, ui, draw, helpers
|
||||
from .libs import umsgpack
|
||||
@ -140,9 +138,8 @@ def init_datablocks():
|
||||
|
||||
for datatype in SUPPORTED_TYPES:
|
||||
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)
|
||||
print(key)
|
||||
client_instance.add(key)
|
||||
|
||||
|
||||
@ -346,22 +343,23 @@ class session_stop(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
global server
|
||||
global client_instance, client_keys
|
||||
global client_instance, client_keys, client_state
|
||||
|
||||
net_settings = context.scene.session_settings
|
||||
|
||||
|
||||
if server:
|
||||
server.kill()
|
||||
del server
|
||||
time.sleep(0.25)
|
||||
server = None
|
||||
if client_instance:
|
||||
client_instance.exit()
|
||||
time.sleep(0.25)
|
||||
del client_instance
|
||||
client_instance = None
|
||||
del client_keys
|
||||
client_keys = None
|
||||
net_settings.is_running = False
|
||||
|
||||
client_state = 1
|
||||
unregister_ticks()
|
||||
else:
|
||||
logger.debug("No server/client_instance running.")
|
||||
@ -415,13 +413,14 @@ class session_snapview(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
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():
|
||||
if v.mtype == 'client_instance' and v.id.decode() == self.target_client_instance:
|
||||
rv3d.view_location = v.body['location'][1]
|
||||
rv3d.view_distance = 30.0
|
||||
return {"FINISHED"}
|
||||
client = client_instance.get("Client/{}".format(self.target_client))
|
||||
if client:
|
||||
rv3d.view_location = client[0][1]['location'][0]
|
||||
rv3d.view_distance = 30.0
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
return {"CANCELLED"}
|
||||
|
||||
@ -493,11 +492,11 @@ def depsgraph_update(scene):
|
||||
# print("{} applying update".format(username))
|
||||
|
||||
# if is_dirty(updates):
|
||||
# for update in ordered(updates):
|
||||
# if update[2] == "Master Collection":
|
||||
# pass
|
||||
# elif update[1] in SUPPORTED_TYPES:
|
||||
# client_instance.add("{}/{}".format(update[1], update[2]))
|
||||
# for update in ordered(updates):
|
||||
# if update[2] == "Master Collection":
|
||||
# pass
|
||||
# elif update[1] in SUPPORTED_TYPES:
|
||||
# client_instance.add("{}/{}".format(update[1], update[2]))
|
||||
|
||||
if hasattr(bpy.context, 'selected_objects'):
|
||||
selected_objects = helpers.get_selected_objects(scene)
|
||||
@ -513,7 +512,7 @@ def register():
|
||||
from bpy.utils import register_class
|
||||
for cls in classes:
|
||||
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(
|
||||
type=session_settings)
|
||||
bpy.app.handlers.depsgraph_update_post.append(depsgraph_update)
|
||||
@ -544,7 +543,7 @@ def unregister():
|
||||
unregister_class(cls)
|
||||
|
||||
del bpy.types.Scene.session_settings
|
||||
|
||||
del bpy.types.ID.id
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
Loading…
Reference in New Issue
Block a user