Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e02143c296 | |||
| 2a8498fe38 | |||
| 5b60a31fbb | |||
| 1e620b5f88 | |||
| 814b1d5044 | |||
| ab48357b4a | |||
| 38e4375689 | |||
| c3dcb9fc44 |
+1
-9
@@ -1,13 +1,5 @@
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
- deploy
|
||||
- doc
|
||||
|
||||
|
||||
|
||||
include:
|
||||
- local: .gitlab/ci/test.gitlab-ci.yml
|
||||
- local: .gitlab/ci/build.gitlab-ci.yml
|
||||
- local: .gitlab/ci/deploy.gitlab-ci.yml
|
||||
- local: .gitlab/ci/doc.gitlab-ci.yml
|
||||
- local: .gitlab/ci/build.gitlab-ci.yml
|
||||
@@ -1,6 +1,5 @@
|
||||
build:
|
||||
stage: build
|
||||
needs: ["test"]
|
||||
image: debian:stable-slim
|
||||
script:
|
||||
- rm -rf tests .git .gitignore script
|
||||
|
||||
@@ -245,8 +245,9 @@ def dump_node_tree(node_tree: bpy.types.ShaderNodeTree) -> dict:
|
||||
'type': type(node_tree).__name__
|
||||
}
|
||||
|
||||
sockets = [item for item in node_tree.interface.items_tree if item.item_type == 'SOCKET']
|
||||
node_tree_data['interface'] = dump_node_tree_sockets(sockets)
|
||||
for socket_id in ['inputs', 'outputs']:
|
||||
socket_collection = getattr(node_tree, socket_id)
|
||||
node_tree_data[socket_id] = dump_node_tree_sockets(socket_collection)
|
||||
|
||||
return node_tree_data
|
||||
|
||||
@@ -262,18 +263,18 @@ def dump_node_tree_sockets(sockets: bpy.types.Collection) -> dict:
|
||||
"""
|
||||
sockets_data = []
|
||||
for socket in sockets:
|
||||
sockets_data.append(
|
||||
(
|
||||
socket.name,
|
||||
socket.socket_type,
|
||||
socket.in_out
|
||||
)
|
||||
)
|
||||
try:
|
||||
socket_uuid = socket['uuid']
|
||||
except Exception:
|
||||
socket_uuid = str(uuid4())
|
||||
socket['uuid'] = socket_uuid
|
||||
|
||||
sockets_data.append((socket.name, socket.bl_socket_idname, socket_uuid))
|
||||
|
||||
return sockets_data
|
||||
|
||||
|
||||
def load_node_tree_sockets(interface: bpy.types.NodeTreeInterface,
|
||||
def load_node_tree_sockets(sockets: bpy.types.Collection,
|
||||
sockets_data: dict):
|
||||
""" load sockets of a shader_node_tree
|
||||
|
||||
@@ -284,17 +285,20 @@ def load_node_tree_sockets(interface: bpy.types.NodeTreeInterface,
|
||||
:arg socket_data: dumped socket data
|
||||
:type socket_data: dict
|
||||
"""
|
||||
# Remove old sockets
|
||||
interface.clear()
|
||||
# Check for removed sockets
|
||||
for socket in sockets:
|
||||
if not [s for s in sockets_data if 'uuid' in socket and socket['uuid'] == s[2]]:
|
||||
sockets.remove(socket)
|
||||
|
||||
# Check for new sockets
|
||||
for name, socket_type, in_out in sockets_data:
|
||||
socket = interface.new_socket(
|
||||
name,
|
||||
in_out=in_out,
|
||||
socket_type=socket_type
|
||||
)
|
||||
|
||||
for idx, socket_data in enumerate(sockets_data):
|
||||
try:
|
||||
checked_socket = sockets[idx]
|
||||
if checked_socket.name != socket_data[0]:
|
||||
checked_socket.name = socket_data[0]
|
||||
except Exception:
|
||||
s = sockets.new(socket_data[1], socket_data[0])
|
||||
s['uuid'] = socket_data[2]
|
||||
|
||||
|
||||
def load_node_tree(node_tree_data: dict, target_node_tree: bpy.types.ShaderNodeTree) -> dict:
|
||||
@@ -311,8 +315,13 @@ def load_node_tree(node_tree_data: dict, target_node_tree: bpy.types.ShaderNodeT
|
||||
if not target_node_tree.is_property_readonly('name'):
|
||||
target_node_tree.name = node_tree_data['name']
|
||||
|
||||
if 'interface' in node_tree_data:
|
||||
load_node_tree_sockets(target_node_tree.interface, node_tree_data['interface'])
|
||||
if 'inputs' in node_tree_data:
|
||||
socket_collection = getattr(target_node_tree, 'inputs')
|
||||
load_node_tree_sockets(socket_collection, node_tree_data['inputs'])
|
||||
|
||||
if 'outputs' in node_tree_data:
|
||||
socket_collection = getattr(target_node_tree, 'outputs')
|
||||
load_node_tree_sockets(socket_collection, node_tree_data['outputs'])
|
||||
|
||||
# Load nodes
|
||||
for node in node_tree_data["nodes"]:
|
||||
|
||||
@@ -37,8 +37,8 @@ VERTICE = ['co']
|
||||
|
||||
EDGE = [
|
||||
'vertices',
|
||||
# 'crease',
|
||||
# 'bevel_weight',
|
||||
'crease',
|
||||
'bevel_weight',
|
||||
'use_seam',
|
||||
'use_edge_sharp',
|
||||
]
|
||||
|
||||
@@ -26,8 +26,8 @@ import numpy as np
|
||||
BPY_TO_NUMPY_TYPES = {
|
||||
'FLOAT': np.float32,
|
||||
'INT': np.int32,
|
||||
'BOOL': bool,
|
||||
'BOOLEAN': bool}
|
||||
'BOOL': np.bool,
|
||||
'BOOLEAN': np.bool}
|
||||
|
||||
PRIMITIVE_TYPES = ['FLOAT', 'INT', 'BOOLEAN']
|
||||
|
||||
|
||||
+42
-18
@@ -30,12 +30,14 @@ VERSION_EXPR = re.compile('\d+.\d+.\d+')
|
||||
DEFAULT_CACHE_DIR = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "cache")
|
||||
REPLICATION_DEPENDENCIES = {
|
||||
"zmq",
|
||||
"deepdiff"
|
||||
("pyzmq", "25.0.0"),
|
||||
("deepdiff","5.7.0"),
|
||||
}
|
||||
LIBS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "libs")
|
||||
REPLICATION = os.path.join(LIBS,"replication")
|
||||
|
||||
PYTHON_PATH = None
|
||||
SUBPROCESS_DIR = None
|
||||
|
||||
rtypes = []
|
||||
|
||||
@@ -48,13 +50,13 @@ def module_can_be_imported(name: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def install_pip(python_path):
|
||||
def install_pip():
|
||||
# pip can not necessarily be imported into Blender after this
|
||||
subprocess.run([str(python_path), "-m", "ensurepip"])
|
||||
subprocess.run([str(PYTHON_PATH), "-m", "ensurepip"])
|
||||
|
||||
|
||||
def install_requirements(python_path:str, module_requirement: str, install_dir: str):
|
||||
logging.info(f"Installing {module_requirement} dependencies in {install_dir}")
|
||||
def install_package(name: str, version:str=None, install_dir: str=None):
|
||||
logging.info(f"installing {name} version...")
|
||||
env = os.environ
|
||||
if "PIP_REQUIRE_VIRTUALENV" in env:
|
||||
# PIP_REQUIRE_VIRTUALENV is an env var to ensure pip cannot install packages outside a virtual env
|
||||
@@ -63,7 +65,24 @@ def install_requirements(python_path:str, module_requirement: str, install_dir:
|
||||
# env var for the subprocess.
|
||||
env = os.environ.copy()
|
||||
del env["PIP_REQUIRE_VIRTUALENV"]
|
||||
subprocess.run([str(python_path), "-m", "pip", "install", "-r", f"{install_dir}/{module_requirement}/requirements.txt", "-t", install_dir], env=env)
|
||||
module_name = f"{name}" if version is None else f"{name}=={version}"
|
||||
subprocess.run([str(PYTHON_PATH), "-m", "pip", "install", module_name, "-t", install_dir], env=env)
|
||||
|
||||
if name in sys.modules:
|
||||
del sys.modules[name]
|
||||
|
||||
|
||||
def check_package_version(name: str, required_version: str):
|
||||
logging.info(f"Checking {name} version...")
|
||||
out = subprocess.run([str(PYTHON_PATH), "-m", "pip", "show", name], capture_output=True)
|
||||
|
||||
version = VERSION_EXPR.search(out.stdout.decode())
|
||||
if version and version.group() == required_version:
|
||||
logging.info(f"{name} is up to date")
|
||||
return True
|
||||
else:
|
||||
logging.info(f"{name} need an update")
|
||||
return False
|
||||
|
||||
|
||||
def get_ip():
|
||||
@@ -99,7 +118,21 @@ def remove_paths(paths: list):
|
||||
if path in sys.path:
|
||||
logging.debug(f"Removing {path} dir from the path.")
|
||||
sys.path.remove(path)
|
||||
|
||||
|
||||
|
||||
def install_modules(dependencies: tuple, python_path: str, install_dir: str):
|
||||
global PYTHON_PATH, SUBPROCESS_DIR
|
||||
|
||||
PYTHON_PATH = Path(python_path)
|
||||
SUBPROCESS_DIR = PYTHON_PATH.parent
|
||||
|
||||
if not module_can_be_imported("pip"):
|
||||
install_pip()
|
||||
|
||||
for package_name, package_version in dependencies:
|
||||
if not module_can_be_imported(package_name):
|
||||
install_package(package_name, version=package_version, install_dir=install_dir)
|
||||
module_can_be_imported(package_name)
|
||||
|
||||
def register():
|
||||
if bpy.app.version >= (2,91,0):
|
||||
@@ -107,21 +140,12 @@ def register():
|
||||
else:
|
||||
python_binary_path = bpy.app.binary_path_python
|
||||
|
||||
python_path = Path(python_binary_path)
|
||||
|
||||
for module_name in list(sys.modules.keys()):
|
||||
if 'replication' in module_name:
|
||||
del sys.modules[module_name]
|
||||
|
||||
setup_paths([LIBS, REPLICATION])
|
||||
|
||||
if not module_can_be_imported("pip"):
|
||||
install_pip(python_path)
|
||||
|
||||
deps_not_installed = [package_name for package_name in REPLICATION_DEPENDENCIES if not module_can_be_imported(package_name)]
|
||||
if any(deps_not_installed):
|
||||
install_requirements(python_path, module_requirement='replication', install_dir=LIBS)
|
||||
|
||||
install_modules(REPLICATION_DEPENDENCIES, python_binary_path, install_dir=LIBS)
|
||||
|
||||
def unregister():
|
||||
remove_paths([REPLICATION, LIBS])
|
||||
@@ -133,7 +133,7 @@ def load_pre_handler(dummy):
|
||||
|
||||
@persistent
|
||||
def update_client_frame(scene):
|
||||
if session and session.state == STATE_ACTIVE:
|
||||
if session and session.state == STATE_ACTIVE and bpy.context.screen and not bpy.context.screen.is_animation_playing:
|
||||
porcelain.update_user_metadata(session.repository, {
|
||||
'frame_current': scene.frame_current
|
||||
})
|
||||
|
||||
Submodule multi_user/libs/replication updated: 3e9eb4f5c0...b60feead9d
@@ -297,17 +297,20 @@ def setup_timer():
|
||||
session_user_sync = timers.SessionUserSync()
|
||||
session_background_executor = timers.MainThreadExecutor(execution_queue=background_execution_queue)
|
||||
session_listen = timers.SessionListenTimer(timeout=0.001)
|
||||
session_frame_sync = timers.SessionFrameSync(timeout=1)
|
||||
|
||||
session_listen.register()
|
||||
session_update.register()
|
||||
session_user_sync.register()
|
||||
session_background_executor.register()
|
||||
session_frame_sync.register()
|
||||
|
||||
deleyables.append(session_background_executor)
|
||||
deleyables.append(session_update)
|
||||
deleyables.append(session_user_sync)
|
||||
deleyables.append(session_listen)
|
||||
deleyables.append(timers.AnnotationUpdates())
|
||||
deleyables.append(session_frame_sync)
|
||||
|
||||
def get_active_server_preset(context):
|
||||
active_index = context.window_manager.server_index
|
||||
|
||||
@@ -44,6 +44,27 @@ DEFAULT_PRESETS = {
|
||||
"admin_password": "admin",
|
||||
"server_password": ""
|
||||
},
|
||||
"NTHU Session 1" : {
|
||||
"server_name": "Session 1",
|
||||
"ip": "31.38.153.178",
|
||||
"port": 5555,
|
||||
"admin_password": "",
|
||||
"server_password": ""
|
||||
},
|
||||
"NTHU Session 2" : {
|
||||
"server_name": "Session 2",
|
||||
"ip": "31.38.153.178",
|
||||
"port": 5655,
|
||||
"admin_password": "",
|
||||
"server_password": ""
|
||||
},
|
||||
"NTHU Session 3" : {
|
||||
"server_name": "Session 3",
|
||||
"ip": "31.38.153.178",
|
||||
"port": 5755,
|
||||
"admin_password": "",
|
||||
"server_password": ""
|
||||
}
|
||||
}
|
||||
|
||||
def randomColor():
|
||||
|
||||
@@ -253,9 +253,11 @@ class Widget(object):
|
||||
return True
|
||||
|
||||
def configure_bgl(self):
|
||||
gpu.state.blend_set('ALPHA')
|
||||
gpu.state.depth_test_set('LESS_EQUAL')
|
||||
gpu.state.line_width_set(2.0)
|
||||
bgl.glLineWidth(2.)
|
||||
bgl.glEnable(bgl.GL_DEPTH_TEST)
|
||||
bgl.glEnable(bgl.GL_BLEND)
|
||||
bgl.glEnable(bgl.GL_LINE_SMOOTH)
|
||||
|
||||
|
||||
def draw(self):
|
||||
"""How to draw the widget
|
||||
@@ -298,7 +300,7 @@ class UserFrustumWidget(Widget):
|
||||
|
||||
def draw(self):
|
||||
location = self.data.get('view_corners')
|
||||
shader = gpu.shader.from_builtin('UNIFORM_COLOR')
|
||||
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||
positions = [tuple(coord) for coord in location]
|
||||
|
||||
if len(positions) != 7:
|
||||
@@ -370,7 +372,7 @@ class UserSelectionWidget(Widget):
|
||||
vertex_pos += bbox_pos
|
||||
vertex_ind += bbox_ind
|
||||
|
||||
shader = gpu.shader.from_builtin('UNIFORM_COLOR')
|
||||
shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
|
||||
batch = batch_for_shader(
|
||||
shader,
|
||||
'LINES',
|
||||
@@ -419,7 +421,7 @@ class UserNameWidget(Widget):
|
||||
|
||||
if coords:
|
||||
blf.position(0, coords[0], coords[1]+10, 0)
|
||||
blf.size(0, 16)
|
||||
blf.size(0, 16, 72)
|
||||
blf.color(0, color[0], color[1], color[2], color[3])
|
||||
blf.draw(0, self.username)
|
||||
|
||||
@@ -509,7 +511,7 @@ class SessionStatusWidget(Widget):
|
||||
vpos = (self.preferences.presence_hud_vpos*bpy.context.area.height)/100
|
||||
|
||||
blf.position(0, hpos, vpos, 0)
|
||||
blf.size(0, int(text_scale*ui_scale))
|
||||
blf.size(0, int(text_scale*ui_scale), 72)
|
||||
blf.color(0, color[0], color[1], color[2], color[3])
|
||||
blf.draw(0, state_str)
|
||||
|
||||
|
||||
+11
-1
@@ -177,6 +177,7 @@ class AnnotationUpdates(Timer):
|
||||
affect_dependencies=False)
|
||||
self._annotating = False
|
||||
|
||||
|
||||
class DynamicRightSelectTimer(Timer):
|
||||
def __init__(self, timeout=.1):
|
||||
super().__init__(timeout)
|
||||
@@ -266,7 +267,7 @@ class DynamicRightSelectTimer(Timer):
|
||||
|
||||
|
||||
class ClientUpdate(Timer):
|
||||
def __init__(self, timeout=.1):
|
||||
def __init__(self, timeout=1):
|
||||
super().__init__(timeout)
|
||||
self.handle_quit = False
|
||||
self.users_metadata = {}
|
||||
@@ -387,3 +388,12 @@ class MainThreadExecutor(Timer):
|
||||
function, kwargs = self.execution_queue.get()
|
||||
logging.debug(f"Executing {function.__name__}")
|
||||
function(**kwargs)
|
||||
|
||||
|
||||
class SessionFrameSync(Timer):
|
||||
def execute(self):
|
||||
if session and session.state == STATE_ACTIVE:
|
||||
if bpy.context.screen and bpy.context.screen.is_animation_playing:
|
||||
porcelain.update_user_metadata(session.repository, {
|
||||
'frame_current': bpy.context.scene.frame_current
|
||||
})
|
||||
Reference in New Issue
Block a user