Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc
| Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | static void extract_tan_init_common(const MeshRenderData *mr, | ||||
| float(*orco)[3] = (float(*)[3])CustomData_get_layer(cd_vdata, CD_ORCO); | float(*orco)[3] = (float(*)[3])CustomData_get_layer(cd_vdata, CD_ORCO); | ||||
| bool orco_allocated = false; | bool orco_allocated = false; | ||||
| bool use_orco_tan = cache->cd_used.tan_orco != 0; | bool use_orco_tan = cache->cd_used.tan_orco != 0; | ||||
| int tan_len = 0; | int tan_len = 0; | ||||
| /* FIXME(T91838): This is to avoid a crash when orco tangent was requested but there are valid | /* FIXME(T91838): This is to avoid a crash when orco tangent was requested but there are valid | ||||
| * uv layers. It would be better to fix the root cause. */ | * uv layers. It would be better to fix the root cause. */ | ||||
| if (tan_layers == 0 && use_orco_tan && CustomData_get_layer_index(cd_ldata, CD_MLOOPUV) != -1) { | if (tan_layers == 0 && use_orco_tan && | ||||
| CustomData_get_layer_index(cd_ldata, CD_PROP_FLOAT2) != -1) { | |||||
| tan_layers = 1; | tan_layers = 1; | ||||
| use_orco_tan = false; | use_orco_tan = false; | ||||
| } | } | ||||
| for (int i = 0; i < MAX_MTFACE; i++) { | for (int i = 0; i < MAX_MTFACE; i++) { | ||||
| if (tan_layers & (1 << i)) { | if (tan_layers & (1 << i)) { | ||||
| char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; | char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; | ||||
| const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i); | const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_PROP_FLOAT2, i); | ||||
| GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); | GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); | ||||
| /* Tangent layer name. */ | /* Tangent layer name. */ | ||||
| BLI_snprintf(attr_name, sizeof(attr_name), "t%s", attr_safe_name); | BLI_snprintf(attr_name, sizeof(attr_name), "t%s", attr_safe_name); | ||||
| GPU_vertformat_attr_add(format, attr_name, comp_type, 4, fetch_mode); | GPU_vertformat_attr_add(format, attr_name, comp_type, 4, fetch_mode); | ||||
| /* Active render layer name. */ | /* Active render layer name. */ | ||||
| if (i == CustomData_get_render_layer(cd_ldata, CD_MLOOPUV)) { | if (i == CustomData_get_render_layer(cd_ldata, CD_PROP_FLOAT2)) { | ||||
| GPU_vertformat_alias_add(format, "t"); | GPU_vertformat_alias_add(format, "t"); | ||||
| } | } | ||||
| /* Active display layer name. */ | /* Active display layer name. */ | ||||
| if (i == CustomData_get_active_layer(cd_ldata, CD_MLOOPUV)) { | if (i == CustomData_get_active_layer(cd_ldata, CD_PROP_FLOAT2)) { | ||||
| GPU_vertformat_alias_add(format, "at"); | GPU_vertformat_alias_add(format, "at"); | ||||
| } | } | ||||
| BLI_strncpy(r_tangent_names[tan_len++], layer_name, MAX_CUSTOMDATA_LAYER_NAME); | BLI_strncpy(r_tangent_names[tan_len++], layer_name, MAX_CUSTOMDATA_LAYER_NAME); | ||||
| } | } | ||||
| } | } | ||||
| if (use_orco_tan && orco == nullptr) { | if (use_orco_tan && orco == nullptr) { | ||||
| /* If `orco` is not available compute it ourselves */ | /* If `orco` is not available compute it ourselves */ | ||||
| ▲ Show 20 Lines • Show All 295 Lines • Show Last 20 Lines | |||||