feat: temporary store applied update to ignore them.
This commit is contained in:
parent
ff1630f9cc
commit
bdfd89c085
@ -57,6 +57,7 @@ from replication.objects import Node
|
|||||||
from . import bl_types, environment, timers, ui, utils
|
from . import bl_types, environment, timers, ui, utils
|
||||||
from .presence import SessionStatusWidget, renderer, view3d_find
|
from .presence import SessionStatusWidget, renderer, view3d_find
|
||||||
from .timers import registry
|
from .timers import registry
|
||||||
|
from . import shared_data
|
||||||
|
|
||||||
background_execution_queue = Queue()
|
background_execution_queue = Queue()
|
||||||
deleyables = []
|
deleyables = []
|
||||||
@ -984,17 +985,20 @@ def depsgraph_evaluation(scene):
|
|||||||
dependency_updates = [u for u in blender_depsgraph.updates]
|
dependency_updates = [u for u in blender_depsgraph.updates]
|
||||||
settings = utils.get_preferences()
|
settings = utils.get_preferences()
|
||||||
|
|
||||||
|
distant_update = [getattr(u.id, 'uuid', None) for u in dependency_updates if getattr(u.id, 'uuid', None) in shared_data.session.applied_updates]
|
||||||
|
if distant_update:
|
||||||
|
for u in distant_update:
|
||||||
|
shared_data.session.applied_updates.remove(u)
|
||||||
|
logging.info(f"Ignoring distant update of {dependency_updates[0].id.name}")
|
||||||
|
return
|
||||||
|
|
||||||
update_external_dependencies()
|
update_external_dependencies()
|
||||||
|
|
||||||
is_internal = [u for u in dependency_updates if u.is_updated_geometry or u.is_updated_shading or u.is_updated_transform]
|
|
||||||
|
|
||||||
# NOTE: maybe we don't need to check each update but only the first
|
# NOTE: maybe we don't need to check each update but only the first
|
||||||
if not is_internal:
|
|
||||||
return
|
|
||||||
for update in reversed(dependency_updates):
|
for update in reversed(dependency_updates):
|
||||||
# Is the object tracked ?
|
update_uuid = getattr(update.id, 'uuid', None)
|
||||||
if update.id.uuid:
|
if update_uuid:
|
||||||
# Retrieve local version
|
logging.info(f"Updating {update.id.name}")
|
||||||
node = session.repository.graph.get(update.id.uuid)
|
node = session.repository.graph.get(update.id.uuid)
|
||||||
check_common = session.repository.rdp.get_implementation(update.id).bl_check_common
|
check_common = session.repository.rdp.get_implementation(update.id).bl_check_common
|
||||||
# Check our right on this update:
|
# Check our right on this update:
|
||||||
@ -1014,15 +1018,10 @@ def depsgraph_evaluation(scene):
|
|||||||
logging.error(e)
|
logging.error(e)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
# A new scene is created
|
|
||||||
elif isinstance(update.id, bpy.types.Scene):
|
elif isinstance(update.id, bpy.types.Scene):
|
||||||
ref = session.repository.get_node_by_datablock(update.id)
|
scn_uuid = porcelain.add(session.repository, update.id)
|
||||||
if ref:
|
porcelain.commit(session.repository, scn_uuid)
|
||||||
pass
|
porcelain.push(session.repository, 'origin', scn_uuid)
|
||||||
else:
|
|
||||||
scn_uuid = porcelain.add(session.repository, update.id)
|
|
||||||
porcelain.commit(session.node_id, scn_uuid)
|
|
||||||
porcelain.push(session.repository,'origin', scn_uuid)
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
|
|
||||||
|
48
multi_user/shared_data.py
Normal file
48
multi_user/shared_data.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# ##### END GPL LICENSE BLOCK #####
|
||||||
|
|
||||||
|
from replication.constants import STATE_INITIAL
|
||||||
|
|
||||||
|
|
||||||
|
class SessionData():
|
||||||
|
""" A structure to share easily the current session data across the addon
|
||||||
|
modules.
|
||||||
|
This object will completely replace the Singleton lying in replication
|
||||||
|
interface module.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.repository = None # The current repository
|
||||||
|
self.remote = None # The active remote
|
||||||
|
self.server = None
|
||||||
|
self.applied_updates = []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
if self.remote is None:
|
||||||
|
return STATE_INITIAL
|
||||||
|
else:
|
||||||
|
return self.remote.connection_status
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self.remote = None
|
||||||
|
self.repository = None
|
||||||
|
self.server = None
|
||||||
|
self.applied_updates = []
|
||||||
|
|
||||||
|
|
||||||
|
session = SessionData()
|
@ -31,6 +31,8 @@ from .presence import (UserFrustumWidget, UserNameWidget, UserSelectionWidget,
|
|||||||
generate_user_camera, get_view_matrix, refresh_3d_view,
|
generate_user_camera, get_view_matrix, refresh_3d_view,
|
||||||
refresh_sidebar_view, renderer)
|
refresh_sidebar_view, renderer)
|
||||||
|
|
||||||
|
from . import shared_data
|
||||||
|
|
||||||
this = sys.modules[__name__]
|
this = sys.modules[__name__]
|
||||||
|
|
||||||
# Registered timers
|
# Registered timers
|
||||||
@ -114,6 +116,7 @@ class ApplyTimer(Timer):
|
|||||||
|
|
||||||
if node_ref.state == FETCHED:
|
if node_ref.state == FETCHED:
|
||||||
try:
|
try:
|
||||||
|
shared_data.session.applied_updates.append(node)
|
||||||
porcelain.apply(session.repository, node)
|
porcelain.apply(session.repository, node)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Fail to apply {node_ref.uuid}")
|
logging.error(f"Fail to apply {node_ref.uuid}")
|
||||||
@ -251,6 +254,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
is_selectable = not session.repository.is_node_readonly(object_uuid)
|
is_selectable = not session.repository.is_node_readonly(object_uuid)
|
||||||
if obj.hide_select != is_selectable:
|
if obj.hide_select != is_selectable:
|
||||||
obj.hide_select = is_selectable
|
obj.hide_select = is_selectable
|
||||||
|
shared_data.session.applied_updates.append(object_uuid)
|
||||||
|
|
||||||
|
|
||||||
class ClientUpdate(Timer):
|
class ClientUpdate(Timer):
|
||||||
|
Loading…
Reference in New Issue
Block a user