- if tangent_layer_index>=0:
- prog_count += 1
- progress.push_task_slice("Computing tangents", 0, prog_count)
- self.split_vertices(self.find_uv_group, progress, tangent_layer_index)
- progress.set_task_slice(self.tangent_uvtex, 1, prog_count)
- self.compute_tangents(tangent_layer_index, progress)
- progress.pop_task()
- prog_step = 2
- else:
- raise Exception("Tangent UV layer not found")
+ if tangent_layer_index<0:
+ raise Exception("Invalid configuration on mesh {}: No tangent UV layer".format(self.name))
+
+ prog_count = len(self.uv_layers)
+ if tangent_layer_index>=0:
+ prog_count += 1
+ task.set_slices(prog_count)
+
+ if tangent_layer_index>=0:
+ subtask = task.next_slice("Computing tangents")
+ self.split_vertices(self.find_uv_group, subtask, tangent_layer_index)
+ subtask = task.next_slice(self.tangent_uvtex)
+ self.compute_tangents(tangent_layer_index, subtask)