Skip to content

Commit 0e13942

Browse files
nrgsille76vanous
authored andcommitted
mvr: Placement of FocusPoint meshes
1 parent b08c04f commit 0e13942

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

‎mvr.py‎

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,15 @@ def get_child_list(
255255

256256
if hasattr(child_list, "fixtures") and child_list.fixtures:
257257
for fixture_idx, fixture in enumerate(child_list.fixtures):
258+
focus_points = []
258259
if fixture.focus is not None:
259-
focus_points = [
260-
fp for fp in child_list.focus_points if fp.uuid == fixture.focus
261-
]
260+
focus_points.extend(
261+
[fp for fp in child_list.focus_points if fp.uuid == fixture.focus]
262+
)
262263
if import_globals.import_fixtures:
263264
add_mvr_fixture(
264265
dmx,
266+
mscale,
265267
mvr_scene,
266268
folder_path,
267269
fixture,
@@ -419,8 +421,6 @@ def add_mvr_object(idx, node, mtx, collect, file=""):
419421
dmx_mvr_object.object_type = mvr_object.__class__.__name__
420422
dmx_mvr_object.collection = bpy.data.collections.new(mvr_object.uuid)
421423

422-
if focus_id:
423-
active_collect = group_collect
424424
if isinstance(mvr_object, pymvr.Symbol):
425425
symbols.append(mvr_object)
426426
elif isinstance(mvr_object, pymvr.Geometry3D):
@@ -438,7 +438,9 @@ def add_mvr_object(idx, node, mtx, collect, file=""):
438438
# TODO: handle this
439439
traceback.print_exception(e)
440440

441-
if symdef_id:
441+
if focus_id:
442+
active_collect = group_collect
443+
elif symdef_id:
442444
create_mvr_props(
443445
group_collect, class_name, name=name, uid=uid, classing=classing
444446
)
@@ -483,8 +485,10 @@ def add_mvr_object(idx, node, mtx, collect, file=""):
483485

484486
for idx, geometry in enumerate(geometrys):
485487
file = geometry.file_name
486-
obj_mtx = get_matrix(geometry, mscale)
487488
extract_mvr_object(file, mvr_scene, folder, import_globals)
489+
obj_mtx = (
490+
get_matrix(mvr_object, mscale) if focus_id else get_matrix(geometry, mscale)
491+
)
488492
object_collect = add_mvr_object(idx, geometry, obj_mtx, active_collect, file)
489493
if (
490494
object_collect
@@ -529,7 +533,11 @@ def add_mvr_object(idx, node, mtx, collect, file=""):
529533

530534
if focus_id:
531535
target = next(
532-
(ob for ob in group_collect.objects if ob.data is None and ob.get("uuid")),
536+
(
537+
ob
538+
for ob in group_collect.objects
539+
if ob.data is None and ob.get("Target ID") == mvr_object.uuid
540+
),
533541
None,
534542
)
535543
if target:
@@ -542,7 +550,6 @@ def add_mvr_object(idx, node, mtx, collect, file=""):
542550
):
543551
ob.parent = target
544552
ob.matrix_parent_inverse = target.matrix_world.inverted()
545-
viewlayer.update()
546553

547554

548555
def transform_objects(layers, mscale):
@@ -594,6 +601,7 @@ def extract_mvr_textures(mvr_scene, folder):
594601

595602
def add_mvr_fixture(
596603
dmx,
604+
mscale,
597605
mvr_scene,
598606
folder_path,
599607
fixture,
@@ -646,9 +654,9 @@ def add_mvr_fixture(
646654
fixture.matrix = pymvr.Matrix(0)
647655

648656
"""Get Focuspoints."""
649-
focus_point = Matrix()
657+
focus_point = mscale
650658
if len(focus_points):
651-
focus_point = get_matrix(focus_points[0], Matrix())
659+
focus_point = get_matrix(focus_points[0], mscale)
652660

653661
if existing_fixture is not None:
654662
# TODO: we should not rename the fixture on import unless if the user wants it
@@ -732,6 +740,12 @@ def add_mvr_fixture(
732740
focus_fixture = dmx.findFixtureByUUID(fixture.uuid)
733741
if focus_fixture:
734742
DMX_Log.log.info(f"importing FocusPoint geometry... {fixture.name}")
743+
focus_target = next(
744+
(tg.object for tg in focus_fixture.objects if tg.name == "Target"), None
745+
)
746+
if focus_target:
747+
focus_target["Geometry Type"] = "Target"
748+
focus_target["Target ID"] = fixture.focus
735749
process_mvr_object(
736750
bpy.context,
737751
mvr_scene,

0 commit comments

Comments
 (0)