Exemple #1
0
def asset_clear(context: Context, datablock: Any) -> Set[str]:
    asset_clear_ctx = {
        **context.copy(),
        "id": datablock,
    }
    result = bpy.ops.asset.clear(asset_clear_ctx)
    assert isinstance(result, set)
    if "FINISHED" in result:
        datablock.use_fake_user = False
    return result
    def draw_evaluated_transform(self, context: Context) -> None:
        depsgraph = context.evaluated_depsgraph_get()
        ob_eval = context.object.evaluated_get(depsgraph)

        if ob_eval.mode == "OBJECT":
            self.draw_decomposed_matrix("Evaluated Transform:",
                                        ob_eval.matrix_world)
            self.draw_decomposed_matrix("Parent Inverse:",
                                        ob_eval.matrix_parent_inverse)

        if context.active_pose_bone:
            bone = context.active_pose_bone
            self.draw_decomposed_matrix(f"{bone.name} matrix:", bone.matrix)
            self.draw_decomposed_matrix(f"{bone.name} matrix_basis:",
                                        bone.matrix_basis)
Exemple #3
0
def detect_overlap(context: Context, obs: Iterable[Object],
                   merge_distance: float):
    depsgraph = context.evaluated_depsgraph_get()
    bm = bmesh.new()

    for ob in obs:
        ob_eval = ob.evaluated_get(depsgraph)
        me = ob_eval.to_mesh()
        me.transform(ob.matrix_world)

        bm.from_mesh(me)

        ob_eval.to_mesh_clear()

    bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=merge_distance)

    tree = bvhtree.BVHTree.FromBMesh(bm, epsilon=0.00001)
    overlap = tree.overlap(tree)

    bm.free()
    return bool(overlap)
Exemple #4
0
def create_poselib_action(
    context: Context,
    src_action: Action,
    src_frame_nr: float,
    bone_names: Set[str],
    pose_name: str,
) -> Action:
    """Create a single-frame Action containing only the given bones."""

    dst_action = bpy.data.actions.new(pose_name)
    dst_action.id_root = src_action.id_root

    copy_fcurves(dst_action, src_action, src_frame_nr, bone_names)

    asset_mark_ctx = {
        **context.copy(),
        "id": dst_action,
    }
    bpy.ops.asset.mark(asset_mark_ctx)
    # TODO(Sybren): Add Asset metadata.

    return dst_action
Exemple #5
0
 def execute(self, context: Context) -> Set[str]:
     flipped = context.window_manager.poselib_flipped
     return bpy.ops.poselib.apply_pose_asset(context.copy(),
                                             'EXEC_DEFAULT',
                                             flipped=flipped)
Exemple #6
0
 def poll(cls, context: Context) -> bool:
     return bpy.ops.poselib.apply_pose_asset.poll(context.copy())
Exemple #7
0
 def invoke(self, context: Context, event: Event) -> Set[str]:
     flipped = context.window_manager.poselib_flipped
     return bpy.ops.poselib.blend_pose_asset(context.copy(),
                                             'INVOKE_DEFAULT',
                                             flipped=flipped)
Exemple #8
0
 def poll(cls, context: Context) -> bool:
     if not asset_utils.SpaceAssetInfo.is_asset_browser(context.space_data):
         return False
     return bpy.ops.poselib.apply_pose_asset.poll(context.copy())
Exemple #9
0
def asset_mark(context: Context, datablock: Any) -> Set[str]:
    asset_mark_ctx = {
        **context.copy(),
        "id": datablock,
    }
    return cast(Set[str], bpy.ops.asset.mark(asset_mark_ctx))