Files
test2/source/blender/blenkernel/BKE_uvproject.h
Jacques Lucke 202db40afb Refactor: move uvproject code from blenlib to blenkernel
I'm moving this for two (related) reasons:
* It depends a lot on the specifics of `Camera` and `Object` data-blocks.
* It links `Object::object_to_world()` which is not an inline function and thus
  easily leads to linker errors. It mostly seems like luck that this is not
  breaking our build due to early dead code elimination when linking binaries
  which use the blenlib static library such as `msgfmt`.

I found this while working on a compilation tool which would not be as lucky and
has a linker error because of the dependence on `Object::object_to_world`.

Pull Request: https://projects.blender.org/blender/blender/pulls/136547
2025-03-26 20:51:57 +01:00

53 lines
1.5 KiB
C

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup bke
*/
struct Object;
struct ProjCameraInfo;
/**
* Create UV info from the camera, needs to be freed.
*
* \param rotmat: can be `obedit->object_to_world().ptr()` when uv project is used.
* \param winx, winy: can be from `scene->r.xsch / ysch`.
*/
struct ProjCameraInfo *BKE_uvproject_camera_info(const struct Object *ob,
const float rotmat[4][4],
float winx,
float winy);
/**
* Apply UV from #ProjCameraInfo (camera).
*/
void BKE_uvproject_from_camera(float target[2], float source[3], struct ProjCameraInfo *uci);
/**
* Apply uv from perspective matrix.
* \param persmat: Can be `rv3d->persmat`.
*/
void BKE_uvproject_from_view(float target[2],
float source[3],
float persmat[4][4],
float rotmat[4][4],
float winx,
float winy);
/**
* Apply orthographic UVs.
*/
void BKE_uvproject_from_view_ortho(float target[2], float source[3], const float rotmat[4][4]);
/**
* So we can adjust scale with keeping the struct private.
*/
void BKE_uvproject_camera_info_scale(ProjCameraInfo *uci, float scale_x, float scale_y);
/*
* Free info. */
void BKE_uvproject_camera_info_free(ProjCameraInfo *uci);