Weight Paint: avoid creating very small values with locked weights.
When painting using Auto-Normalize or Lock Relative with some groups locked, the locked weights may not add up precisely to 1 because of precision limitations, which results in creating nonzero weights close to FLT_EPSILON. With Lock Relative display mode this is very obvious and annoying (random red points amid black or blue), so add an epsilon check to consider less than 1e-6 unlocked weight to be the same as 0. In addition, in cases when no weight can be painted due to locks, don't create vertex group entries at all if they don't exist yet. Also, don't run Auto Normalize when not painting a deform group. Differential Revision: https://developer.blender.org/D10000
This commit is contained in:
@@ -80,6 +80,9 @@ float BKE_defvert_multipaint_collective_weight(const struct MDeformVert *dv,
|
||||
int defbase_tot_sel,
|
||||
bool is_normalized);
|
||||
|
||||
/* This much unlocked weight is considered equivalent to none. */
|
||||
#define VERTEX_WEIGHT_LOCK_EPSILON 1e-6f
|
||||
|
||||
float BKE_defvert_calc_lock_relative_weight(float weight,
|
||||
float locked_weight,
|
||||
float unlocked_weight);
|
||||
|
||||
@@ -899,7 +899,7 @@ float BKE_defvert_calc_lock_relative_weight(float weight,
|
||||
}
|
||||
|
||||
/* handle division by zero */
|
||||
if (locked_weight >= 1.0f) {
|
||||
if (locked_weight >= 1.0f - VERTEX_WEIGHT_LOCK_EPSILON) {
|
||||
if (weight != 0.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user