Esempio n. 1
0
def handler_on_undo_redo_post(scene, dummy):
    logger.info("on_undo_redo_post")

    share_data.set_dirty()
    share_data.clear_lists()
    # apply only in object mode
    if not is_in_object_mode():
        return

    old_objects_name = dict([(k, None) for k in share_data.old_objects.keys()
                             ])  # value not needed
    remap_objects_info()
    for k, v in share_data.old_objects.items():
        if k in old_objects_name:
            old_objects_name[k] = v

    update_object_state(old_objects_name, share_data.old_objects)

    update_collections_state()
    update_scenes_state()

    remove_objects_from_scenes()
    remove_objects_from_collections()
    remove_collections_from_scenes()
    remove_collections_from_collections()

    remove_collections()
    remove_scenes()
    add_scenes()
    add_objects()
    add_collections()

    add_collections_to_scenes()
    add_collections_to_collections()

    add_objects_to_collections()
    add_objects_to_scenes()

    update_collections_parameters()
    create_vrtist_objects()
    delete_scene_objects()
    rename_objects()
    update_objects_visibility()
    update_objects_transforms()
    reparent_objects()

    # send selection content (including data)
    materials = set()
    for obj in bpy.context.selected_objects:
        update_transform(obj)
        if hasattr(obj, "data"):
            update_params(obj)
        if hasattr(obj, "material_slots"):
            for slot in obj.material_slots[:]:
                materials.add(slot.material)

    for material in materials:
        share_data.client.send_material(material)

    share_data.update_current_data()
Esempio n. 2
0
def add_objects():
    changed = False
    for obj_name in share_data.objects_added:
        obj = share_data.blender_objects.get(obj_name)
        if obj:
            update_params(obj)
            changed = True
    return changed
Esempio n. 3
0
def update_objects_data():
    depsgraph = bpy.context.evaluated_depsgraph_get()

    if len(depsgraph.updates) == 0:
        return  # Exit here to avoid noise if you want to put breakpoints in this function

    data_container = {}
    data = set()
    transforms = set()

    for update in depsgraph.updates:
        obj = update.id.original
        typename = obj.bl_rna.name

        if typename == "Object":
            if hasattr(obj, "data"):
                if obj.data in data_container:
                    data_container[obj.data].append(obj)
                else:
                    data_container[obj.data] = [obj]
            if obj.name_full not in share_data.objects_transformed:
                transforms.add(obj)

        if (
            typename == "Camera"
            or typename == "Mesh"
            or typename == "Curve"
            or typename == "Text Curve"
            or typename == "Sun Light"
            or typename == "Point Light"
            or typename == "Spot Light"
            or typename == "Grease Pencil"
        ):
            data.add(obj)

        if typename == "Material":
            share_data.client.send_material(obj)

        if typename == "Scene":
            shot_manager.update_scene()

    update_frame_start_end()

    # Send transforms
    for obj in transforms:
        update_transform(obj)

    # Send data (mesh) of objects
    for d in data:
        container = data_container.get(d)
        if not container:
            continue
        for c in container:
            update_params(c)
Esempio n. 4
0
def handler_on_undo_redo_post(scene, dummy):
    logger.error(f"Undo/redo post on {scene}")
    share_data.client.send_error(
        f"Undo/redo post from {get_mixer_prefs().user}")

    if not share_data.use_vrtist_protocol():
        # Generic sync: reload all datablocks
        undone = share_data.bpy_data_proxy.snapshot_undo_post()
        logger.warning(f"undone uuids : {undone}")
        share_data.bpy_data_proxy.reload_datablocks()
    else:
        share_data.set_dirty()
        share_data.clear_lists()
        # apply only in object mode
        if not is_in_object_mode():
            return

        old_objects_name = dict([
            (k, None) for k in share_data.old_objects.keys()
        ])  # value not needed
        remap_objects_info()
        for k, v in share_data.old_objects.items():
            if k in old_objects_name:
                old_objects_name[k] = v

        update_object_state(old_objects_name, share_data.old_objects)

        update_collections_state()
        update_scenes_state()

        remove_objects_from_scenes()
        remove_objects_from_collections()
        remove_collections_from_scenes()
        remove_collections_from_collections()

        remove_collections()
        add_scenes()
        add_objects()
        add_collections()

        add_collections_to_scenes()
        add_collections_to_collections()

        add_objects_to_collections()
        add_objects_to_scenes()

        update_collections_parameters()
        create_vrtist_objects()
        delete_scene_objects()
        rename_objects()
        update_objects_visibility()
        update_objects_constraints()
        update_objects_transforms()
        reparent_objects()

        # send selection content (including data)
        materials = set()
        for obj in bpy.context.selected_objects:
            update_transform(obj)
            if hasattr(obj, "data"):
                update_params(obj)
            if hasattr(obj, "material_slots"):
                for slot in obj.material_slots[:]:
                    materials.add(slot.material)

        for material in materials:
            share_data.client.send_material(material)

        share_data.update_current_data()