+ def prepare_splat_weights(self, task):
+ if not self.splat_layers:
+ return
+
+ splat_weights = []
+ remainder = None
+ for s in self.splat_sources:
+ if s[0] is None:
+ splat_weights.append(remainder)
+ else:
+ index = s[1]
+ layer_values = [c[index] for c in s[0].colors]
+ if remainder:
+ splat_weights.append([v*r for v, r in zip(layer_values, remainder)])
+ remainder = [(1-v)*r for v, r in zip(layer_values, remainder)]
+ else:
+ splat_weights.append(layer_values)
+ remainder = [1-v for v in layer_values]
+
+ splat_weights = list(zip(*splat_weights))
+
+ for f in self.faces:
+ for i in f.loop_indices:
+ f.splat_mask |= sum(1<<j for j, w in enumerate(splat_weights[i]) if w>0)
+
+ self.split_vertices(self.find_splat_group, task)
+
+ for v in self.vertices:
+ if v.faces:
+ f = v.faces[0]
+ weights = splat_weights[f.get_loop_index(v)]
+ v.groups = [VertexGroup(i, w) for i, w in enumerate(weights) if (f.splat_mask>>i)&1]
+ else:
+ v.groups = []
+ while len(v.groups)<self.max_groups_per_vertex:
+ v.groups.append(VertexGroup(None))
+
+ def split_vertices(self, find_group_func, task, *args):