Exemple #1
0
def join_room(room_name: str, vrtist_protocol: bool = False, shared_folders=None, ignore_version_check: bool = False):
    prefs = get_mixer_prefs()
    logger.warning(f"join: room: {room_name}, user: {prefs.user}")

    for line in tech_infos():
        logger.warning(line)

    assert share_data.client.current_room is None
    share_data.session_id += 1
    # todo tech debt -> current_room should be set when JOIN_ROOM is received
    # todo _joining_room_name should be set in client timer
    share_data.client.current_room = room_name
    share_data.client._joining_room_name = room_name
    set_client_attributes()
    blender_version = bpy.app.version_string
    mixer_version = mixer.display_version
    share_data.client.join_room(room_name, blender_version, mixer_version, ignore_version_check, not vrtist_protocol)

    if shared_folders is None:
        shared_folders = []
    share_data.init_protocol(vrtist_protocol, shared_folders)
    share_data.pending_test_update = False

    # join a room <==> want to track local changes
    HandlerManager.set_handlers(True)
Exemple #2
0
def join_room(room_name: str):
    logger.info("join_room")

    assert share_data.client.current_room is None
    BlendData.instance().reset()
    share_data.session_id += 1
    # todo tech debt -> current_room should be set when JOIN_ROOM is received
    # todo _joining_room_name should be set in client timer
    share_data.client.current_room = room_name
    share_data.client._joining_room_name = room_name
    set_client_attributes()
    share_data.client.join_room(room_name)
    share_data.client.send_set_current_scene(bpy.context.scene.name_full)

    share_data.current_statistics = {
        "session_id": share_data.session_id,
        "blendfile": bpy.data.filepath,
        "statsfile": get_stats_filename(share_data.run_id,
                                        share_data.session_id),
        "user": get_mixer_prefs().user,
        "room": room_name,
        "children": {},
    }
    prefs = get_mixer_prefs()
    share_data.auto_save_statistics = prefs.auto_save_statistics
    share_data.statistics_directory = prefs.statistics_directory
    share_data.set_experimental_sync(prefs.experimental_sync)
    share_data.pending_test_update = False

    # join a room <==> want to track local changes
    HandlerManager.set_handlers(True)
Exemple #3
0
def connect():
    prefs = get_mixer_prefs()
    logger.info(f"connect to {prefs.host}:{prefs.port}")
    if share_data.client is not None:
        # a server shutdown was not processed
        logger.debug("connect: share_data.client is not None")
        share_data.client = None

    if not create_main_client(prefs.host, prefs.port):
        if is_localhost(prefs.host):
            if prefs.no_start_server:
                raise RuntimeError(
                    f"Cannot connect to existing server at {prefs.host}:{prefs.port} and MIXER_NO_START_SERVER environment variable exists"
                )
            start_local_server()
            if not wait_for_server(prefs.host, prefs.port):
                raise RuntimeError("Unable to start local server")
        else:
            raise RuntimeError(
                f"Unable to connect to remote server {prefs.host}:{prefs.port}"
            )

    assert is_client_connected()

    set_client_attributes()
    HandlerManager._set_connection_handler(True)
Exemple #4
0
def leave_current_room():
    logger.info("leave_current_room")

    if share_data.client and share_data.client.current_room:
        share_data.leave_current_room()
        HandlerManager.set_handlers(False)

    share_data.clear_before_state()
Exemple #5
0
def leave_current_room():
    logger.info("leave_current_room")

    if share_data.client and share_data.client.current_room:
        share_data.leave_current_room()
        HandlerManager.set_handlers(False)

    share_data.clear_before_state()

    if share_data.current_statistics is not None and share_data.auto_save_statistics:
        save_statistics(share_data.current_statistics,
                        share_data.statistics_directory)
    share_data.current_statistics = None
    share_data.auto_save_statistics = False
    share_data.statistics_directory = None
Exemple #6
0
def send_scene_content():
    """
    Initial data send to fill a new room.
    """

    from mixer.handlers import HandlerManager, send_scene_data_to_server

    if get_mixer_prefs().no_send_scene_content:
        return

    with HandlerManager(False):
        # mesh baking may trigger depsgraph_updatewhen more than one view layer and
        # cause to reenter send_scene_data_to_server() and send duplicate messages

        share_data.clear_before_state()
        share_data.init_proxy()
        share_data.client.send_group_begin()

        # Temporary waiting for material sync. Should move to send_scene_data_to_server
        for material in bpy.data.materials:
            share_data.client.send_material(material)

        send_scene_data_to_server(None, None)

        shot_manager.send_scene()
        share_data.client.send_frame_start_end(bpy.context.scene.frame_start, bpy.context.scene.frame_end)
        share_data.start_frame = bpy.context.scene.frame_start
        share_data.end_frame = bpy.context.scene.frame_end
        share_data.client.send_frame(bpy.context.scene.frame_current)

        share_data.client.send_group_end()
Exemple #7
0
def disconnect():
    from mixer.bl_panels import update_ui_lists

    logger.info("disconnect")

    leave_current_room()

    remove_draw_handlers()

    if bpy.app.timers.is_registered(network_consumer_timer):
        bpy.app.timers.unregister(network_consumer_timer)

    # the socket has already been disconnected
    if share_data.client is not None:
        if share_data.client.is_connected():
            share_data.client.disconnect()
        share_data.client = None

    update_ui_lists()
    HandlerManager._set_connection_handler(False)
Exemple #8
0
def join_room(room_name: str, vrtist_protocol: bool = False):
    prefs = get_mixer_prefs()
    logger.warning(f"join: room: {room_name}, user: {prefs.user}")

    for line in tech_infos():
        logger.warning(line)

    assert share_data.client.current_room is None
    share_data.session_id += 1
    # todo tech debt -> current_room should be set when JOIN_ROOM is received
    # todo _joining_room_name should be set in client timer
    share_data.client.current_room = room_name
    share_data.client._joining_room_name = room_name
    set_client_attributes()
    share_data.client.join_room(room_name)
    share_data.client.send_set_current_scene(bpy.context.scene.name_full)

    share_data.set_vrtist_protocol(vrtist_protocol)
    share_data.pending_test_update = False

    # join a room <==> want to track local changes
    HandlerManager.set_handlers(True)
Exemple #9
0
def clear_scene_content():
    """
    Clear data before joining a room.
    """

    from mixer.handlers import HandlerManager

    with HandlerManager(False):

        data = [
            "cameras",
            "collections",
            "curves",
            "grease_pencils",
            "images",
            "lights",
            "objects",
            "materials",
            "metaballs",
            "meshes",
            "textures",
            "worlds",
            "sounds",
        ]

        for name in data:
            collection = getattr(bpy.data, name)
            for obj in collection:
                collection.remove(obj)

        # Cannot remove the last scene at this point, treat it differently
        for scene in bpy.data.scenes[:-1]:
            scene_api.delete_scene(scene)

        share_data.clear_before_state()

        if len(bpy.data.scenes) == 1:
            scene = bpy.data.scenes[0]
            scene.name = "__last_scene_to_be_removed__"