feat: reparent ground work
This commit is contained in:
parent
34ed5da6f0
commit
ae71d7757e
@ -44,7 +44,7 @@ from . import environment, utils
|
||||
|
||||
|
||||
DEPENDENCIES = {
|
||||
("replication", '0.0.21a6'),
|
||||
("replication", '0.0.21a7'),
|
||||
}
|
||||
|
||||
|
||||
|
@ -134,6 +134,7 @@ class BlAction(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'ACTION_TWEAK'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -31,6 +31,7 @@ class BlArmature(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 0
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'ARMATURE_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -29,6 +29,7 @@ class BlCamera(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'CAMERA_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -79,7 +79,8 @@ class BlCollection(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
|
||||
bl_check_common = True
|
||||
|
||||
def _construct(self, data):
|
||||
if self.is_library:
|
||||
with bpy.data.libraries.load(filepath=bpy.data.libraries[self.data['library']].filepath, link=True) as (sourceData, targetData):
|
||||
|
@ -52,6 +52,7 @@ class BlCurve(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'CURVE_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
import bpy
|
||||
import mathutils
|
||||
import logging
|
||||
|
||||
from .. import utils
|
||||
from .dump_anything import Loader, Dumper
|
||||
@ -95,6 +96,7 @@ class BlDatablock(ReplicatedDatablock):
|
||||
bl_delay_apply : refresh rate in sec for apply
|
||||
bl_automatic_push : boolean
|
||||
bl_icon : type icon (blender icon name)
|
||||
bl_check_common: enable check even in common rights
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -122,6 +124,8 @@ class BlDatablock(ReplicatedDatablock):
|
||||
try:
|
||||
datablock_ref = datablock_root[self.data['name']]
|
||||
except Exception:
|
||||
name = self.data.get('name')
|
||||
logging.debug(f"Constructing {name}")
|
||||
datablock_ref = self._construct(data=self.data)
|
||||
|
||||
if datablock_ref:
|
||||
@ -129,6 +133,15 @@ class BlDatablock(ReplicatedDatablock):
|
||||
|
||||
self.instance = datablock_ref
|
||||
|
||||
def remove_instance(self):
|
||||
"""
|
||||
Remove instance from blender data
|
||||
"""
|
||||
assert(self.instance)
|
||||
|
||||
datablock_root = getattr(bpy.data, self.bl_id)
|
||||
datablock_root.remove(self.instance)
|
||||
|
||||
def _dump(self, instance=None):
|
||||
dumper = Dumper()
|
||||
data = {}
|
||||
@ -189,6 +202,7 @@ class BlDatablock(ReplicatedDatablock):
|
||||
if not self.is_library:
|
||||
dependencies.extend(self._resolve_deps_implementation())
|
||||
|
||||
logging.debug(f"{self.instance.name} dependencies: {dependencies}")
|
||||
return dependencies
|
||||
|
||||
def _resolve_deps_implementation(self):
|
||||
|
@ -218,6 +218,7 @@ class BlGpencil(BlDatablock):
|
||||
bl_delay_refresh = 2
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'GREASEPENCIL'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -54,6 +54,7 @@ class BlImage(BlDatablock):
|
||||
bl_delay_refresh = 0
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = False
|
||||
bl_check_common = False
|
||||
bl_icon = 'IMAGE_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -32,6 +32,7 @@ class BlLattice(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'LATTICE_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -29,6 +29,7 @@ class BlLibrary(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'LIBRARY_DATA_DIRECT'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -29,6 +29,7 @@ class BlLight(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'LIGHT_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -30,6 +30,7 @@ class BlLightprobe(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'LIGHTPROBE_GRID'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -163,6 +163,7 @@ class BlMaterial(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'MATERIAL_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -52,6 +52,7 @@ class BlMesh(BlDatablock):
|
||||
bl_delay_refresh = 2
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'MESH_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -68,6 +68,7 @@ class BlMetaball(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'META_BALL'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -24,6 +24,7 @@ from replication.exception import ContextError
|
||||
|
||||
from .bl_datablock import BlDatablock
|
||||
from .dump_anything import Dumper, Loader
|
||||
from replication.exception import ReparentException
|
||||
|
||||
|
||||
def load_pose(target_bone, data):
|
||||
@ -45,6 +46,7 @@ class BlObject(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'OBJECT_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
@ -96,6 +98,9 @@ class BlObject(BlDatablock):
|
||||
|
||||
def _load_implementation(self, data, target):
|
||||
loader = Loader()
|
||||
|
||||
if target.type != data['type']:
|
||||
raise ReparentException()
|
||||
|
||||
# vertex groups
|
||||
if 'vertex_groups' in data:
|
||||
@ -202,6 +207,7 @@ class BlObject(BlDatablock):
|
||||
'lock_location',
|
||||
'lock_rotation',
|
||||
'lock_scale',
|
||||
'type',
|
||||
'rotation_quaternion' if instance.rotation_mode == 'QUATERNION' else 'rotation_euler',
|
||||
]
|
||||
|
||||
|
@ -30,6 +30,7 @@ class BlScene(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = True
|
||||
bl_icon = 'SCENE_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -29,6 +29,7 @@ class BlSpeaker(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = False
|
||||
bl_icon = 'SPEAKER'
|
||||
|
||||
def _load_implementation(self, data, target):
|
||||
|
@ -30,6 +30,7 @@ class BlWorld(BlDatablock):
|
||||
bl_delay_refresh = 1
|
||||
bl_delay_apply = 1
|
||||
bl_automatic_push = True
|
||||
bl_check_common = True
|
||||
bl_icon = 'WORLD_DATA'
|
||||
|
||||
def _construct(self, data):
|
||||
|
@ -21,13 +21,15 @@ import bpy
|
||||
|
||||
from . import operators, presence, utils
|
||||
from replication.constants import (FETCHED,
|
||||
RP_COMMON,
|
||||
STATE_INITIAL,
|
||||
STATE_QUITTING,
|
||||
STATE_ACTIVE,
|
||||
STATE_SYNCING,
|
||||
STATE_LOBBY,
|
||||
STATE_SRV_SYNC)
|
||||
UP,
|
||||
RP_COMMON,
|
||||
STATE_INITIAL,
|
||||
STATE_QUITTING,
|
||||
STATE_ACTIVE,
|
||||
STATE_SYNCING,
|
||||
STATE_LOBBY,
|
||||
STATE_SRV_SYNC,
|
||||
REPARENT)
|
||||
|
||||
|
||||
class Delayable():
|
||||
@ -85,8 +87,8 @@ class ApplyTimer(Timer):
|
||||
super().__init__(timout)
|
||||
|
||||
def execute(self):
|
||||
client = operators.client
|
||||
if client and client.state['STATE'] == STATE_ACTIVE:
|
||||
client = operators.client
|
||||
if client and client.state['STATE'] == STATE_ACTIVE:
|
||||
if self._type:
|
||||
nodes = client.list(filter=self._type)
|
||||
else:
|
||||
@ -100,6 +102,16 @@ class ApplyTimer(Timer):
|
||||
client.apply(node, force=True)
|
||||
except Exception as e:
|
||||
logging.error(f"Fail to apply {node_ref.uuid}: {e}")
|
||||
elif node_ref.state == REPARENT:
|
||||
# Reload the node
|
||||
node_ref.remove_instance()
|
||||
node_ref.resolve()
|
||||
client.apply(node, force=True)
|
||||
for parent in client._graph.find_parents(node):
|
||||
logging.info(f"Applying parent {parent}")
|
||||
client.apply(parent, force=True)
|
||||
node_ref.state = UP
|
||||
|
||||
|
||||
class DynamicRightSelectTimer(Timer):
|
||||
def __init__(self, timout=.1):
|
||||
@ -253,14 +265,16 @@ class ClientUpdate(Timer):
|
||||
|
||||
if session and renderer:
|
||||
if session.state['STATE'] in [STATE_ACTIVE, STATE_LOBBY]:
|
||||
local_user = operators.client.online_users.get(settings.username)
|
||||
local_user = operators.client.online_users.get(
|
||||
settings.username)
|
||||
|
||||
if not local_user:
|
||||
return
|
||||
else:
|
||||
for username, user_data in operators.client.online_users.items():
|
||||
if username != settings.username:
|
||||
cached_user_data = self.users_metadata.get(username)
|
||||
cached_user_data = self.users_metadata.get(
|
||||
username)
|
||||
new_user_data = operators.client.online_users[username]['metadata']
|
||||
|
||||
if cached_user_data is None:
|
||||
@ -274,7 +288,7 @@ class ClientUpdate(Timer):
|
||||
|
||||
local_user_metadata = local_user.get('metadata')
|
||||
scene_current = bpy.context.scene.name
|
||||
local_user = session.online_users.get(settings.username)
|
||||
local_user = session.online_users.get(settings.username)
|
||||
current_view_corners = presence.get_view_corners()
|
||||
|
||||
# Init client metadata
|
||||
@ -283,9 +297,9 @@ class ClientUpdate(Timer):
|
||||
'view_corners': presence.get_view_matrix(),
|
||||
'view_matrix': presence.get_view_matrix(),
|
||||
'color': (settings.client_color.r,
|
||||
settings.client_color.g,
|
||||
settings.client_color.b,
|
||||
1),
|
||||
settings.client_color.g,
|
||||
settings.client_color.b,
|
||||
1),
|
||||
'frame_current': bpy.context.scene.frame_current,
|
||||
'scene_current': scene_current
|
||||
}
|
||||
@ -298,9 +312,11 @@ class ClientUpdate(Timer):
|
||||
session.update_user_metadata(local_user_metadata)
|
||||
elif 'view_corners' in local_user_metadata and current_view_corners != local_user_metadata['view_corners']:
|
||||
local_user_metadata['view_corners'] = current_view_corners
|
||||
local_user_metadata['view_matrix'] = presence.get_view_matrix()
|
||||
local_user_metadata['view_matrix'] = presence.get_view_matrix(
|
||||
)
|
||||
session.update_user_metadata(local_user_metadata)
|
||||
|
||||
|
||||
class SessionStatusUpdate(Timer):
|
||||
def __init__(self, timout=1):
|
||||
super().__init__(timout)
|
||||
@ -308,6 +324,7 @@ class SessionStatusUpdate(Timer):
|
||||
def execute(self):
|
||||
presence.refresh_sidebar_view()
|
||||
|
||||
|
||||
class SessionUserSync(Timer):
|
||||
def __init__(self, timout=1):
|
||||
super().__init__(timout)
|
||||
@ -332,4 +349,4 @@ class SessionUserSync(Timer):
|
||||
if user not in ui_users:
|
||||
new_key = ui_users.add()
|
||||
new_key.name = user
|
||||
new_key.username = user
|
||||
new_key.username = user
|
||||
|
@ -111,7 +111,8 @@ class SessionStartOperator(bpy.types.Operator):
|
||||
type_module_class.bl_class,
|
||||
type_module_class,
|
||||
timer=type_local_config.bl_delay_refresh*1000,
|
||||
automatic=type_local_config.auto_push)
|
||||
automatic=type_local_config.auto_push,
|
||||
check_common=type_module_class.bl_check_common)
|
||||
|
||||
if settings.update_method == 'DEFAULT':
|
||||
if type_local_config.bl_delay_apply > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user