예제 #1
0
파일: props_ui.py 프로젝트: armory3d/armory
    def execute(self, context):
        if not armutils.check_saved(self):
            return {"CANCELLED"}

        assets.invalidate_enabled = False
        make.build_project()
        make.compile_project(watch=True)
        assets.invalidate_enabled = True
        return{'FINISHED'}
예제 #2
0
파일: props_ui.py 프로젝트: daela/armory
    def execute(self, context):
        if not armutils.check_saved(self):
            return {"CANCELLED"}

        if not armutils.check_camera(self):
            return {"CANCELLED"}

        if not armutils.check_sdkpath(self):
            return {"CANCELLED"}

        state.target = bpy.data.worlds['Arm'].arm_project_target
        assets.invalidate_enabled = False
        make.build_project(target=state.target)
        make.compile_project(target_name=state.target, watch=True)
        assets.invalidate_enabled = True
        return{'FINISHED'}
예제 #3
0
파일: props_ui.py 프로젝트: daela/armory
    def execute(self, context):
        if not armutils.check_saved(self):
            return {"CANCELLED"}

        if not armutils.check_camera(self):
            return {"CANCELLED"}

        if not armutils.check_sdkpath(self):
            return {"CANCELLED"}

        state.target = make.runtime_to_target(in_viewport=False)
        assets.invalidate_enabled = False
        make.build_project(target=state.target)
        make.compile_project(target_name=state.target, watch=True)
        assets.invalidate_enabled = True
        return{'FINISHED'}
예제 #4
0
파일: props_ui.py 프로젝트: armory3d/armory
    def execute(self, context):
        if not armutils.check_saved(self):
            return {"CANCELLED"}

        if not armutils.check_camera(self):
            return {"CANCELLED"}

        nodes_renderpath.check_default()

        assets.invalidate_enabled = False
        if state.playproc == None:
            log.clear()
            # Cancel viewport render
            for space in context.area.spaces:
                if space.type == 'VIEW_3D':
                    if space.viewport_shade == 'RENDERED':
                        space.viewport_shade = 'SOLID'
                    break
            make.play_project(self, True)
        else:
            make.patch_project()
            make.compile_project()
        assets.invalidate_enabled = True
        return{'FINISHED'}
예제 #5
0
파일: props_ui.py 프로젝트: armory3d/armory
 def execute(self, context):
     assets.invalidate_enabled = False
     make.patch_project()
     make.compile_project()
     assets.invalidate_enabled = True
     return{'FINISHED'}
예제 #6
0
파일: handlers.py 프로젝트: armory3d/armory
def on_scene_update_post(context):
    global last_time
    # global last_update_time
    global last_operator
    global redraw_ui
    global redraw_progress

    # Redraw at the start of 'next' frame
    if redraw_ui and bpy.context.screen != None:
        for area in bpy.context.screen.areas:
                if area.type == 'VIEW_3D' or area.type == 'PROPERTIES':
                    area.tag_redraw()
        redraw_ui = False
    if redraw_progress and bpy.context.screen != None:
        for area in bpy.context.screen.areas:
            if area.type == 'INFO':
                area.tag_redraw()
                break
        redraw_progress = False

    # New operator
    ops = bpy.context.window_manager.operators
    operators_changed = False
    if len(ops) > 0 and last_operator != ops[-1]:
        last_operator = ops[-1]
        operators_changed = True

    # Player running
    state.krom_running = False
    if not state.is_paused and bpy.context.screen != None:
        for area in bpy.context.screen.areas:
            if area.type == 'VIEW_ARMORY':
                state.krom_running = True
                break

    # Auto patch on every operator change
    if state.krom_running and \
       bpy.data.worlds['Arm'].arm_play_live_patch and \
       bpy.data.worlds['Arm'].arm_play_auto_build and \
       operators_changed:
        # Otherwise rebuild scene
        if bridge.send_operator(last_operator) == False:
            make.patch_project()
            make.compile_project(target_name="krom", patch=True)

    # Use frame rate for update frequency for now
    if time.time() - last_time >= (1 / bpy.context.scene.render.fps):
        last_time = time.time()

        if state.krom_running:
            # Read krom console
            if barmory.get_console_updated() == 1:
                log.print_player(barmory.get_console())
            # Read operator console
            if barmory.get_operator_updated() == 1:
                bridge.parse_operator(barmory.get_operator())
            # Tag redraw
            if bpy.context.screen != None:
                for area in bpy.context.screen.areas:
                    if area.type == 'VIEW_ARMORY':
                        area.tag_redraw()
                        break

        # New output has been logged
        if log.tag_redraw and bpy.context.screen != None:
            log.tag_redraw = False
            redraw_progress = True

        # Player finished, redraw play buttons
        if state.playproc_finished and bpy.context.screen != None:
            state.playproc_finished = False
            redraw_ui = True

        # Compilation finished
        if state.compileproc_finished and bpy.context.screen != None:
            state.compileproc_finished = False
            redraw_ui = True
            # Compilation succesfull
            if state.compileproc_success:
                # Notify embedded player
                if state.krom_running:
                    barmory.call_js('armory.Scene.patch();')
                # Or switch to armory space
                elif armutils.with_krom() and state.in_viewport:
                    state.play_area.type = 'VIEW_ARMORY'
                    # Prevent immediate operator patch
                    if len(ops) > 0:
                        last_operator = ops[-1]

    # No attribute when using multiple windows?
    if hasattr(bpy.context, 'edit_object'):
        edit_obj = bpy.context.edit_object
        if edit_obj != None and edit_obj.is_updated_data:
            if edit_obj.type == 'MESH':
                edit_obj.data.mesh_cached = False
            elif edit_obj.type == 'ARMATURE':
                edit_obj.data.data_cached = False

    obj = bpy.context.object
    if obj != None:
        if operators_changed:
            # Modifier was added/removed, recache mesh
            if ops[-1].bl_idname == 'OBJECT_OT_modifier_add' or ops[-1].bl_idname == 'OBJECT_OT_modifier_remove':
                obj.data.mesh_cached = False
        if obj.active_material != None and obj.active_material.is_updated:
            obj.active_material.is_cached = False