2019-02-08 00:41:18 +08:00
|
|
|
bl_info = {
|
2019-07-01 21:39:01 +08:00
|
|
|
"name": "Multi-User",
|
2019-10-22 22:37:23 +08:00
|
|
|
"author": "Swann Martinez",
|
2020-02-28 06:15:31 +08:00
|
|
|
"version": (0, 0, 2),
|
|
|
|
"description": "Enable real-time collaborative workflow inside blender",
|
2019-05-21 22:53:55 +08:00
|
|
|
"blender": (2, 80, 0),
|
2020-02-28 06:15:31 +08:00
|
|
|
"location": "3D View > Sidebar > Multi-User tab",
|
2019-09-18 23:54:02 +08:00
|
|
|
"warning": "Unstable addon, use it at your own risks",
|
2020-02-28 06:15:31 +08:00
|
|
|
"category": "Collaboration",
|
|
|
|
"wiki_url": "https://multi-user.readthedocs.io/en/develop/index.html",
|
|
|
|
"tracker_url": "https://gitlab.com/slumber/multi-user/issues",
|
|
|
|
"support": "COMMUNITY"
|
2019-02-08 00:41:18 +08:00
|
|
|
}
|
|
|
|
|
2019-03-14 23:44:18 +08:00
|
|
|
|
2019-07-02 00:04:35 +08:00
|
|
|
import logging
|
2019-08-23 18:28:57 +08:00
|
|
|
import os
|
2019-07-01 21:39:01 +08:00
|
|
|
import random
|
|
|
|
import sys
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-07-01 21:39:01 +08:00
|
|
|
import bpy
|
2019-08-22 16:58:54 +08:00
|
|
|
from bpy.app.handlers import persistent
|
2019-07-01 21:39:01 +08:00
|
|
|
|
2020-02-29 00:34:30 +08:00
|
|
|
from . import environment, utils, presence, preferences
|
2019-09-24 20:42:59 +08:00
|
|
|
from .libs.replication.replication.constants import RP_COMMON
|
|
|
|
|
2019-08-23 18:28:57 +08:00
|
|
|
|
2019-09-18 23:54:02 +08:00
|
|
|
# TODO: remove dependency as soon as replication will be installed as a module
|
2019-07-01 21:39:01 +08:00
|
|
|
DEPENDENCIES = {
|
2019-08-27 05:14:30 +08:00
|
|
|
("zmq","zmq"),
|
2019-09-18 00:25:06 +08:00
|
|
|
("msgpack","msgpack"),
|
2019-08-27 06:50:38 +08:00
|
|
|
("yaml","pyyaml"),
|
|
|
|
("jsondiff","jsondiff")
|
2019-07-01 21:39:01 +08:00
|
|
|
}
|
2019-05-23 00:19:11 +08:00
|
|
|
|
2019-07-02 22:43:30 +08:00
|
|
|
|
2019-07-02 00:04:35 +08:00
|
|
|
logger = logging.getLogger(__name__)
|
2020-02-07 07:48:34 +08:00
|
|
|
logger.setLevel(logging.WARNING)
|
2019-05-15 20:52:45 +08:00
|
|
|
|
|
|
|
def client_list_callback(scene, context):
|
2019-08-14 21:57:07 +08:00
|
|
|
from . import operators
|
2019-05-22 23:17:09 +08:00
|
|
|
|
2019-09-24 20:42:59 +08:00
|
|
|
items = [(RP_COMMON, RP_COMMON, "")]
|
2019-05-15 20:52:45 +08:00
|
|
|
|
2020-03-02 18:09:45 +08:00
|
|
|
username = utils.get_preferences().username
|
2019-08-14 21:57:07 +08:00
|
|
|
cli = operators.client
|
|
|
|
if cli:
|
2020-01-22 21:33:34 +08:00
|
|
|
client_ids = cli.online_users.keys()
|
|
|
|
for id in client_ids:
|
|
|
|
name_desc = id
|
|
|
|
if id == username:
|
2019-07-11 21:45:56 +08:00
|
|
|
name_desc += " (self)"
|
2019-05-15 20:52:45 +08:00
|
|
|
|
2020-01-22 21:33:34 +08:00
|
|
|
items.append((id, name_desc, ""))
|
2019-05-15 20:52:45 +08:00
|
|
|
|
|
|
|
return items
|
|
|
|
|
2020-01-18 01:15:37 +08:00
|
|
|
class SessionUser(bpy.types.PropertyGroup):
|
|
|
|
"""Session User
|
|
|
|
|
|
|
|
Blender user information property
|
|
|
|
"""
|
|
|
|
username: bpy.props.StringProperty(name="username")
|
|
|
|
current_frame: bpy.props.IntProperty(name="current_frame")
|
|
|
|
|
|
|
|
|
2019-05-21 22:53:55 +08:00
|
|
|
class SessionProps(bpy.types.PropertyGroup):
|
2019-09-24 19:26:51 +08:00
|
|
|
is_admin: bpy.props.BoolProperty(
|
|
|
|
name="is_admin",
|
|
|
|
default=False
|
|
|
|
)
|
2019-05-16 00:37:14 +08:00
|
|
|
session_mode: bpy.props.EnumProperty(
|
2019-05-15 20:52:45 +08:00
|
|
|
name='session_mode',
|
|
|
|
description='session mode',
|
|
|
|
items={
|
|
|
|
('HOST', 'hosting', 'host a session'),
|
|
|
|
('CONNECT', 'connexion', 'connect to a session')},
|
|
|
|
default='HOST')
|
2019-05-16 00:37:14 +08:00
|
|
|
clients: bpy.props.EnumProperty(
|
2019-05-15 20:52:45 +08:00
|
|
|
name="clients",
|
|
|
|
description="client enum",
|
2019-08-09 16:58:47 +08:00
|
|
|
items=client_list_callback)
|
2019-07-02 00:04:35 +08:00
|
|
|
enable_presence: bpy.props.BoolProperty(
|
2019-09-19 19:02:39 +08:00
|
|
|
name="Presence overlay",
|
2019-05-15 20:52:45 +08:00
|
|
|
description='Enable overlay drawing module',
|
2019-09-24 20:42:59 +08:00
|
|
|
default=True,
|
|
|
|
update=presence.update_presence
|
|
|
|
)
|
|
|
|
presence_show_selected: bpy.props.BoolProperty(
|
|
|
|
name="Show selected objects",
|
|
|
|
description='Enable selection overlay ',
|
|
|
|
default=True,
|
|
|
|
update=presence.update_overlay_settings
|
2019-09-25 00:37:36 +08:00
|
|
|
)
|
2019-09-24 20:42:59 +08:00
|
|
|
presence_show_user: bpy.props.BoolProperty(
|
|
|
|
name="Show users",
|
|
|
|
description='Enable user overlay ',
|
|
|
|
default=True,
|
|
|
|
update=presence.update_overlay_settings
|
2019-07-02 00:04:35 +08:00
|
|
|
)
|
2020-03-06 00:20:04 +08:00
|
|
|
presence_show_far_user: bpy.props.BoolProperty(
|
|
|
|
name="Show different scenes",
|
|
|
|
description="Show user on different scenes",
|
|
|
|
default=False,
|
|
|
|
update=presence.update_overlay_settings
|
|
|
|
)
|
2019-09-19 05:10:36 +08:00
|
|
|
filter_owned: bpy.props.BoolProperty(
|
|
|
|
name="filter_owned",
|
|
|
|
description='Show only owned datablocks',
|
|
|
|
default=True
|
|
|
|
)
|
2020-01-22 23:17:48 +08:00
|
|
|
user_snap_running: bpy.props.BoolProperty(
|
|
|
|
default=False
|
|
|
|
)
|
|
|
|
time_snap_running: bpy.props.BoolProperty(
|
|
|
|
default=False
|
|
|
|
)
|
2019-07-02 00:04:35 +08:00
|
|
|
|
2019-07-02 22:43:30 +08:00
|
|
|
classes = (
|
2020-01-18 01:15:37 +08:00
|
|
|
SessionUser,
|
2019-08-08 21:35:43 +08:00
|
|
|
SessionProps,
|
2019-07-02 22:43:30 +08:00
|
|
|
)
|
2019-05-15 20:52:45 +08:00
|
|
|
|
2020-02-04 02:04:08 +08:00
|
|
|
libs = os.path.dirname(os.path.abspath(__file__))+"\\libs\\replication\\replication"
|
2019-05-21 22:53:55 +08:00
|
|
|
|
2019-05-23 22:49:32 +08:00
|
|
|
def register():
|
2019-08-05 22:48:46 +08:00
|
|
|
if libs not in sys.path:
|
|
|
|
sys.path.append(libs)
|
|
|
|
|
2019-07-02 00:04:35 +08:00
|
|
|
environment.setup(DEPENDENCIES,bpy.app.binary_path_python)
|
2019-05-16 00:37:14 +08:00
|
|
|
|
2019-09-27 20:50:00 +08:00
|
|
|
from . import presence
|
2019-05-16 00:37:14 +08:00
|
|
|
from . import operators
|
|
|
|
from . import ui
|
2020-02-29 00:34:30 +08:00
|
|
|
from . import preferences
|
2019-05-16 00:37:14 +08:00
|
|
|
|
2019-05-15 20:52:45 +08:00
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.register_class(cls)
|
|
|
|
|
|
|
|
bpy.types.WindowManager.session = bpy.props.PointerProperty(
|
2019-05-21 22:53:55 +08:00
|
|
|
type=SessionProps)
|
2019-08-09 00:12:13 +08:00
|
|
|
bpy.types.ID.uuid = bpy.props.StringProperty(default="")
|
2020-01-18 01:15:37 +08:00
|
|
|
bpy.types.WindowManager.online_users = bpy.props.CollectionProperty(
|
|
|
|
type=SessionUser
|
|
|
|
)
|
|
|
|
bpy.types.WindowManager.user_index = bpy.props.IntProperty()
|
2019-09-24 19:26:51 +08:00
|
|
|
|
2020-02-29 00:34:30 +08:00
|
|
|
preferences.register()
|
2019-09-27 20:50:00 +08:00
|
|
|
presence.register()
|
2019-04-10 23:01:21 +08:00
|
|
|
operators.register()
|
|
|
|
ui.register()
|
2019-02-08 00:41:18 +08:00
|
|
|
|
|
|
|
def unregister():
|
2019-09-27 20:50:00 +08:00
|
|
|
from . import presence
|
2019-05-16 00:37:14 +08:00
|
|
|
from . import operators
|
|
|
|
from . import ui
|
2020-02-29 00:34:30 +08:00
|
|
|
from . import preferences
|
2019-05-21 22:53:55 +08:00
|
|
|
|
2019-09-27 20:50:00 +08:00
|
|
|
presence.unregister()
|
2019-04-10 23:01:21 +08:00
|
|
|
ui.unregister()
|
|
|
|
operators.unregister()
|
2020-02-29 00:34:30 +08:00
|
|
|
preferences.unregister()
|
2019-05-15 20:52:45 +08:00
|
|
|
del bpy.types.WindowManager.session
|
|
|
|
|
2019-07-02 22:43:30 +08:00
|
|
|
for cls in reversed(classes):
|
2019-05-15 20:52:45 +08:00
|
|
|
bpy.utils.unregister_class(cls)
|