fix: material loading
This commit is contained in:
parent
40b9b02590
commit
d717e01f3f
@ -457,8 +457,9 @@ def rcf_client_worker(ctx,store, pipe, serial_product, serial_feed, stop_event):
|
||||
|
||||
# with lock:
|
||||
# helpers.load(rcfmsg.key, rcfmsg.body)
|
||||
net_product.put(('LOAD',rcfmsg.key, rcfmsg.body))
|
||||
rcfmsg.store(agent.property_map)
|
||||
net_product.put(('LOAD',rcfmsg.key, rcfmsg.body))
|
||||
|
||||
|
||||
else:
|
||||
logger.debug("{} nothing to do".format(agent.id))
|
||||
|
4
draw.py
4
draw.py
@ -122,7 +122,7 @@ class DrawFactory(object):
|
||||
def draw_client_selected_objects(self, client):
|
||||
if client:
|
||||
name = client['id']
|
||||
local_username = bpy.context.scene.session_settings.username
|
||||
local_username = bpy.context.window_manager.session_settings.username
|
||||
|
||||
if name != local_username:
|
||||
if client['active_objects']:
|
||||
@ -165,7 +165,7 @@ class DrawFactory(object):
|
||||
def draw_client(self, client):
|
||||
if client:
|
||||
name = client['id']
|
||||
local_username = bpy.context.scene.session_settings.username
|
||||
local_username = bpy.context.window_manager.session_settings.username
|
||||
|
||||
if name != local_username:
|
||||
try:
|
||||
|
15
helpers.py
15
helpers.py
@ -73,7 +73,7 @@ def get_all_datablocks():
|
||||
datas = []
|
||||
for datatype in SUPPORTED_TYPES:
|
||||
for item in getattr(bpy.data, CORRESPONDANCE[datatype]):
|
||||
item.id = bpy.context.scene.session_settings.username
|
||||
item.id = bpy.context.window_manager.session_settings.username
|
||||
datas.append("{}/{}".format(datatype, item.name))
|
||||
|
||||
return datas
|
||||
@ -141,7 +141,7 @@ def resolve_bpy_path(path):
|
||||
def load_client(client=None, data=None):
|
||||
C = bpy.context
|
||||
D = bpy.data
|
||||
net_settings = C.scene.session_settings
|
||||
net_settings = C.window_manager.session_settings
|
||||
|
||||
if client and data:
|
||||
if net_settings.enable_draw:
|
||||
@ -276,7 +276,7 @@ def load_object(target=None, data=None, create=False):
|
||||
|
||||
target.id = data['id']
|
||||
|
||||
client = bpy.context.scene.session_settings.username
|
||||
client = bpy.context.window_manager.session_settings.username
|
||||
|
||||
if target.id == client:
|
||||
target.hide_select = False
|
||||
@ -342,7 +342,7 @@ def load_collection(target=None, data=None, create=False):
|
||||
target.id = data['id']
|
||||
|
||||
|
||||
client = bpy.context.scene.session_settings.username
|
||||
client = bpy.context.window_manager.session_settings.username
|
||||
|
||||
if target.id == client:
|
||||
target.hide_select = False
|
||||
@ -401,7 +401,7 @@ def load_material(target=None, data=None, create=False):
|
||||
if target is None:
|
||||
target = bpy.data.materials.new(data["name"])
|
||||
|
||||
if data['grease_pencil']:
|
||||
if data['is_grease_pencil']:
|
||||
if not target.is_grease_pencil:
|
||||
bpy.data.materials.create_gpencil_data(target)
|
||||
|
||||
@ -545,7 +545,8 @@ def dump(key):
|
||||
data = None
|
||||
|
||||
if target_type == 'Material':
|
||||
data = dump_datablock_attibute(target, ['name','grease_pencil' ,'node_tree', 'id'], 7)
|
||||
data = dump_datablock(target, 2)
|
||||
dump_datablock_attibute(target, ['node_tree'], 7, data)
|
||||
elif target_type == 'Grease Pencil':
|
||||
data = dump_datablock(target, 2)
|
||||
dump_datablock_attibute(
|
||||
@ -630,7 +631,7 @@ def init_client(key=None):
|
||||
client_dict = {}
|
||||
|
||||
C = bpy.context
|
||||
Net = C.scene.session_settings
|
||||
Net = C.window_manager.session_settings
|
||||
client_dict['uuid'] = str(uuid4())
|
||||
client_dict['location'] = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
|
||||
client_dict['color'] = [Net.client_color.r,
|
||||
|
63
operators.py
63
operators.py
@ -40,7 +40,7 @@ def client_list_callback(scene, context):
|
||||
|
||||
items = [("Common", "Common", "")]
|
||||
|
||||
username = bpy.context.scene.session_settings.username
|
||||
username = bpy.context.window_manager.session_settings.username
|
||||
|
||||
if client_keys:
|
||||
for k in client_keys:
|
||||
@ -87,7 +87,7 @@ def refresh_window():
|
||||
def upload_client_instance_position():
|
||||
global client_instance
|
||||
|
||||
username = bpy.context.scene.session_settings.username
|
||||
username = bpy.context.window_manager.session_settings.username
|
||||
if client_instance:
|
||||
|
||||
key = "Client/{}".format(username)
|
||||
@ -105,9 +105,9 @@ def upload_client_instance_position():
|
||||
|
||||
def update_selected_object(context):
|
||||
global client_instance
|
||||
session = bpy.context.scene.session_settings
|
||||
session = bpy.context.window_manager.session_settings
|
||||
|
||||
username = bpy.context.scene.session_settings.username
|
||||
username = bpy.context.window_manager.session_settings.username
|
||||
client_key = "Client/{}".format(username)
|
||||
client_data = client_instance.get(client_key)
|
||||
|
||||
@ -132,7 +132,7 @@ def init_datablocks():
|
||||
|
||||
for datatype in helpers.SUPPORTED_TYPES:
|
||||
for item in getattr(bpy.data, helpers.CORRESPONDANCE[datatype]):
|
||||
item.id = bpy.context.scene.session_settings.username
|
||||
item.id = bpy.context.window_manager.session_settings.username
|
||||
key = "{}/{}".format(datatype, item.name)
|
||||
client_instance.set(key)
|
||||
|
||||
@ -205,7 +205,7 @@ class session_join(bpy.types.Operator):
|
||||
def execute(self, context):
|
||||
global client_instance
|
||||
|
||||
net_settings = context.scene.session_settings
|
||||
net_settings = context.window_manager.session_settings
|
||||
# Scene setup
|
||||
if net_settings.clear_scene:
|
||||
clean_scene()
|
||||
@ -215,7 +215,7 @@ class session_join(bpy.types.Operator):
|
||||
net_settings.username = "{}_{}".format(
|
||||
net_settings.username, randomStringDigits())
|
||||
|
||||
username = str(context.scene.session_settings.username)
|
||||
username = str(context.window_manager.session_settings.username)
|
||||
|
||||
if len(net_settings.ip) < 1:
|
||||
net_settings.ip = "127.0.0.1"
|
||||
@ -327,7 +327,7 @@ class session_create(bpy.types.Operator):
|
||||
global server
|
||||
global client_instance
|
||||
|
||||
net_settings = context.scene.session_settings
|
||||
net_settings = context.window_manager.session_settings
|
||||
|
||||
script = os.path.join(os.path.dirname(os.path.abspath(__file__)),"server.py")
|
||||
|
||||
@ -360,7 +360,7 @@ class session_stop(bpy.types.Operator):
|
||||
global server
|
||||
global client_instance, client_keys, client_state
|
||||
|
||||
net_settings = context.scene.session_settings
|
||||
net_settings = context.window_manager.session_settings
|
||||
|
||||
if server:
|
||||
server.kill()
|
||||
@ -402,7 +402,7 @@ class session_rights(bpy.types.Operator):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
net_settings = context.scene.session_settings
|
||||
net_settings = context.window_manager.session_settings
|
||||
|
||||
col = layout.column()
|
||||
col.prop(net_settings, "clients")
|
||||
@ -411,7 +411,7 @@ class session_rights(bpy.types.Operator):
|
||||
global server
|
||||
global client_instance, client_keys, client_state
|
||||
|
||||
net_settings = context.scene.session_settings
|
||||
net_settings = context.window_manager.session_settings
|
||||
|
||||
if net_settings.is_admin:
|
||||
val = client_instance.get(self.key)
|
||||
@ -576,8 +576,8 @@ def depsgraph_update(scene):
|
||||
|
||||
if ctx.mode in ['OBJECT','PAINT_GPENCIL']:
|
||||
updates = ctx.depsgraph.updates
|
||||
username = ctx.scene.session_settings.username
|
||||
|
||||
username = ctx.window_manager.session_settings.username
|
||||
|
||||
|
||||
selected_objects = helpers.get_selected_objects(scene)
|
||||
|
||||
@ -586,24 +586,27 @@ def depsgraph_update(scene):
|
||||
if update.id.id == username or update.id.id == 'Common':
|
||||
toogle_dirty(ctx, update)
|
||||
else:
|
||||
item = get_datablock(update,ctx)
|
||||
#get parent authority
|
||||
parent_id = ctx.collection.id if ctx.collection.id != 'None' else ctx.scene.id
|
||||
|
||||
if hasattr(item,"id"):
|
||||
parent_id = ctx.collection.id if ctx.collection.id != 'None' else ctx.scene.id
|
||||
|
||||
if parent_id == username or parent_id == 'Common':
|
||||
item = get_datablock(update,ctx)
|
||||
item.id = bpy.context.scene.session_settings.username
|
||||
if parent_id == username or parent_id == 'Common':
|
||||
|
||||
item.id = username
|
||||
|
||||
key = "{}/{}".format(item.__class__.__name__, item.name)
|
||||
client_instance.set(key)
|
||||
else:
|
||||
history.put("etst")
|
||||
try:
|
||||
item = get_datablock(update,ctx)
|
||||
print(item)
|
||||
getattr(bpy.data, helpers.CORRESPONDANCE[update.id.__class__.__name__]).remove(item)
|
||||
except:
|
||||
print("asdasdasd")
|
||||
break
|
||||
key = "{}/{}".format(item.__class__.__name__, item.name)
|
||||
client_instance.set(key)
|
||||
else:
|
||||
history.put("etst")
|
||||
try:
|
||||
item = get_datablock(update,ctx)
|
||||
print(item)
|
||||
getattr(bpy.data, helpers.CORRESPONDANCE[update.id.__class__.__name__]).remove(item)
|
||||
except:
|
||||
print("asdasdasd")
|
||||
break
|
||||
|
||||
update_selected_object(ctx)
|
||||
# if update.id.id == username or update.id.id == 'Common' or update.id.id == 'None':
|
||||
@ -623,7 +626,7 @@ def register():
|
||||
register_class(cls)
|
||||
bpy.types.ID.id = bpy.props.StringProperty(default="None")
|
||||
bpy.types.ID.is_dirty = bpy.props.BoolProperty(default=False)
|
||||
bpy.types.Scene.session_settings = bpy.props.PointerProperty(
|
||||
bpy.types.WindowManager.session_settings = bpy.props.PointerProperty(
|
||||
type=session_settings)
|
||||
bpy.app.handlers.depsgraph_update_post.append(depsgraph_update)
|
||||
draw.register()
|
||||
@ -655,7 +658,7 @@ def unregister():
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
|
||||
del bpy.types.Scene.session_settings
|
||||
del bpy.types.WindowManager.session_settings
|
||||
del bpy.types.ID.id
|
||||
del bpy.types.ID.is_dirty
|
||||
|
||||
|
26
ui.py
26
ui.py
@ -19,9 +19,9 @@ class SessionSettingsPanel(bpy.types.Panel):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
if hasattr(context.scene, 'session_settings'):
|
||||
net_settings = context.scene.session_settings
|
||||
scene = context.scene
|
||||
if hasattr(context.window_manager, 'session_settings'):
|
||||
net_settings = context.window_manager.session_settings
|
||||
window_manager = context.window_manager
|
||||
|
||||
row = layout.row()
|
||||
if operators.client_instance is None:
|
||||
@ -30,10 +30,10 @@ class SessionSettingsPanel(bpy.types.Panel):
|
||||
row = box.row()
|
||||
row.label(text="USER", icon='TRIA_RIGHT')
|
||||
row = box.row()
|
||||
row.prop(scene.session_settings, "username", text="id")
|
||||
row.prop(window_manager.session_settings, "username", text="id")
|
||||
|
||||
row = box.row()
|
||||
row.prop(scene.session_settings, "client_color", text="color")
|
||||
row.prop(window_manager.session_settings, "client_color", text="color")
|
||||
row = box.row()
|
||||
|
||||
row = layout.row()
|
||||
@ -51,13 +51,13 @@ class SessionSettingsPanel(bpy.types.Panel):
|
||||
|
||||
|
||||
row = box.row()
|
||||
row.prop(scene.session_settings, "session_mode", expand=True)
|
||||
row.prop(net_settings, "session_mode", expand=True)
|
||||
row = box.row()
|
||||
|
||||
|
||||
|
||||
|
||||
if scene.session_settings.session_mode == 'HOST':
|
||||
if window_manager.session_settings.session_mode == 'HOST':
|
||||
box = row.box()
|
||||
row = box.row()
|
||||
row.label(text="init scene:")
|
||||
@ -70,7 +70,7 @@ class SessionSettingsPanel(bpy.types.Panel):
|
||||
row.prop(net_settings, "ip", text="ip")
|
||||
row = box.row()
|
||||
row.label(text="port:")
|
||||
row.prop(scene.session_settings, "port", text="")
|
||||
row.prop(window_manager.session_settings, "port", text="")
|
||||
row = box.row()
|
||||
row.label(text="load data:")
|
||||
row.prop(net_settings, "load_data", text="")
|
||||
@ -126,8 +126,8 @@ class SessionUsersPanel(bpy.types.Panel):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
net_settings = context.scene.session_settings
|
||||
scene = context.scene
|
||||
net_settings = context.window_manager.session_settings
|
||||
scene = context.window_manager
|
||||
# Create a simple row.
|
||||
row = layout.row()
|
||||
if operators.client_keys and len(operators.client_keys) > 0:
|
||||
@ -171,9 +171,9 @@ class SessionPropertiesPanel(bpy.types.Panel):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
if hasattr(context.scene,'session_settings'):
|
||||
net_settings = context.scene.session_settings
|
||||
scene = context.scene
|
||||
if hasattr(context.window_manager,'session_settings'):
|
||||
net_settings = context.window_manager.session_settings
|
||||
scene = context.window_manager
|
||||
# Create a simple row.
|
||||
row = layout.row()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user