feat: differential ground work

This commit is contained in:
Swann 2019-10-08 18:45:46 +02:00
parent 688b57578c
commit e047874dbd
7 changed files with 46 additions and 42 deletions

View File

@ -42,7 +42,7 @@ class BlCollection(BlDatablock):
assert(pointer)
dumper = utils.dump_anything.Dumper()
dumper.depth = 4
dumper.depth = 2
dumper.include_filter = ['name','objects', 'children', 'uuid']
return dumper.dump(pointer)

View File

@ -1,5 +1,6 @@
import bpy
import mathutils
import jsondiff
from .. import utils
from .. import presence
@ -17,10 +18,14 @@ class BlUser(BlDatablock):
utils.dump_anything.load(target, data)
def apply(self):
# super().apply()
# self.data = jsondiff.patch(self.data, self.modifications, marshal=True)
# self.modifications = None
if self.pointer:
self.load(data=self.data, target=self.pointer)
settings = bpy.context.window_manager.session
# settings = bpy.context.window_manager.session
presence.refresh_3d_view()
@ -39,17 +44,17 @@ class BlUser(BlDatablock):
def update(self):
self.pointer.is_dirty = True
def diff(self):
if not self.pointer:
return False
if self.pointer.is_dirty:
self.pointer.is_dirty = False
return True
# def diff(self):
# if not self.pointer:
# return False
# if self.pointer.is_dirty:
# self.pointer.is_dirty = False
# return True
for i,coord in enumerate(self.pointer.location):
if coord != self.data['location'][i]:
return True
return False
# for i,coord in enumerate(self.pointer.location):
# if coord != self.data['location'][i]:
# return True
# return False
def is_valid(self):
return True

View File

@ -88,11 +88,6 @@ class BlWorld(BlDatablock):
assert(self.data)
self.pointer = bpy.data.worlds.get(self.data['name'])
def diff(self):
diff_rev = diff(self.dump(pointer=self.pointer), self.data)
return (self.bl_diff() or
len(diff_rev.keys()) > 0)
def resolve_dependencies(self):
deps = []

View File

@ -162,13 +162,13 @@ class DrawClient(Draw):
for cli in client_list:
cli_ref = repo.get(uuid=cli)
if settings.presence_show_selected:
presence.renderer.draw_client_selection(
cli_ref.data['name'], cli_ref.data['color'], cli_ref.data['selected_objects'])
if settings.presence_show_user:
presence.renderer.draw_client_camera(
cli_ref.data['name'], cli_ref.data['location'], cli_ref.data['color'])
if cli_ref.data.get('name'):
if settings.presence_show_selected:
presence.renderer.draw_client_selection(
cli_ref.data['name'], cli_ref.data['color'], cli_ref.data['selected_objects'])
if settings.presence_show_user:
presence.renderer.draw_client_camera(
cli_ref.data['name'], cli_ref.data['location'], cli_ref.data['color'])
class ClientUpdate(Timer):

@ -1 +1 @@
Subproject commit bc6bda2c1d7a5d7852b4bb392c1d2d7fcbe38c4f
Subproject commit fb92463c13032222e847e83b8417de99d7fd37e0

View File

@ -114,11 +114,7 @@ class SessionStartOperator(bpy.types.Operator):
"A session is already hosted on this address")
return {"CANCELLED"}
if settings.init_scene and self.host:
init_supported_datablocks(supported_bl_types)
for node in client.list():
client.commit(node)
# Init user settings
usr = presence.User(
@ -128,9 +124,16 @@ class SessionStartOperator(bpy.types.Operator):
settings.client_color.b,
1),
)
settings.user_uuid = client.add(usr,owner=settings.username)
client.commit(settings.user_uuid)
if settings.init_scene and self.host:
# init_supported_datablocks(supported_bl_types)
client.add(bpy.context.scene)
for node in client.list():
client.commit(node)
delayables.append(delayable.ClientUpdate(
client_uuid=settings.user_uuid))
delayables.append(delayable.DrawClient())

View File

@ -197,22 +197,23 @@ class SESSION_PT_user(bpy.types.Panel):
detail_item_row = item_box.row(align=True)
username = client['name']
if client.get('name'):
username = client['name']
is_local_user = username == settings.username
is_local_user = username == settings.username
if is_local_user:
info = "(self)"
if is_local_user:
info = "(self)"
detail_item_row.label(
text="{} {}".format(username, info))
detail_item_row.label(
text="{} {}".format(username, info))
if not is_local_user:
detail_item_row.operator(
"session.snapview",
text="",
icon='VIEW_CAMERA').target_client = key
row = layout.row()
if not is_local_user:
detail_item_row.operator(
"session.snapview",
text="",
icon='VIEW_CAMERA').target_client = key
row = layout.row()
else:
row.label(text="Empty")