Fix T91838 Crash when toggling edit mode on object with geometry node modifier, but only if the instanced objects material has a normal map assigned.

This is only a workaround to avoid the crash. The underlying issue is left
unfixed.

New report for tracking the underlying issue is T93223.
This commit is contained in:
Clément Foucault
2021-11-19 19:24:22 +01:00
parent 1b686c60b5
commit 00e4d665f4

View File

@@ -54,11 +54,18 @@ static void extract_tan_ex_init(const MeshRenderData *mr,
uint32_t tan_layers = cache->cd_used.tan;
float(*orco)[3] = (float(*)[3])CustomData_get_layer(cd_vdata, CD_ORCO);
bool orco_allocated = false;
const bool use_orco_tan = cache->cd_used.tan_orco != 0;
bool use_orco_tan = cache->cd_used.tan_orco != 0;
int tan_len = 0;
char tangent_names[MAX_MTFACE][MAX_CUSTOMDATA_LAYER_NAME];
/* 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. */
if (tan_layers == 0 && use_orco_tan && CustomData_get_layer_index(cd_ldata, CD_MLOOPUV) != -1) {
tan_layers = 1;
use_orco_tan = false;
}
for (int i = 0; i < MAX_MTFACE; i++) {
if (tan_layers & (1 << i)) {
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];