44 bool orco_allocated =
false;
57 if (tan_layers & (1 << i)) {
62 BLI_snprintf(attr_name,
sizeof(attr_name),
"t%s", attr_safe_name);
76 if (use_orco_tan && orco ==
nullptr) {
78 orco_allocated =
true;
101 if (tan_len != 0 || use_orco_tan) {
102 short tangent_mask = 0;
103 bool calc_active_tangent =
false;
141 BLI_snprintf(attr_name,
sizeof(*attr_name),
"t%s", attr_safe_name);
147 if (orco_allocated) {
152 if (
format->attr_len == 0) {
158 *r_use_orco_tan = use_orco_tan;
160 *r_tan_len = tan_len;
193 for (
int i = 0; i < tan_len; i++) {
194 const char *name = tangent_names[i];
197 for (
int ml_index = 0; ml_index < mr->
loop_len; ml_index++) {
199 (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? SHRT_MAX : SHRT_MIN;
205 for (
int ml_index = 0; ml_index < mr->
loop_len; ml_index++) {
207 (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? SHRT_MAX : SHRT_MIN;
214 for (
int i = 0; i < tan_len; i++) {
215 const char *name = tangent_names[i];
218 for (
int ml_index = 0; ml_index < mr->
loop_len; ml_index++) {
220 tan_data->
w = (layer_data[ml_index][3] > 0.0f) ? 1 : -2;
226 for (
int ml_index = 0; ml_index < mr->
loop_len; ml_index++) {
228 tan_data->
w = (layer_data[ml_index][3] > 0.0f) ? 1 : -2;
249 if (
format.attr_len == 0) {
290 int pack_layer_index = 0;
291 for (
int i = 0; i < tan_len; i++) {
293 const char *name = tangent_names[i];
296 for (
int ml_index = 0; ml_index < mr->
loop_len; ml_index++) {
298 (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? 1.0f : -1.0f;
305 const int dst_offset = (int)subdiv_cache->
num_subdiv_loops * 4 * pack_layer_index++;
311 for (
int ml_index = 0; ml_index < mr->
loop_len; ml_index++) {
313 (*tan_data)[3] = (layer_data[ml_index][3] > 0.0f) ? 1.0f : -1.0f;
320 const int dst_offset = (int)subdiv_cache->
num_subdiv_loops * 4 * pack_layer_index++;
typedef float(TangentPoint)[2]
void CustomData_free(struct CustomData *data, int totelem)
const char * CustomData_get_layer_name(const struct CustomData *data, int type, int n)
int CustomData_get_active_layer(const struct CustomData *data, int type)
void * CustomData_get_layer_named(const struct CustomData *data, int type, const char *name)
void * CustomData_get_layer_n(const struct CustomData *data, int type, int n)
int CustomData_get_layer_index(const struct CustomData *data, int type)
void * CustomData_get_layer(const struct CustomData *data, int type)
void CustomData_reset(struct CustomData *data)
int CustomData_get_render_layer(const struct CustomData *data, int type)
void BKE_editmesh_loop_tangent_calc(BMEditMesh *em, bool calc_active_tangent, const char(*tangent_names)[MAX_NAME], int tangent_names_len, const float(*poly_normals)[3], const float(*loop_normals)[3], const float(*vert_orco)[3], CustomData *dm_loopdata_out, uint dm_loopdata_out_len, short *tangent_mask_curr_p)
void BKE_mesh_orco_verts_transform(struct Mesh *me, float(*orco)[3], int totvert, int invert)
void BKE_mesh_calc_loop_tangent_ex(const struct MVert *mvert, const struct MPoly *mpoly, uint mpoly_len, const struct MLoop *mloop, const struct MLoopTri *looptri, uint looptri_len, struct CustomData *loopdata, bool calc_active_tangent, const char(*tangent_names)[64], int tangent_names_len, const float(*vert_normals)[3], const float(*poly_normals)[3], const float(*loop_normals)[3], const float(*vert_orco)[3], struct CustomData *loopdata_out, uint loopdata_out_len, short *tangent_mask_curr_p)
MINLINE void normal_float_to_short_v3(short r[3], const float n[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define MAX_CUSTOMDATA_LAYER_NAME
void GPU_vertbuf_discard(GPUVertBuf *)
struct GPUVertBuf GPUVertBuf
GPUVertBuf * GPU_vertbuf_calloc(void)
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
void GPU_vertbuf_init_with_format_ex(GPUVertBuf *, const GPUVertFormat *, GPUUsageType)
#define GPU_vertbuf_init_with_format(verts, format)
void * GPU_vertbuf_get_data(const GPUVertBuf *verts)
void GPU_vertbuf_init_build_on_device(GPUVertBuf *verts, GPUVertFormat *format, uint v_len)
void GPU_vertbuf_tag_dirty(GPUVertBuf *verts)
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT BMesh * bm
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void draw_subdiv_interp_custom_data(const DRWSubdivCache *cache, GPUVertBuf *src_data, GPUVertBuf *dst_data, int dimensions, int dst_offset, bool compress_to_u16)
ccl_global float * buffer
void *(* MEM_mallocN)(size_t len, const char *str)
constexpr MeshExtract create_extractor_tan()
static GPUVertFormat * get_coarse_tan_format()
static void extract_tan_init_common(const MeshRenderData *mr, MeshBatchCache *cache, GPUVertFormat *format, GPUVertCompType comp_type, GPUVertFetchMode fetch_mode, CustomData *r_loop_data, int *r_v_len, int *r_tan_len, char r_tangent_names[MAX_MTFACE][MAX_CUSTOMDATA_LAYER_NAME], bool *r_use_orco_tan)
static void extract_tan_init_subdiv(const DRWSubdivCache *subdiv_cache, const MeshRenderData *mr, MeshBatchCache *cache, void *buffer, void *UNUSED(data))
constexpr MeshExtract create_extractor_tan_hq()
static void extract_tan_hq_init(const MeshRenderData *mr, MeshBatchCache *cache, void *buf, void *UNUSED(tls_data))
static void extract_tan_ex_init(const MeshRenderData *mr, MeshBatchCache *cache, GPUVertBuf *vbo, const bool do_hq)
static void extract_tan_init(const MeshRenderData *mr, MeshBatchCache *cache, void *buf, void *UNUSED(tls_data))
eMRExtractType extract_type
const float(* poly_normals)[3]
const float(* vert_normals)[3]