Compare commits
15 Commits
235-show-c
...
242-replay
Author | SHA1 | Date | |
---|---|---|---|
48eded1a9b | |||
3fbe769928 | |||
fe998214be | |||
3a4f691b8f | |||
0e20d35e7d | |||
8d15e69b50 | |||
8000ce9931 | |||
b96f600f15 | |||
de32bd89e3 | |||
50e86aea15 | |||
c05a12343c | |||
a09193fba2 | |||
60e21f2b8e | |||
421f00879f | |||
964e6a8c63 |
@ -130,14 +130,29 @@ def load_pre_handler(dummy):
|
|||||||
if session and session.state in [STATE_ACTIVE, STATE_SYNCING]:
|
if session and session.state in [STATE_ACTIVE, STATE_SYNCING]:
|
||||||
bpy.ops.session.stop()
|
bpy.ops.session.stop()
|
||||||
|
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def update_client_frame(scene):
|
def update_client_frame(scene):
|
||||||
|
setting = bpy.context.window_manager.session
|
||||||
|
if setting.replay_mode == 'TIMELINE' and \
|
||||||
|
setting.replay_files and \
|
||||||
|
scene.active_replay_file != setting.replay_frame_current :
|
||||||
|
index = bpy.context.scene.active_replay_file
|
||||||
|
bpy.ops.session.load(filepath=bpy.context.window_manager.session.replay_files[index].name,
|
||||||
|
draw_users=True,
|
||||||
|
replay=True)
|
||||||
|
setting.replay_frame_current = index
|
||||||
|
|
||||||
if session and session.state == STATE_ACTIVE:
|
if session and session.state == STATE_ACTIVE:
|
||||||
porcelain.update_user_metadata(session.repository, {
|
porcelain.update_user_metadata(session.repository, {
|
||||||
'frame_current': scene.frame_current
|
'frame_current': scene.frame_current
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@persistent
|
||||||
|
def post_frame_update(scene):
|
||||||
|
if bpy.context.window_manager.session.replay_mode == 'TIMELINE' and \
|
||||||
|
not bpy.context.scene.animation_data:
|
||||||
|
bpy.context.scene.animation_data_create()
|
||||||
|
bpy.context.scene.animation_data.action = bpy.data.actions.get('replay_action')
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.app.handlers.undo_post.append(resolve_deps_graph)
|
bpy.app.handlers.undo_post.append(resolve_deps_graph)
|
||||||
|
@ -35,8 +35,10 @@ from operator import itemgetter
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from time import gmtime, strftime
|
from time import gmtime, strftime
|
||||||
|
from numpy import interp
|
||||||
|
|
||||||
from bpy.props import FloatProperty
|
from bpy.props import FloatProperty
|
||||||
|
import bmesh
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import _pickle as pickle
|
import _pickle as pickle
|
||||||
@ -58,13 +60,164 @@ from replication.repository import Repository
|
|||||||
|
|
||||||
from . import bl_types, environment, shared_data, timers, ui, utils
|
from . import bl_types, environment, shared_data, timers, ui, utils
|
||||||
from .handlers import on_scene_update, sanitize_deps_graph
|
from .handlers import on_scene_update, sanitize_deps_graph
|
||||||
from .presence import SessionStatusWidget, renderer, view3d_find, refresh_sidebar_view
|
from .presence import SessionStatusWidget, renderer, view3d_find, refresh_sidebar_view, bbox_from_obj
|
||||||
from .timers import registry
|
from .timers import registry
|
||||||
|
|
||||||
background_execution_queue = Queue()
|
background_execution_queue = Queue()
|
||||||
deleyables = []
|
deleyables = []
|
||||||
stop_modal_executor = False
|
stop_modal_executor = False
|
||||||
|
|
||||||
|
|
||||||
|
CLEARED_DATABLOCKS = ['actions', 'armatures', 'cache_files', 'cameras',
|
||||||
|
'collections', 'curves', 'fonts',
|
||||||
|
'grease_pencils', 'images', 'lattices', 'libraries',
|
||||||
|
'lightprobes', 'lights', 'linestyles', 'masks',
|
||||||
|
'materials', 'meshes', 'metaballs', 'movieclips',
|
||||||
|
'node_groups', 'objects', 'paint_curves', 'particles',
|
||||||
|
'scenes', 'shape_keys', 'sounds', 'speakers', 'texts',
|
||||||
|
'textures', 'volumes', 'worlds']
|
||||||
|
|
||||||
|
PERSISTENT_DATABLOCKS = ['LineStyle', 'Dots Stroke', 'replay_action']
|
||||||
|
|
||||||
|
def clean_scene(ignored_datablocks: list = None):
|
||||||
|
"""
|
||||||
|
Delete all datablock of the scene except PERSISTENT_DATABLOCKS and ignored
|
||||||
|
ones in ignored_datablocks.
|
||||||
|
"""
|
||||||
|
PERSISTENT_DATABLOCKS.extend(ignored_datablocks)
|
||||||
|
# Avoid to trigger a runtime error by keeping the last scene
|
||||||
|
PERSISTENT_DATABLOCKS.append(bpy.data.scenes[0].name)
|
||||||
|
|
||||||
|
for type_name in CLEARED_DATABLOCKS:
|
||||||
|
type_collection = getattr(bpy.data, type_name)
|
||||||
|
for datablock in type_collection:
|
||||||
|
if datablock.name in PERSISTENT_DATABLOCKS:
|
||||||
|
logging.debug(f"Skipping {datablock.name}")
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
logging.debug(f"Removing {datablock.name}")
|
||||||
|
type_collection.remove(datablock)
|
||||||
|
|
||||||
|
# Clear sequencer
|
||||||
|
bpy.context.scene.sequence_editor_clear()
|
||||||
|
|
||||||
|
|
||||||
|
def draw_user(username, metadata, radius=0.01, intensity=10.0):
|
||||||
|
"""
|
||||||
|
Generate a mesh representation of a given user frustum and
|
||||||
|
sight of view.
|
||||||
|
"""
|
||||||
|
view_corners = metadata.get('view_corners')
|
||||||
|
color = metadata.get('color', (1,1,1,0))
|
||||||
|
objects = metadata.get('selected_objects', None)
|
||||||
|
scene = metadata.get('scene_current', bpy.context.scene.name)
|
||||||
|
|
||||||
|
user_collection = bpy.data.collections.new(username)
|
||||||
|
# User Color
|
||||||
|
user_mat = bpy.data.materials.new(username)
|
||||||
|
user_mat.use_nodes = True
|
||||||
|
nodes = user_mat.node_tree.nodes
|
||||||
|
nodes.remove(nodes['Principled BSDF'])
|
||||||
|
emission_node = nodes.new('ShaderNodeEmission')
|
||||||
|
emission_node.inputs['Color'].default_value = color
|
||||||
|
emission_node.inputs['Strength'].default_value = intensity
|
||||||
|
|
||||||
|
output_node = nodes['Material Output']
|
||||||
|
user_mat.node_tree.links.new(
|
||||||
|
emission_node.outputs['Emission'], output_node.inputs['Surface'])
|
||||||
|
|
||||||
|
# Generate camera mesh
|
||||||
|
camera_vertices = view_corners[:4]
|
||||||
|
camera_vertices.append(view_corners[6])
|
||||||
|
camera_mesh = bpy.data.meshes.new(f"{username}_camera")
|
||||||
|
camera_obj = bpy.data.objects.new(f"{username}_camera", camera_mesh)
|
||||||
|
frustum_bm = bmesh.new()
|
||||||
|
frustum_bm.from_mesh(camera_mesh)
|
||||||
|
|
||||||
|
for p in camera_vertices:
|
||||||
|
frustum_bm.verts.new(p)
|
||||||
|
frustum_bm.verts.ensure_lookup_table()
|
||||||
|
|
||||||
|
frustum_bm.edges.new((frustum_bm.verts[0], frustum_bm.verts[2]))
|
||||||
|
frustum_bm.edges.new((frustum_bm.verts[2], frustum_bm.verts[1]))
|
||||||
|
frustum_bm.edges.new((frustum_bm.verts[1], frustum_bm.verts[3]))
|
||||||
|
frustum_bm.edges.new((frustum_bm.verts[3], frustum_bm.verts[0]))
|
||||||
|
|
||||||
|
frustum_bm.edges.new((frustum_bm.verts[0], frustum_bm.verts[4]))
|
||||||
|
frustum_bm.edges.new((frustum_bm.verts[2], frustum_bm.verts[4]))
|
||||||
|
frustum_bm.edges.new((frustum_bm.verts[1], frustum_bm.verts[4]))
|
||||||
|
frustum_bm.edges.new((frustum_bm.verts[3], frustum_bm.verts[4]))
|
||||||
|
frustum_bm.edges.ensure_lookup_table()
|
||||||
|
|
||||||
|
frustum_bm.to_mesh(camera_mesh)
|
||||||
|
frustum_bm.free() # free and prevent further access
|
||||||
|
|
||||||
|
camera_obj.modifiers.new("wireframe", "SKIN")
|
||||||
|
camera_obj.data.skin_vertices[0].data[0].use_root = True
|
||||||
|
for v in camera_obj.data.skin_vertices[0].data:
|
||||||
|
v.radius = [radius, radius]
|
||||||
|
|
||||||
|
camera_mesh.materials.append(user_mat)
|
||||||
|
user_collection.objects.link(camera_obj)
|
||||||
|
|
||||||
|
# Generate sight mesh
|
||||||
|
sight_mesh = bpy.data.meshes.new(f"{username}_sight")
|
||||||
|
sight_obj = bpy.data.objects.new(f"{username}_sight", sight_mesh)
|
||||||
|
sight_verts = view_corners[4:6]
|
||||||
|
sight_bm = bmesh.new()
|
||||||
|
sight_bm.from_mesh(sight_mesh)
|
||||||
|
|
||||||
|
for p in sight_verts:
|
||||||
|
sight_bm.verts.new(p)
|
||||||
|
sight_bm.verts.ensure_lookup_table()
|
||||||
|
|
||||||
|
sight_bm.edges.new((sight_bm.verts[0], sight_bm.verts[1]))
|
||||||
|
sight_bm.edges.ensure_lookup_table()
|
||||||
|
sight_bm.to_mesh(sight_mesh)
|
||||||
|
sight_bm.free()
|
||||||
|
|
||||||
|
sight_obj.modifiers.new("wireframe", "SKIN")
|
||||||
|
sight_obj.data.skin_vertices[0].data[0].use_root = True
|
||||||
|
for v in sight_mesh.skin_vertices[0].data:
|
||||||
|
v.radius = [radius, radius]
|
||||||
|
|
||||||
|
sight_mesh.materials.append(user_mat)
|
||||||
|
user_collection.objects.link(sight_obj)
|
||||||
|
|
||||||
|
# Draw selected objects
|
||||||
|
if objects:
|
||||||
|
for o in list(objects):
|
||||||
|
instance = bl_types.bl_datablock.get_datablock_from_uuid(o, None)
|
||||||
|
if instance:
|
||||||
|
bbox_mesh = bpy.data.meshes.new(f"{instance.name}_bbox")
|
||||||
|
bbox_obj = bpy.data.objects.new(
|
||||||
|
f"{instance.name}_bbox", bbox_mesh)
|
||||||
|
bbox_verts, bbox_ind = bbox_from_obj(instance, index=0)
|
||||||
|
bbox_bm = bmesh.new()
|
||||||
|
bbox_bm.from_mesh(bbox_mesh)
|
||||||
|
|
||||||
|
for p in bbox_verts:
|
||||||
|
bbox_bm.verts.new(p)
|
||||||
|
bbox_bm.verts.ensure_lookup_table()
|
||||||
|
|
||||||
|
for e in bbox_ind:
|
||||||
|
bbox_bm.edges.new(
|
||||||
|
(bbox_bm.verts[e[0]], bbox_bm.verts[e[1]]))
|
||||||
|
|
||||||
|
bbox_bm.to_mesh(bbox_mesh)
|
||||||
|
bbox_bm.free()
|
||||||
|
bpy.data.collections[username].objects.link(bbox_obj)
|
||||||
|
|
||||||
|
bbox_obj.modifiers.new("wireframe", "SKIN")
|
||||||
|
bbox_obj.data.skin_vertices[0].data[0].use_root = True
|
||||||
|
for v in bbox_mesh.skin_vertices[0].data:
|
||||||
|
v.radius = [radius, radius]
|
||||||
|
|
||||||
|
bbox_mesh.materials.append(user_mat)
|
||||||
|
|
||||||
|
bpy.data.scenes[scene].collection.children.link(user_collection)
|
||||||
|
|
||||||
|
|
||||||
def session_callback(name):
|
def session_callback(name):
|
||||||
""" Session callback wrapper
|
""" Session callback wrapper
|
||||||
|
|
||||||
@ -249,7 +402,7 @@ class SessionConnectOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
# Join a session
|
# Join a session
|
||||||
if not active_server.use_admin_password:
|
if not active_server.use_admin_password:
|
||||||
utils.clean_scene()
|
clean_scene()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
porcelain.remote_add(
|
porcelain.remote_add(
|
||||||
@ -320,7 +473,7 @@ class SessionHostOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
# Host a session
|
# Host a session
|
||||||
if settings.init_method == 'EMPTY':
|
if settings.init_method == 'EMPTY':
|
||||||
utils.clean_scene()
|
clean_scene()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Init repository
|
# Init repository
|
||||||
@ -384,7 +537,7 @@ class SessionInitOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if self.init_method == 'EMPTY':
|
if self.init_method == 'EMPTY':
|
||||||
utils.clean_scene()
|
clean_scene()
|
||||||
|
|
||||||
for scene in bpy.data.scenes:
|
for scene in bpy.data.scenes:
|
||||||
porcelain.add(session.repository, scene)
|
porcelain.add(session.repository, scene)
|
||||||
@ -863,14 +1016,89 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper):
|
|||||||
maxlen=255, # Max internal buffer length, longer would be clamped.
|
maxlen=255, # Max internal buffer length, longer would be clamped.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
draw_users: bpy.props.BoolProperty(
|
||||||
|
name="Load users",
|
||||||
|
description="Draw users in the scene",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
replay: bpy.props.BoolProperty(
|
||||||
|
name="Replay mode",
|
||||||
|
description="Enable replay functions",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
user_skin_radius: bpy.props.FloatProperty(
|
||||||
|
name="Wireframe radius",
|
||||||
|
description="Wireframe radius",
|
||||||
|
default=0.01,
|
||||||
|
)
|
||||||
|
user_color_intensity: bpy.props.FloatProperty(
|
||||||
|
name="Shading intensity",
|
||||||
|
description="Shading intensity",
|
||||||
|
default=1.0,
|
||||||
|
)
|
||||||
|
|
||||||
|
files: bpy.props.CollectionProperty(
|
||||||
|
name='File paths',
|
||||||
|
type=bpy.types.OperatorFileListElement
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
pass
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
from replication.repository import Repository
|
from replication.repository import Repository
|
||||||
|
|
||||||
|
runtime_settings = context.window_manager.session
|
||||||
|
|
||||||
# init the factory with supported types
|
# init the factory with supported types
|
||||||
bpy_protocol = bl_types.get_data_translation_protocol()
|
bpy_protocol = bl_types.get_data_translation_protocol()
|
||||||
repo = Repository(bpy_protocol)
|
repo = Repository(bpy_protocol)
|
||||||
repo.loads(self.filepath)
|
|
||||||
utils.clean_scene()
|
try:
|
||||||
|
repo.loads(self.filepath)
|
||||||
|
except TypeError:
|
||||||
|
# Load legacy snapshots
|
||||||
|
db = pickle.load(gzip.open(self.filepath, "rb"))
|
||||||
|
|
||||||
|
nodes = db.get("nodes")
|
||||||
|
|
||||||
|
logging.info(f"Loading legacy {len(nodes)} node")
|
||||||
|
repo.object_store.clear()
|
||||||
|
for node, node_data in nodes:
|
||||||
|
instance = Node(
|
||||||
|
uuid=node,
|
||||||
|
data=node_data.get('data'),
|
||||||
|
owner=node_data.get('owner'),
|
||||||
|
dependencies=node_data.get('dependencies'),
|
||||||
|
state=FETCHED)
|
||||||
|
# Patch data for compatibility
|
||||||
|
type_id = node_data.get('str_type')[2:]
|
||||||
|
if type_id == "File":
|
||||||
|
type_id = "WindowsPath"
|
||||||
|
instance.data['type_id'] = type_id
|
||||||
|
repo.do_commit(instance)
|
||||||
|
instance.state = FETCHED
|
||||||
|
|
||||||
|
# Persitstent collection
|
||||||
|
ignored_datablocks = []
|
||||||
|
|
||||||
|
persistent_collection = bpy.data.collections.get("multiuser_timelapse")
|
||||||
|
if self.replay and \
|
||||||
|
runtime_settings.replay_persistent_collection and \
|
||||||
|
persistent_collection:
|
||||||
|
collection_repo = Repository(
|
||||||
|
rdp=bpy_protocol,
|
||||||
|
username="None")
|
||||||
|
porcelain.add(collection_repo, persistent_collection)
|
||||||
|
porcelain.commit(collection_repo, persistent_collection.uuid)
|
||||||
|
for node in collection_repo.graph.values():
|
||||||
|
ignored_datablocks.append(node.data.get('name'))
|
||||||
|
|
||||||
|
clean_scene(ignored_datablocks=ignored_datablocks)
|
||||||
|
|
||||||
nodes = [repo.graph.get(n) for n in repo.index_sorted]
|
nodes = [repo.graph.get(n) for n in repo.index_sorted]
|
||||||
|
|
||||||
@ -884,14 +1112,110 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper):
|
|||||||
# Step 2: Load nodes
|
# Step 2: Load nodes
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
porcelain.apply(repo, node.uuid)
|
porcelain.apply(repo, node.uuid)
|
||||||
|
|
||||||
|
if len(self.files) > 1:
|
||||||
|
runtime_settings.replay_files.clear()
|
||||||
|
context.scene.active_replay_file = len(self.files)-1
|
||||||
|
directory = Path(self.filepath).parent
|
||||||
|
file_list = [f['name'] for f in self.files]
|
||||||
|
file_list.sort()
|
||||||
|
for f in file_list:
|
||||||
|
snap = runtime_settings.replay_files.add()
|
||||||
|
snap.name = str(Path(directory, f))
|
||||||
|
print(f)
|
||||||
|
|
||||||
|
if runtime_settings.replay_mode == 'TIMELINE':
|
||||||
|
replay_action = bpy.data.actions.get('replay_action', bpy.data.actions.new('replay_action'))
|
||||||
|
|
||||||
|
bpy.context.scene.animation_data_create()
|
||||||
|
bpy.context.scene.animation_data.action = replay_action
|
||||||
|
if len(replay_action.fcurves) > 0 and replay_action.fcurves[0].data_path == 'active_replay_file':
|
||||||
|
replay_fcurve = replay_action.fcurves[0]
|
||||||
|
else:
|
||||||
|
replay_fcurve = replay_action.fcurves.new('active_replay_file')
|
||||||
|
|
||||||
|
for p in reversed(replay_fcurve.keyframe_points):
|
||||||
|
replay_fcurve.keyframe_points.remove(p, fast=True)
|
||||||
|
|
||||||
|
duration = runtime_settings.replay_duration
|
||||||
|
file_count = len(self.files)-1
|
||||||
|
for index in range(0, file_count):
|
||||||
|
frame = interp(index, [0, file_count], [bpy.context.scene.frame_start, duration])
|
||||||
|
replay_fcurve.keyframe_points.insert(frame, index)
|
||||||
|
|
||||||
|
|
||||||
|
if self.draw_users:
|
||||||
|
f = gzip.open(self.filepath, "rb")
|
||||||
|
db = pickle.load(f)
|
||||||
|
|
||||||
|
users = db.get("users")
|
||||||
|
|
||||||
|
for username, user_data in users.items():
|
||||||
|
metadata = user_data['metadata']
|
||||||
|
|
||||||
|
if metadata:
|
||||||
|
draw_user(username, metadata, radius=self.user_skin_radius, intensity=self.user_color_intensity)
|
||||||
|
|
||||||
|
# Relink the persistent collection
|
||||||
|
if self.replay and persistent_collection:
|
||||||
|
logging.info(f"Relinking {persistent_collection.name}")
|
||||||
|
bpy.context.scene.collection.children.link(persistent_collection)
|
||||||
|
|
||||||
|
# Reasign scene action
|
||||||
|
if self.replay and \
|
||||||
|
runtime_settings.replay_mode == 'TIMELINE' and \
|
||||||
|
not bpy.context.scene.animation_data :
|
||||||
|
bpy.context.scene.animation_data_create()
|
||||||
|
bpy.context.scene.animation_data.action = bpy.data.actions.get('replay_action')
|
||||||
|
bpy.context.scene.frame_end = runtime_settings.replay_duration
|
||||||
|
|
||||||
|
# Reasign the scene camera
|
||||||
|
if self.replay and \
|
||||||
|
runtime_settings.replay_persistent_collection and \
|
||||||
|
runtime_settings.replay_camera:
|
||||||
|
bpy.context.scene.camera = runtime_settings.replay_camera
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
class SESSION_PT_ImportUser(bpy.types.Panel):
|
||||||
|
bl_space_type = 'FILE_BROWSER'
|
||||||
|
bl_region_type = 'TOOL_PROPS'
|
||||||
|
bl_label = "Users"
|
||||||
|
bl_parent_id = "FILE_PT_operator"
|
||||||
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
return operator.bl_idname == "SESSION_OT_load"
|
||||||
|
|
||||||
|
def draw_header(self, context):
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
self.layout.prop(operator, "draw_users", text="")
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = False # No animation.
|
||||||
|
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
layout.enabled = operator.draw_users
|
||||||
|
|
||||||
|
layout.prop(operator, "user_skin_radius")
|
||||||
|
layout.prop(operator, "user_color_intensity")
|
||||||
|
|
||||||
class SessionPresetServerAdd(bpy.types.Operator):
|
class SessionPresetServerAdd(bpy.types.Operator):
|
||||||
"""Add a server to the server list preset"""
|
"""Add a server to the server list preset"""
|
||||||
bl_idname = "session.preset_server_add"
|
bl_idname = "session.preset_server_add"
|
||||||
@ -1106,6 +1430,26 @@ def menu_func_import(self, context):
|
|||||||
def menu_func_export(self, context):
|
def menu_func_export(self, context):
|
||||||
self.layout.operator(SessionSaveBackupOperator.bl_idname, text='Multi-user session snapshot (.db)')
|
self.layout.operator(SessionSaveBackupOperator.bl_idname, text='Multi-user session snapshot (.db)')
|
||||||
|
|
||||||
|
class SessionRenderReplay(bpy.types.Operator):
|
||||||
|
bl_idname = "session.render_replay"
|
||||||
|
bl_label = "Render Replay"
|
||||||
|
bl_description = "Render Replay"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return context.window_manager.session.replay_files
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
base_path = str(context.scene.render.filepath)
|
||||||
|
for frame in range(0,context.scene.frame_end):
|
||||||
|
logging.info(f"Rendering frame {frame} to {base_path}_{frame}.png")
|
||||||
|
context.scene.frame_current = frame
|
||||||
|
filename = Path(bpy.context.window_manager.session.replay_files[context.scene.active_replay_file].name)
|
||||||
|
context.scene.render.filepath = f"{base_path}{frame}_{filename.stem}"
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
|
||||||
|
context.scene.render.filepath = base_path
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
SessionConnectOperator,
|
SessionConnectOperator,
|
||||||
@ -1123,6 +1467,7 @@ classes = (
|
|||||||
SessionNotifyOperator,
|
SessionNotifyOperator,
|
||||||
SessionSaveBackupOperator,
|
SessionSaveBackupOperator,
|
||||||
SessionLoadSaveOperator,
|
SessionLoadSaveOperator,
|
||||||
|
SESSION_PT_ImportUser,
|
||||||
SessionStopAutoSaveOperator,
|
SessionStopAutoSaveOperator,
|
||||||
SessionPurgeOperator,
|
SessionPurgeOperator,
|
||||||
SessionPresetServerAdd,
|
SessionPresetServerAdd,
|
||||||
@ -1131,6 +1476,7 @@ classes = (
|
|||||||
RefreshServerStatus,
|
RefreshServerStatus,
|
||||||
GetDoc,
|
GetDoc,
|
||||||
FirstLaunch,
|
FirstLaunch,
|
||||||
|
SessionRenderReplay,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import bpy
|
|||||||
import string
|
import string
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
from numpy import interp
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@ -99,6 +100,77 @@ def update_directory(self, context):
|
|||||||
def set_log_level(self, value):
|
def set_log_level(self, value):
|
||||||
logging.getLogger().setLevel(value)
|
logging.getLogger().setLevel(value)
|
||||||
|
|
||||||
|
def set_active_replay(self, value):
|
||||||
|
files_count = len(bpy.context.window_manager.session.replay_files)
|
||||||
|
|
||||||
|
if files_count == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
max_index = files_count-1
|
||||||
|
|
||||||
|
if value > max_index:
|
||||||
|
value = max_index
|
||||||
|
|
||||||
|
if hasattr(self, 'active_replay_file'):
|
||||||
|
self["active_replay_file"] = value
|
||||||
|
else:
|
||||||
|
self.active_replay_file = value
|
||||||
|
|
||||||
|
if bpy.context.window_manager.session.replay_mode == 'MANUAL':
|
||||||
|
bpy.ops.session.load(
|
||||||
|
filepath=bpy.context.window_manager.session.replay_files[value].name,
|
||||||
|
draw_users=True,
|
||||||
|
replay=True)
|
||||||
|
|
||||||
|
def get_active_replay(self):
|
||||||
|
return self.get('active_replay_file', 0)
|
||||||
|
|
||||||
|
|
||||||
|
def set_replay_persistent_collection(self, value):
|
||||||
|
if hasattr(self, 'replay_persistent_collection'):
|
||||||
|
self["replay_persistent_collection"] = value
|
||||||
|
else:
|
||||||
|
self.replay_persistent_collection = value
|
||||||
|
|
||||||
|
collection = bpy.data.collections.get("multiuser_timelapse", None)
|
||||||
|
|
||||||
|
if collection is None and value:
|
||||||
|
collection = bpy.data.collections.new('multiuser_timelapse')
|
||||||
|
bpy.context.scene.collection.children.link(collection)
|
||||||
|
elif collection and not value:
|
||||||
|
for o in collection.objects:
|
||||||
|
bpy.data.objects.remove(o)
|
||||||
|
bpy.data.collections.remove(collection)
|
||||||
|
|
||||||
|
def get_replay_persistent_collection(self):
|
||||||
|
return self.get('replay_persistent_collection', False)
|
||||||
|
|
||||||
|
def set_replay_duration(self, value):
|
||||||
|
if hasattr(self, 'replay_duration'):
|
||||||
|
self["replay_duration"] = value
|
||||||
|
else:
|
||||||
|
self.replay_duration = value
|
||||||
|
|
||||||
|
# Update the animation fcurve
|
||||||
|
replay_action = bpy.data.actions.get('replay_action')
|
||||||
|
replay_fcurve = None
|
||||||
|
|
||||||
|
for fcurve in replay_action.fcurves:
|
||||||
|
if fcurve.data_path == 'active_replay_file':
|
||||||
|
replay_fcurve = fcurve
|
||||||
|
|
||||||
|
if replay_fcurve:
|
||||||
|
for p in reversed(replay_fcurve.keyframe_points):
|
||||||
|
replay_fcurve.keyframe_points.remove(p, fast=True)
|
||||||
|
|
||||||
|
bpy.context.scene.frame_end = value
|
||||||
|
files_count = len(bpy.context.window_manager.session.replay_files)-1
|
||||||
|
for index in range(0, files_count):
|
||||||
|
frame = interp(index,[0, files_count],[bpy.context.scene.frame_start, value])
|
||||||
|
replay_fcurve.keyframe_points.insert(frame, index)
|
||||||
|
|
||||||
|
def get_replay_duration(self):
|
||||||
|
return self.get('replay_duration', 10)
|
||||||
|
|
||||||
def get_log_level(self):
|
def get_log_level(self):
|
||||||
return logging.getLogger().level
|
return logging.getLogger().level
|
||||||
@ -619,11 +691,6 @@ class SessionUser(bpy.types.PropertyGroup):
|
|||||||
"""
|
"""
|
||||||
username: bpy.props.StringProperty(name="username")
|
username: bpy.props.StringProperty(name="username")
|
||||||
current_frame: bpy.props.IntProperty(name="current_frame")
|
current_frame: bpy.props.IntProperty(name="current_frame")
|
||||||
color: bpy.props.FloatVectorProperty(name="color", subtype="COLOR",
|
|
||||||
min=0.0,
|
|
||||||
max=1.0,
|
|
||||||
size=4,
|
|
||||||
default=(1.0, 1.0, 1.0, 1.0))
|
|
||||||
|
|
||||||
|
|
||||||
class SessionProps(bpy.types.PropertyGroup):
|
class SessionProps(bpy.types.PropertyGroup):
|
||||||
@ -692,6 +759,37 @@ class SessionProps(bpy.types.PropertyGroup):
|
|||||||
is_host: bpy.props.BoolProperty(
|
is_host: bpy.props.BoolProperty(
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
replay_files: bpy.props.CollectionProperty(
|
||||||
|
name='File paths',
|
||||||
|
type=bpy.types.OperatorFileListElement
|
||||||
|
)
|
||||||
|
replay_persistent_collection: bpy.props.BoolProperty(
|
||||||
|
name="replay_persistent_collection",
|
||||||
|
description='Enable a collection that persist accross frames loading',
|
||||||
|
get=get_replay_persistent_collection,
|
||||||
|
set=set_replay_persistent_collection,
|
||||||
|
)
|
||||||
|
replay_mode: bpy.props.EnumProperty(
|
||||||
|
name='replay method',
|
||||||
|
description='Replay in keyframe (timeline) or manually',
|
||||||
|
items={
|
||||||
|
('TIMELINE', 'TIMELINE', 'Replay from the timeline.'),
|
||||||
|
('MANUAL', 'MANUAL', 'Replay manually, from the replay frame widget.')},
|
||||||
|
default='TIMELINE')
|
||||||
|
replay_duration: bpy.props.IntProperty(
|
||||||
|
name='replay interval',
|
||||||
|
default=250,
|
||||||
|
min=10,
|
||||||
|
set=set_replay_duration,
|
||||||
|
get=get_replay_duration,
|
||||||
|
)
|
||||||
|
replay_frame_current: bpy.props.IntProperty(
|
||||||
|
name='replay_frame_current',
|
||||||
|
)
|
||||||
|
replay_camera: bpy.props.PointerProperty(
|
||||||
|
name='Replay camera',
|
||||||
|
type=bpy.types.Object
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
@ -717,6 +815,16 @@ def register():
|
|||||||
|
|
||||||
# at launch server presets
|
# at launch server presets
|
||||||
prefs.generate_default_presets()
|
prefs.generate_default_presets()
|
||||||
|
|
||||||
|
bpy.types.Scene.active_replay_file = bpy.props.IntProperty(
|
||||||
|
name="active_replay_file",
|
||||||
|
default=0,
|
||||||
|
min=0,
|
||||||
|
description='Active snapshot',
|
||||||
|
set=set_active_replay,
|
||||||
|
get=get_active_replay,
|
||||||
|
options={'ANIMATABLE'}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -725,3 +833,5 @@ def unregister():
|
|||||||
|
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
unregister_class(cls)
|
unregister_class(cls)
|
||||||
|
|
||||||
|
del bpy.types.Scene.active_replay_file
|
||||||
|
165
multi_user/ui.py
165
multi_user/ui.py
@ -62,41 +62,7 @@ def printProgressBar(iteration, total, prefix='', suffix='', decimals=1, length=
|
|||||||
bar = fill * filledLength + fill_empty * (length - filledLength)
|
bar = fill * filledLength + fill_empty * (length - filledLength)
|
||||||
return f"{prefix} |{bar}| {iteration}/{total}{suffix}"
|
return f"{prefix} |{bar}| {iteration}/{total}{suffix}"
|
||||||
|
|
||||||
def get_mode_icon(mode_name: str) -> str:
|
|
||||||
""" given a mode name retrieve a built-in icon
|
|
||||||
"""
|
|
||||||
mode_icon = "NONE"
|
|
||||||
if mode_name == "OBJECT" :
|
|
||||||
mode_icon = "OBJECT_DATAMODE"
|
|
||||||
elif mode_name == "EDIT_MESH" :
|
|
||||||
mode_icon = "EDITMODE_HLT"
|
|
||||||
elif mode_name == 'EDIT_CURVE':
|
|
||||||
mode_icon = "CURVE_DATA"
|
|
||||||
elif mode_name == 'EDIT_SURFACE':
|
|
||||||
mode_icon = "SURFACE_DATA"
|
|
||||||
elif mode_name == 'EDIT_TEXT':
|
|
||||||
mode_icon = "FILE_FONT"
|
|
||||||
elif mode_name == 'EDIT_ARMATURE':
|
|
||||||
mode_icon = "ARMATURE_DATA"
|
|
||||||
elif mode_name == 'EDIT_METABALL':
|
|
||||||
mode_icon = "META_BALL"
|
|
||||||
elif mode_name == 'EDIT_LATTICE':
|
|
||||||
mode_icon = "LATTICE_DATA"
|
|
||||||
elif mode_name == 'POSE':
|
|
||||||
mode_icon = "POSE_HLT"
|
|
||||||
elif mode_name == 'SCULPT':
|
|
||||||
mode_icon = "SCULPTMODE_HLT"
|
|
||||||
elif mode_name == 'PAINT_WEIGHT':
|
|
||||||
mode_icon = "WPAINT_HLT"
|
|
||||||
elif mode_name == 'PAINT_VERTEX':
|
|
||||||
mode_icon = "VPAINT_HLT"
|
|
||||||
elif mode_name == 'PAINT_TEXTURE':
|
|
||||||
mode_icon = "TPAINT_HLT"
|
|
||||||
elif mode_name == 'PARTICLE':
|
|
||||||
mode_icon = "PARTICLES"
|
|
||||||
elif mode_name == 'PAINT_GPENCIL' or mode_name =='EDIT_GPENCIL' or mode_name =='SCULPT_GPENCIL' or mode_name =='WEIGHT_GPENCIL' or mode_name =='VERTEX_GPENCIL':
|
|
||||||
mode_icon = "GREASEPENCIL"
|
|
||||||
return mode_icon
|
|
||||||
class SESSION_PT_settings(bpy.types.Panel):
|
class SESSION_PT_settings(bpy.types.Panel):
|
||||||
"""Settings panel"""
|
"""Settings panel"""
|
||||||
bl_idname = "MULTIUSER_SETTINGS_PT_panel"
|
bl_idname = "MULTIUSER_SETTINGS_PT_panel"
|
||||||
@ -409,31 +375,18 @@ class SESSION_PT_user(bpy.types.Panel):
|
|||||||
online_users)-1 >= selected_user else 0
|
online_users)-1 >= selected_user else 0
|
||||||
|
|
||||||
#USER LIST
|
#USER LIST
|
||||||
col = layout.column(align=True)
|
row = layout.row()
|
||||||
row = col.row(align=True)
|
|
||||||
row = row.split(factor=0.35, align=True)
|
|
||||||
|
|
||||||
box = row.box()
|
box = row.box()
|
||||||
brow = box.row(align=True)
|
split = box.split(factor=0.35)
|
||||||
brow.label(text="user")
|
split.label(text="user")
|
||||||
|
split = split.split(factor=0.3)
|
||||||
|
split.label(text="mode")
|
||||||
|
split.label(text="frame")
|
||||||
|
split.label(text="location")
|
||||||
|
split.label(text="ping")
|
||||||
|
|
||||||
row = row.split(factor=0.25, align=True)
|
row = layout.row()
|
||||||
|
layout.template_list("SESSION_UL_users", "", context.window_manager,
|
||||||
box = row.box()
|
|
||||||
brow = box.row(align=True)
|
|
||||||
brow.label(text="mode")
|
|
||||||
box = row.box()
|
|
||||||
brow = box.row(align=True)
|
|
||||||
brow.label(text="frame")
|
|
||||||
box = row.box()
|
|
||||||
brow = box.row(align=True)
|
|
||||||
brow.label(text="scene")
|
|
||||||
box = row.box()
|
|
||||||
brow = box.row(align=True)
|
|
||||||
brow.label(text="ping")
|
|
||||||
|
|
||||||
row = col.row(align=True)
|
|
||||||
row.template_list("SESSION_UL_users", "", context.window_manager,
|
|
||||||
"online_users", context.window_manager, "user_index")
|
"online_users", context.window_manager, "user_index")
|
||||||
|
|
||||||
#OPERATOR ON USER
|
#OPERATOR ON USER
|
||||||
@ -480,32 +433,45 @@ class SESSION_UL_users(bpy.types.UIList):
|
|||||||
frame_current = str(metadata.get('frame_current','-'))
|
frame_current = str(metadata.get('frame_current','-'))
|
||||||
scene_current = metadata.get('scene_current','-')
|
scene_current = metadata.get('scene_current','-')
|
||||||
mode_current = metadata.get('mode_current','-')
|
mode_current = metadata.get('mode_current','-')
|
||||||
mode_current = metadata.get('mode_current','-')
|
if mode_current == "OBJECT" :
|
||||||
mode_icon = get_mode_icon(mode_current)
|
mode_icon = "OBJECT_DATAMODE"
|
||||||
user_color = metadata.get('color',[1.0,1.0,1.0,1.0])
|
elif mode_current == "EDIT_MESH" :
|
||||||
item.color = user_color
|
mode_icon = "EDITMODE_HLT"
|
||||||
|
elif mode_current == 'EDIT_CURVE':
|
||||||
|
mode_icon = "CURVE_DATA"
|
||||||
|
elif mode_current == 'EDIT_SURFACE':
|
||||||
|
mode_icon = "SURFACE_DATA"
|
||||||
|
elif mode_current == 'EDIT_TEXT':
|
||||||
|
mode_icon = "FILE_FONT"
|
||||||
|
elif mode_current == 'EDIT_ARMATURE':
|
||||||
|
mode_icon = "ARMATURE_DATA"
|
||||||
|
elif mode_current == 'EDIT_METABALL':
|
||||||
|
mode_icon = "META_BALL"
|
||||||
|
elif mode_current == 'EDIT_LATTICE':
|
||||||
|
mode_icon = "LATTICE_DATA"
|
||||||
|
elif mode_current == 'POSE':
|
||||||
|
mode_icon = "POSE_HLT"
|
||||||
|
elif mode_current == 'SCULPT':
|
||||||
|
mode_icon = "SCULPTMODE_HLT"
|
||||||
|
elif mode_current == 'PAINT_WEIGHT':
|
||||||
|
mode_icon = "WPAINT_HLT"
|
||||||
|
elif mode_current == 'PAINT_VERTEX':
|
||||||
|
mode_icon = "VPAINT_HLT"
|
||||||
|
elif mode_current == 'PAINT_TEXTURE':
|
||||||
|
mode_icon = "TPAINT_HLT"
|
||||||
|
elif mode_current == 'PARTICLE':
|
||||||
|
mode_icon = "PARTICLES"
|
||||||
|
elif mode_current == 'PAINT_GPENCIL' or mode_current =='EDIT_GPENCIL' or mode_current =='SCULPT_GPENCIL' or mode_current =='WEIGHT_GPENCIL' or mode_current =='VERTEX_GPENCIL':
|
||||||
|
mode_icon = "GREASEPENCIL"
|
||||||
if user['admin']:
|
if user['admin']:
|
||||||
status_icon = 'FAKE_USER_ON'
|
status_icon = 'FAKE_USER_ON'
|
||||||
row = layout.split(factor=0.35, align=True)
|
split = layout.split(factor=0.35)
|
||||||
entry = row.row(align=True)
|
split.label(text=item.username, icon=status_icon)
|
||||||
entry.scale_x = 0.05
|
split = split.split(factor=0.3)
|
||||||
entry.enabled = False
|
split.label(icon=mode_icon)
|
||||||
entry.prop(item, 'color', text="", event=False, full_event=False)
|
split.label(text=frame_current)
|
||||||
entry.enabled = True
|
split.label(text=scene_current)
|
||||||
entry.scale_x = 1.0
|
split.label(text=ping)
|
||||||
entry.label(icon=status_icon, text="")
|
|
||||||
entry.label(text=item.username)
|
|
||||||
|
|
||||||
row = row.split(factor=0.25, align=True)
|
|
||||||
|
|
||||||
entry = row.row()
|
|
||||||
entry.label(icon=mode_icon)
|
|
||||||
entry = row.row()
|
|
||||||
entry.label(text=frame_current)
|
|
||||||
entry = row.row()
|
|
||||||
entry.label(text=scene_current)
|
|
||||||
entry = row.row()
|
|
||||||
entry.label(text=ping)
|
|
||||||
|
|
||||||
def draw_property(context, parent, property_uuid, level=0):
|
def draw_property(context, parent, property_uuid, level=0):
|
||||||
settings = get_preferences()
|
settings = get_preferences()
|
||||||
@ -598,10 +564,42 @@ class SESSION_PT_sync(bpy.types.Panel):
|
|||||||
row.prop(settings.sync_flags, "sync_active_camera", text="",icon_only=True, icon='VIEW_CAMERA')
|
row.prop(settings.sync_flags, "sync_active_camera", text="",icon_only=True, icon='VIEW_CAMERA')
|
||||||
|
|
||||||
|
|
||||||
|
class SESSION_PT_replay(bpy.types.Panel):
|
||||||
|
bl_idname = "MULTIUSER_REPLAY_PT_panel"
|
||||||
|
bl_label = "Replay"
|
||||||
|
bl_space_type = 'VIEW_3D'
|
||||||
|
bl_region_type = 'UI'
|
||||||
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return context.window_manager.session.replay_files
|
||||||
|
|
||||||
|
def draw_header(self, context):
|
||||||
|
self.layout.label(text="", icon='RECOVER_LAST')
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
settings = context.window_manager.session
|
||||||
|
row= layout.row()
|
||||||
|
row.prop(settings,'replay_mode', toggle=True, expand=True)
|
||||||
|
row= layout.row()
|
||||||
|
if settings.replay_mode == 'MANUAL':
|
||||||
|
row.prop(bpy.context.scene, 'active_replay_file', text="Snapshot index")
|
||||||
|
else:
|
||||||
|
row.prop(settings, 'replay_duration', text="Replay Duration")
|
||||||
|
row= layout.row()
|
||||||
|
row.prop(settings, 'replay_persistent_collection', text="persistent collection", toggle=True, icon='OUTLINER_COLLECTION')
|
||||||
|
|
||||||
|
if settings.replay_persistent_collection:
|
||||||
|
row= layout.row()
|
||||||
|
row.prop(settings, 'replay_camera', text="", icon='VIEW_CAMERA')
|
||||||
|
|
||||||
class SESSION_PT_repository(bpy.types.Panel):
|
class SESSION_PT_repository(bpy.types.Panel):
|
||||||
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
|
bl_idname = "MULTIUSER_PROPERTIES_PT_panel"
|
||||||
bl_label = "Repository"
|
bl_label = "Repository"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
@ -743,6 +741,7 @@ classes = (
|
|||||||
SESSION_PT_sync,
|
SESSION_PT_sync,
|
||||||
SESSION_PT_repository,
|
SESSION_PT_repository,
|
||||||
VIEW3D_PT_overlay_session,
|
VIEW3D_PT_overlay_session,
|
||||||
|
SESSION_PT_replay,
|
||||||
)
|
)
|
||||||
|
|
||||||
register, unregister = bpy.utils.register_classes_factory(classes)
|
register, unregister = bpy.utils.register_classes_factory(classes)
|
||||||
|
@ -38,15 +38,6 @@ from replication.constants import (STATE_ACTIVE, STATE_AUTH,
|
|||||||
STATE_LOBBY,
|
STATE_LOBBY,
|
||||||
CONNECTING)
|
CONNECTING)
|
||||||
|
|
||||||
CLEARED_DATABLOCKS = ['actions', 'armatures', 'cache_files', 'cameras',
|
|
||||||
'collections', 'curves', 'filepath', 'fonts',
|
|
||||||
'grease_pencils', 'images', 'lattices', 'libraries',
|
|
||||||
'lightprobes', 'lights', 'linestyles', 'masks',
|
|
||||||
'materials', 'meshes', 'metaballs', 'movieclips',
|
|
||||||
'node_groups', 'objects', 'paint_curves', 'particles',
|
|
||||||
'scenes', 'shape_keys', 'sounds', 'speakers', 'texts',
|
|
||||||
'textures', 'volumes', 'worlds']
|
|
||||||
|
|
||||||
def find_from_attr(attr_name, attr_value, list):
|
def find_from_attr(attr_name, attr_value, list):
|
||||||
for item in list:
|
for item in list:
|
||||||
if getattr(item, attr_name, None) == attr_value:
|
if getattr(item, attr_name, None) == attr_value:
|
||||||
@ -108,26 +99,6 @@ def get_state_str(state):
|
|||||||
return state_str
|
return state_str
|
||||||
|
|
||||||
|
|
||||||
def clean_scene():
|
|
||||||
for type_name in CLEARED_DATABLOCKS:
|
|
||||||
sub_collection_to_avoid = [
|
|
||||||
bpy.data.linestyles.get('LineStyle'),
|
|
||||||
bpy.data.materials.get('Dots Stroke')
|
|
||||||
]
|
|
||||||
|
|
||||||
type_collection = getattr(bpy.data, type_name)
|
|
||||||
items_to_remove = [i for i in type_collection if i not in sub_collection_to_avoid]
|
|
||||||
for item in items_to_remove:
|
|
||||||
try:
|
|
||||||
type_collection.remove(item)
|
|
||||||
logging.info(item.name)
|
|
||||||
except:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Clear sequencer
|
|
||||||
bpy.context.scene.sequence_editor_clear()
|
|
||||||
|
|
||||||
|
|
||||||
def get_selected_objects(scene, active_view_layer):
|
def get_selected_objects(scene, active_view_layer):
|
||||||
return [obj.uuid for obj in scene.objects if obj.select_get(view_layer=active_view_layer)]
|
return [obj.uuid for obj in scene.objects if obj.select_get(view_layer=active_view_layer)]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user