Cleanup: BLI: Remove Span::get method
Unlike to `lookup_or_default` accessor methods of `Map` or attribute provider class, `Span::get` is not so explicit and self described to be used with default value. Other one issue was is that result is by value. But this is not the main reason to delete this method. And although this can be fixed by reference, this is still not such good to just have method to check index and return something. Pull Request: https://projects.blender.org/blender/blender/pulls/122425
This commit is contained in:
committed by
Jacques Lucke
parent
c7635fa200
commit
bea8825446
@@ -330,18 +330,6 @@ template<typename T> class Span {
|
||||
return data_[size_ - 1 - n];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the element at the given index. If the index is out of range, return the fallback
|
||||
* value.
|
||||
*/
|
||||
constexpr T get(int64_t index, const T &fallback) const
|
||||
{
|
||||
if (index < size_ && index >= 0) {
|
||||
return data_[index];
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the array contains duplicates. Does a linear search for every element. So the total
|
||||
* running time is O(n^2). Only use this for small arrays.
|
||||
|
||||
@@ -101,8 +101,7 @@ static void compute_vertex_mask__armature_mode(const MDeformVert *dvert,
|
||||
bool bone_for_group_exists = pchan && pchan->bone && (pchan->bone->flag & BONE_SELECTED);
|
||||
selected_bone_uses_group.append(bone_for_group_exists);
|
||||
}
|
||||
|
||||
Span<bool> use_vertex_group = selected_bone_uses_group;
|
||||
const int64_t total_size = selected_bone_uses_group.size();
|
||||
|
||||
for (int i : r_vertex_mask.index_range()) {
|
||||
Span<MDeformWeight> weights(dvert[i].dw, dvert[i].totweight);
|
||||
@@ -110,7 +109,11 @@ static void compute_vertex_mask__armature_mode(const MDeformVert *dvert,
|
||||
|
||||
/* check the groups that vertex is assigned to, and see if it was any use */
|
||||
for (const MDeformWeight &dw : weights) {
|
||||
if (use_vertex_group.get(dw.def_nr, false)) {
|
||||
if (dw.def_nr >= total_size) {
|
||||
continue;
|
||||
}
|
||||
BLI_assert(dw.def_nr >= 0);
|
||||
if (selected_bone_uses_group[dw.def_nr]) {
|
||||
if (dw.weight > threshold) {
|
||||
r_vertex_mask[i] = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user