patch 21737 by Elia Sarti (vekoon)
Currently for ColorBands, when pressing the Add button, new elements are set with a medium gray in a medium position which often is not desired behaviour. This patch when possible sets new elements as averaged values between the current element and its preceding neighbour
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_texture.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
@@ -1438,6 +1439,33 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
|
||||
{
|
||||
ColorBand *coba= coba_v;
|
||||
|
||||
if(coba->tot > 0) {
|
||||
CBData *xnew, *x1, *x2;
|
||||
float col[4];
|
||||
|
||||
xnew= &coba->data[coba->tot];
|
||||
|
||||
if(coba->tot > 1) {
|
||||
if(coba->cur > 0) {
|
||||
x1= &coba->data[coba->cur-1];
|
||||
x2= &coba->data[coba->cur];
|
||||
}
|
||||
else {
|
||||
x1= &coba->data[coba->cur];
|
||||
x2= &coba->data[coba->cur+1];
|
||||
}
|
||||
|
||||
xnew->pos = x1->pos + ((x2->pos - x1->pos) / 2);
|
||||
}
|
||||
|
||||
do_colorband(coba, xnew->pos, col);
|
||||
|
||||
xnew->r= col[0];
|
||||
xnew->g= col[1];
|
||||
xnew->b= col[2];
|
||||
xnew->a= col[3];
|
||||
}
|
||||
|
||||
if(coba->tot < MAXCOLORBAND-1) coba->tot++;
|
||||
coba->cur= coba->tot-1;
|
||||
|
||||
|
Reference in New Issue
Block a user