Blender V4.5
mesh_tangent.cc File Reference
#include "MEM_guardedalloc.h"
#include "BLI_math_geom.h"
#include "BLI_math_vector.h"
#include "BLI_string.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "BKE_attribute.hh"
#include "BKE_customdata.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_tangent.hh"
#include "BKE_report.hh"
#include "mikktspace.hh"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Classes

struct  BKEMeshToTangent
struct  SGLSLMeshToTangent

Typedefs

using float2
using float3
using int3

Functions

Mesh Tangent Calculations (Single Layer)
void BKE_mesh_calc_loop_tangent_single_ex (const float(*vert_positions)[3], const int, const int *corner_verts, float(*r_looptangent)[4], const float(*corner_normals)[3], const float(*loop_uvs)[2], const int, const OffsetIndices< int > faces, 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_TRI_DETECT_QUADS
static void DM_calc_loop_tangents_thread (TaskPool *__restrict, void *taskdata)
void BKE_mesh_add_loop_tangent_named_layer_for_uv (const 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_CUSTOMDATA_LAYER_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 Span< float3 > vert_positions, const OffsetIndices< int > faces, const Span< int > corner_verts, const Span< int3 > corner_tris, const Span< int > corner_tri_faces, const Span< bool > sharp_faces, const CustomData *loopdata, bool calc_active_tangent, const char(*tangent_names)[MAX_CUSTOMDATA_LAYER_NAME], int tangent_names_len, const Span< float3 > vert_normals, const Span< float3 > face_normals, const Span< float3 > corner_normals, const Span< float3 > vert_orco, CustomData *loopdata_out, const uint loopdata_out_len, short *tangent_mask_curr_p)
void BKE_mesh_calc_loop_tangents (Mesh *mesh_eval, bool calc_active_tangent, const char(*tangent_names)[MAX_CUSTOMDATA_LAYER_NAME], int tangent_names_len)

Detailed Description

Functions to evaluate mesh tangents.

Definition in file mesh_tangent.cc.

Macro Definition Documentation

◆ USE_TRI_DETECT_QUADS

#define USE_TRI_DETECT_QUADS

Definition at line 156 of file mesh_tangent.cc.

Typedef Documentation

◆ float2

Definition at line 618 of file BLI_math_vector_types.hh.

◆ float3

Definition at line 619 of file BLI_math_vector_types.hh.

◆ int3

Definition at line 602 of file BLI_math_vector_types.hh.

Function Documentation

◆ BKE_mesh_add_loop_tangent_named_layer_for_uv()

void BKE_mesh_add_loop_tangent_named_layer_for_uv ( const CustomData * uv_data,
CustomData * tan_data,
int numLoopData,
const char * layer_name )

◆ BKE_mesh_calc_loop_tangent_ex()

void BKE_mesh_calc_loop_tangent_ex ( const Span< float3 > vert_positions,
const OffsetIndices< int > faces,
const Span< int > corner_verts,
const Span< int3 > corner_tris,
const Span< int > corner_tri_faces,
const Span< bool > sharp_faces,
const CustomData * loopdata,
bool calc_active_tangent,
const char(*) tangent_names[MAX_CUSTOMDATA_LAYER_NAME],
int tangent_names_len,
const Span< float3 > vert_normals,
const Span< float3 > face_normals,
const Span< float3 > corner_normals,
const Span< float3 > vert_orco,
CustomData * loopdata_out,
const uint loopdata_out_len,
short * tangent_mask_curr_p )

◆ BKE_mesh_calc_loop_tangent_single()

void BKE_mesh_calc_loop_tangent_single ( Mesh * mesh,
const char * uvmap,
float(*) r_looptangents[4],
ReportList * reports )

Wrapper around BKE_mesh_calc_loop_tangent_single_ex, which takes care of most boilerplate code.

Note
  • There must be a valid loop's CD_NORMALS available.
  • The mesh should be made of only triangles and quads!

Definition at line 116 of file mesh_tangent.cc.

References BKE_mesh_calc_loop_tangent_single_ex(), BKE_reportf(), CD_PROP_FLOAT2, blender::bke::Corner, CustomData_get_active_layer_name(), blender::Span< T >::data(), blender::Span< T >::is_empty(), blender::bke::AttributeAccessor::lookup(), reports, and RPT_ERROR.

◆ BKE_mesh_calc_loop_tangent_single_ex()

void BKE_mesh_calc_loop_tangent_single_ex ( const float(*) vert_positions[3],
const int ,
const int * corner_verts,
float(*) r_looptangent[4],
const float(*) corner_normals[3],
const float(*) loop_uvs[2],
const int ,
const OffsetIndices< int > faces,
ReportList * reports )

◆ BKE_mesh_calc_loop_tangent_step_0()

void BKE_mesh_calc_loop_tangent_step_0 ( const CustomData * loopData,
bool calc_active_tangent,
const char(*) tangent_names[MAX_CUSTOMDATA_LAYER_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 )

Here we get some useful information such as active uv layer name and search if it is already in tangent_names. Also, we calculate tangent_mask that works as a descriptor of tangents state. If tangent_mask has changed, then recalculate tangents.

Definition at line 326 of file mesh_tangent.cc.

References add(), BLI_strncpy(), CD_PROP_FLOAT2, CustomData_get_active_layer(), CustomData_get_layer_index(), CustomData_get_layer_name(), CustomData_get_render_layer(), CustomData_number_of_layers(), DM_TANGENT_MASK_ORCO, i, CustomData::layers, MAX_CUSTOMDATA_LAYER_NAME, CustomDataLayer::name, and STREQ.

Referenced by BKE_editmesh_loop_tangent_calc(), and BKE_mesh_calc_loop_tangent_ex().

◆ BKE_mesh_calc_loop_tangents()

void BKE_mesh_calc_loop_tangents ( Mesh * mesh_eval,
bool calc_active_tangent,
const char(*) tangent_names[MAX_CUSTOMDATA_LAYER_NAME],
int tangent_names_len )

◆ DM_calc_loop_tangents_thread()

void DM_calc_loop_tangents_thread ( TaskPool * __restrict,
void * taskdata )
static

Definition at line 306 of file mesh_tangent.cc.

Referenced by BKE_mesh_calc_loop_tangent_ex().