Blender
V3.3
|
#include <limits.h>
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_math.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "BKE_customdata.h"
#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
#include "BKE_mesh_tangent.h"
#include "BKE_report.h"
#include "BLI_strict_flags.h"
#include "atomic_ops.h"
#include "mikktspace.h"
Go to the source code of this file.
Classes | |
struct | BKEMeshToTangent |
struct | SGLSLMeshToTangent |
Functions | |
Mesh Tangent Calculations (Single Layer) | |
static int | get_num_faces (const SMikkTSpaceContext *pContext) |
static int | get_num_verts_of_face (const SMikkTSpaceContext *pContext, const int face_idx) |
static void | get_position (const SMikkTSpaceContext *pContext, float r_co[3], const int face_idx, const int vert_idx) |
static void | get_texture_coordinate (const SMikkTSpaceContext *pContext, float r_uv[2], const int face_idx, const int vert_idx) |
static void | get_normal (const SMikkTSpaceContext *pContext, float r_no[3], const int face_idx, const int vert_idx) |
static void | set_tspace (const SMikkTSpaceContext *pContext, const float fv_tangent[3], const float face_sign, const int face_idx, const int vert_idx) |
void | BKE_mesh_calc_loop_tangent_single_ex (const MVert *mverts, const int UNUSED(numVerts), const MLoop *mloops, float(*r_looptangent)[4], const float(*loopnors)[3], const MLoopUV *loopuvs, const int UNUSED(numLoops), const MPoly *mpolys, const int numPolys, ReportList *reports) |
void | BKE_mesh_calc_loop_tangent_single (Mesh *mesh, const char *uvmap, float(*r_looptangents)[4], ReportList *reports) |
Mesh Tangent Calculations (All Layers) | |
#define | USE_LOOPTRI_DETECT_QUADS |
static int | dm_ts_GetNumFaces (const SMikkTSpaceContext *pContext) |
static int | dm_ts_GetNumVertsOfFace (const SMikkTSpaceContext *pContext, const int face_num) |
static void | dm_ts_GetPosition (const SMikkTSpaceContext *pContext, float r_co[3], const int face_num, const int vert_index) |
static void | dm_ts_GetTextureCoordinate (const SMikkTSpaceContext *pContext, float r_uv[2], const int face_num, const int vert_index) |
static void | dm_ts_GetNormal (const SMikkTSpaceContext *pContext, float r_no[3], const int face_num, const int vert_index) |
static void | dm_ts_SetTSpace (const SMikkTSpaceContext *pContext, const float fvTangent[3], const float fSign, const int face_num, const int vert_index) |
static void | DM_calc_loop_tangents_thread (TaskPool *__restrict UNUSED(pool), void *taskdata) |
void | BKE_mesh_add_loop_tangent_named_layer_for_uv (CustomData *uv_data, CustomData *tan_data, int numLoopData, const char *layer_name) |
void | BKE_mesh_calc_loop_tangent_step_0 (const CustomData *loopData, bool calc_active_tangent, const char(*tangent_names)[MAX_NAME], int tangent_names_count, bool *rcalc_act, bool *rcalc_ren, int *ract_uv_n, int *rren_uv_n, char *ract_uv_name, char *rren_uv_name, short *rtangent_mask) |
void | BKE_mesh_calc_loop_tangent_ex (const MVert *mvert, const MPoly *mpoly, const uint mpoly_len, const MLoop *mloop, const MLoopTri *looptri, const uint looptri_len, CustomData *loopdata, bool calc_active_tangent, const char(*tangent_names)[MAX_NAME], int tangent_names_len, const float(*vert_normals)[3], const float(*poly_normals)[3], const float(*loop_normals)[3], const float(*vert_orco)[3], CustomData *loopdata_out, const uint loopdata_out_len, short *tangent_mask_curr_p) |
void | BKE_mesh_calc_loop_tangents (Mesh *me_eval, bool calc_active_tangent, const char(*tangent_names)[MAX_NAME], int tangent_names_len) |
Functions to evaluate mesh tangents.
Definition in file mesh_tangent.c.
#define USE_LOOPTRI_DETECT_QUADS |
Definition at line 201 of file mesh_tangent.c.
void BKE_mesh_add_loop_tangent_named_layer_for_uv | ( | CustomData * | uv_data, |
CustomData * | tan_data, | ||
int | numLoopData, | ||
const char * | layer_name | ||
) |
Definition at line 448 of file mesh_tangent.c.
References CD_CALLOC, CD_MLOOPUV, CD_TANGENT, CustomData_add_layer_named(), CustomData_get_named_layer_index(), and NULL.
Referenced by BKE_editmesh_loop_tangent_calc(), and BKE_mesh_calc_loop_tangent_ex().
void BKE_mesh_calc_loop_tangent_ex | ( | const MVert * | mvert, |
const MPoly * | mpoly, | ||
const uint | mpoly_len, | ||
const MLoop * | mloop, | ||
const MLoopTri * | looptri, | ||
const uint | looptri_len, | ||
CustomData * | loopdata, | ||
bool | calc_active_tangent, | ||
const char(*) | tangent_names[MAX_NAME], | ||
int | tangent_names_len, | ||
const float(*) | vert_normals[3], | ||
const float(*) | poly_normals[3], | ||
const float(*) | loop_normals[3], | ||
const float(*) | vert_orco[3], | ||
CustomData * | loopdata_out, | ||
const uint | loopdata_out_len, | ||
short * | tangent_mask_curr_p | ||
) |
Definition at line 532 of file mesh_tangent.c.
References BKE_mesh_add_loop_tangent_named_layer_for_uv(), BKE_mesh_calc_loop_tangent_step_0(), BLI_assert, BLI_task_pool_create(), BLI_task_pool_free(), BLI_task_pool_push(), BLI_task_pool_work_and_wait(), CD_CALLOC, CD_MLOOPUV, CD_TANGENT, CustomData_add_layer_named(), CustomData_get_layer_index(), CustomData_get_layer_index_n(), CustomData_get_layer_named(), CustomData_get_named_layer_index(), CustomData_number_of_layers(), CustomData_set_layer_active_index(), CustomData_set_layer_render_index(), CustomDataLayer::data, DM_calc_loop_tangents_thread(), DM_TANGENT_MASK_ORCO, SGLSLMeshToTangent::face_as_quad_map, CustomData::layers, SGLSLMeshToTangent::looptri, MAX_MTFACE, MAX_NAME, MEM_freeN, MEM_mallocN, SGLSLMeshToTangent::mloop, SGLSLMeshToTangent::mloopuv, SGLSLMeshToTangent::mpoly, SGLSLMeshToTangent::mvert, CustomDataLayer::name, NULL, SGLSLMeshToTangent::num_face_as_quad_map, SGLSLMeshToTangent::numTessFaces, SGLSLMeshToTangent::orco, SGLSLMeshToTangent::precomputedFaceNormals, SGLSLMeshToTangent::precomputedLoopNormals, SGLSLMeshToTangent::tangent, task_pool, TASK_PRIORITY_HIGH, and SGLSLMeshToTangent::vert_normals.
Referenced by BKE_mesh_calc_loop_tangents().
void BKE_mesh_calc_loop_tangent_single | ( | struct Mesh * | mesh, |
const char * | uvmap, | ||
float(*) | r_looptangents[4], | ||
struct ReportList * | reports | ||
) |
Wrapper around BKE_mesh_calc_loop_tangent_single_ex, which takes care of most boilerplate code.
Definition at line 153 of file mesh_tangent.c.
References BKE_mesh_calc_loop_tangent_single_ex(), BKE_report(), BKE_reportf(), CD_MLOOPUV, CD_NORMAL, CustomData_get_layer(), CustomData_get_layer_named(), float(), Mesh::ldata, mesh, Mesh::mloop, Mesh::mpoly, Mesh::mvert, RPT_ERROR, Mesh::totloop, Mesh::totpoly, and Mesh::totvert.
void BKE_mesh_calc_loop_tangent_single_ex | ( | const MVert * | mverts, |
const int | UNUSEDnumVerts, | ||
const MLoop * | mloops, | ||
float(*) | r_looptangent[4], | ||
const float(*) | loopnors[3], | ||
const MLoopUV * | loopuvs, | ||
const int | UNUSEDnumLoops, | ||
const MPoly * | mpolys, | ||
const int | numPolys, | ||
ReportList * | reports | ||
) |
Definition at line 102 of file mesh_tangent.c.
References BKE_report(), genTangSpaceDefault(), get_normal(), get_num_faces(), get_num_verts_of_face(), get_position(), get_texture_coordinate(), BKEMeshToTangent::lnors, BKEMeshToTangent::luvs, SMikkTSpaceInterface::m_getNormal, SMikkTSpaceInterface::m_getNumFaces, SMikkTSpaceInterface::m_getNumVerticesOfFace, SMikkTSpaceInterface::m_getPosition, SMikkTSpaceInterface::m_getTexCoord, SMikkTSpaceContext::m_pInterface, SMikkTSpaceContext::m_pUserData, SMikkTSpaceInterface::m_setTSpaceBasic, BKEMeshToTangent::mloops, BKEMeshToTangent::mpolys, BKEMeshToTangent::mverts, NULL, BKEMeshToTangent::num_polys, RPT_ERROR, set_tspace(), BKEMeshToTangent::tangents, and MPoly::totloop.
Referenced by BKE_mesh_calc_loop_tangent_single().
void BKE_mesh_calc_loop_tangent_step_0 | ( | const CustomData * | loopData, |
bool | calc_active_tangent, | ||
const char(*) | tangent_names[MAX_NAME], | ||
int | tangent_names_count, | ||
bool * | rcalc_act, | ||
bool * | rcalc_ren, | ||
int * | ract_uv_n, | ||
int * | rren_uv_n, | ||
char * | ract_uv_name, | ||
char * | rren_uv_name, | ||
short * | rtangent_mask | ||
) |
Definition at line 459 of file mesh_tangent.c.
References blender::bke::attribute_accessor_functions::add(), CD_MLOOPUV, CustomData_get_active_layer(), CustomData_get_layer_index(), CustomData_get_layer_name(), CustomData_get_render_layer(), CustomData_number_of_layers(), DM_TANGENT_MASK_ORCO, CustomData::layers, CustomDataLayer::name, and STREQ.
Referenced by BKE_mesh_calc_loop_tangent_ex().
void BKE_mesh_calc_loop_tangents | ( | Mesh * | me_eval, |
bool | calc_active_tangent, | ||
const char(*) | tangent_names[MAX_NAME], | ||
int | tangent_names_len | ||
) |
Definition at line 712 of file mesh_tangent.c.
References MLoopTri_Store::array, BKE_mesh_calc_loop_tangent_ex(), BKE_mesh_poly_normals_ensure(), BKE_mesh_runtime_looptri_ensure(), BKE_mesh_vertex_normals_ensure(), CD_NORMAL, CD_ORCO, CustomData_get_layer(), Mesh::ldata, MLoopTri_Store::len, Mesh_Runtime::looptris, Mesh::mloop, Mesh::mpoly, Mesh::mvert, Mesh::runtime, Mesh::totloop, Mesh::totpoly, and Mesh::vdata.
Referenced by mesh_calc_tri_tessface().
|
static |
Definition at line 426 of file mesh_tangent.c.
References dm_ts_GetNormal(), dm_ts_GetNumFaces(), dm_ts_GetNumVertsOfFace(), dm_ts_GetPosition(), dm_ts_GetTextureCoordinate(), dm_ts_SetTSpace(), genTangSpaceDefault(), SMikkTSpaceInterface::m_getNormal, SMikkTSpaceInterface::m_getNumFaces, SMikkTSpaceInterface::m_getNumVerticesOfFace, SMikkTSpaceInterface::m_getPosition, SMikkTSpaceInterface::m_getTexCoord, SMikkTSpaceContext::m_pInterface, SMikkTSpaceContext::m_pUserData, SMikkTSpaceInterface::m_setTSpaceBasic, and NULL.
Referenced by BKE_mesh_calc_loop_tangent_ex().
|
static |
Definition at line 328 of file mesh_tangent.c.
References MVert::co, copy_v3_v3(), SGLSLMeshToTangent::face_as_quad_map, MPoly::flag, if(), MPoly::loopstart, SGLSLMeshToTangent::looptri, SMikkTSpaceContext::m_pUserData, ME_SMOOTH, SGLSLMeshToTangent::mloop, SGLSLMeshToTangent::mpoly, SGLSLMeshToTangent::mvert, normal_quad_v3(), normal_tri_v3(), SGLSLMeshToTangent::precomputedFaceNormals, SGLSLMeshToTangent::precomputedLoopNormals, MPoly::totloop, MLoopTri::tri, USE_LOOPTRI_DETECT_QUADS, MLoop::v, and SGLSLMeshToTangent::vert_normals.
Referenced by DM_calc_loop_tangents_thread().
|
static |
Definition at line 226 of file mesh_tangent.c.
References SMikkTSpaceContext::m_pUserData, SGLSLMeshToTangent::num_face_as_quad_map, and SGLSLMeshToTangent::numTessFaces.
Referenced by DM_calc_loop_tangents_thread().
|
static |
Definition at line 237 of file mesh_tangent.c.
References SGLSLMeshToTangent::face_as_quad_map, SGLSLMeshToTangent::looptri, SMikkTSpaceContext::m_pUserData, SGLSLMeshToTangent::mpoly, MLoopTri::poly, MPoly::totloop, and UNUSED_VARS.
Referenced by DM_calc_loop_tangents_thread().
|
static |
Definition at line 255 of file mesh_tangent.c.
References MVert::co, copy_v3_v3(), SGLSLMeshToTangent::face_as_quad_map, MPoly::loopstart, SGLSLMeshToTangent::looptri, SMikkTSpaceContext::m_pUserData, SGLSLMeshToTangent::mloop, SGLSLMeshToTangent::mpoly, SGLSLMeshToTangent::mvert, MLoopTri::poly, MPoly::totloop, MLoopTri::tri, and MLoop::v.
Referenced by DM_calc_loop_tangents_thread().
|
static |
Definition at line 289 of file mesh_tangent.c.
References copy_v2_v2(), SGLSLMeshToTangent::face_as_quad_map, MPoly::loopstart, SGLSLMeshToTangent::looptri, SMikkTSpaceContext::m_pUserData, map_to_sphere(), SGLSLMeshToTangent::mloop, SGLSLMeshToTangent::mloopuv, SGLSLMeshToTangent::mpoly, NULL, SGLSLMeshToTangent::orco, MLoopTri::poly, MPoly::totloop, MLoopTri::tri, MLoopUV::uv, and MLoop::v.
Referenced by DM_calc_loop_tangents_thread().
|
static |
Definition at line 389 of file mesh_tangent.c.
References copy_v3_v3(), SGLSLMeshToTangent::face_as_quad_map, if(), MPoly::loopstart, SGLSLMeshToTangent::looptri, SMikkTSpaceContext::m_pUserData, SGLSLMeshToTangent::mpoly, SGLSLMeshToTangent::tangent, MPoly::totloop, MLoopTri::tri, and USE_LOOPTRI_DETECT_QUADS.
Referenced by DM_calc_loop_tangents_thread().
|
static |
Definition at line 81 of file mesh_tangent.c.
References copy_v3_v3(), BKEMeshToTangent::lnors, MPoly::loopstart, SMikkTSpaceContext::m_pUserData, and BKEMeshToTangent::mpolys.
Referenced by BKE_mesh_calc_loop_tangent_single_ex().
|
static |
Definition at line 50 of file mesh_tangent.c.
References SMikkTSpaceContext::m_pUserData, and BKEMeshToTangent::num_polys.
Referenced by BKE_mesh_calc_loop_tangent_single_ex().
|
static |
Definition at line 56 of file mesh_tangent.c.
References SMikkTSpaceContext::m_pUserData, BKEMeshToTangent::mpolys, and MPoly::totloop.
Referenced by BKE_mesh_calc_loop_tangent_single_ex().
|
static |
Definition at line 62 of file mesh_tangent.c.
References MVert::co, copy_v3_v3(), MPoly::loopstart, SMikkTSpaceContext::m_pUserData, BKEMeshToTangent::mloops, BKEMeshToTangent::mpolys, BKEMeshToTangent::mverts, and MLoop::v.
Referenced by BKE_mesh_calc_loop_tangent_single_ex().
|
static |
Definition at line 72 of file mesh_tangent.c.
References copy_v2_v2(), MPoly::loopstart, BKEMeshToTangent::luvs, SMikkTSpaceContext::m_pUserData, BKEMeshToTangent::mpolys, and MLoopUV::uv.
Referenced by BKE_mesh_calc_loop_tangent_single_ex().
|
static |
Definition at line 90 of file mesh_tangent.c.
References copy_v3_v3(), MPoly::loopstart, SMikkTSpaceContext::m_pUserData, BKEMeshToTangent::mpolys, and BKEMeshToTangent::tangents.
Referenced by BKE_mesh_calc_loop_tangent_single_ex().