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