[Bf-blender-cvs] [ecf3d62] soc-2013-paint: Better fix for sampling adding new palette colors. Projective texture sampling was still buggy.
Antony Riakiotakis
noreply at git.blender.org
Wed Mar 12 21:31:21 CET 2014
Commit: ecf3d627989e24a8bbdd79267339761340842d53
Author: Antony Riakiotakis
Date: Wed Mar 12 22:31:06 2014 +0200
https://developer.blender.org/rBecf3d627989e24a8bbdd79267339761340842d53
Better fix for sampling adding new palette colors. Projective texture
sampling was still buggy.
===================================================================
M source/blender/editors/sculpt_paint/paint_image.c
M source/blender/editors/sculpt_paint/paint_intern.h
M source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 5f6cdb9..3c571af 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1254,7 +1254,7 @@ static int sample_color_exec(bContext *C, wmOperator *op)
RNA_int_get_array(op->ptr, "location", location);
use_palette = RNA_boolean_get(op->ptr, "palette");
- paint_sample_color(C, ar, location[0], location[1], mode == PAINT_TEXTURE_PROJECTIVE, use_palette, false);
+ paint_sample_color(C, ar, location[0], location[1], mode == PAINT_TEXTURE_PROJECTIVE, use_palette);
if (show_cursor) {
paint->flags |= PAINT_SHOW_BRUSH;
@@ -1290,7 +1290,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
WM_redraw_windows(C);
RNA_int_set_array(op->ptr, "location", event->mval);
- paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == PAINT_TEXTURE_PROJECTIVE, false, false);
+ paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == PAINT_TEXTURE_PROJECTIVE, false);
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
@@ -1326,7 +1326,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *ar = CTX_wm_region(C);
RNA_int_set_array(op->ptr, "location", event->mval);
- paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == PAINT_TEXTURE_PROJECTIVE, data->sample_palette, data->sample_palette);
+ paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == PAINT_TEXTURE_PROJECTIVE, false);
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
break;
}
@@ -1335,7 +1335,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
ARegion *ar = CTX_wm_region(C);
RNA_int_set_array(op->ptr, "location", event->mval);
- paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == PAINT_TEXTURE_PROJECTIVE, true, false);
+ paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == PAINT_TEXTURE_PROJECTIVE, true);
if (!data->sample_palette) {
data->sample_palette = true;
sample_color_update_header(data, C);
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index b33504f..c856f43 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -38,6 +38,7 @@ struct bglMats;
struct Brush;
struct ImagePool;
struct ListBase;
+struct Material;
struct Mesh;
struct MTex;
struct Object;
@@ -212,7 +213,7 @@ int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *
void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata);
-void paint_sample_color(bContext *C, struct ARegion *ar, int x, int y, bool texpaint_proj, bool palette, bool use_last);
+void paint_sample_color(bContext *C, struct ARegion *ar, int x, int y, bool texpaint_proj, bool palette);
void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
void PAINT_OT_face_select_linked(struct wmOperatorType *ot);
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 39ac7d1..0c2518a 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -390,10 +390,11 @@ void flip_v3_v3(float out[3], const float in[3], const char symm)
}
/* used for both 3d view and image window */
-void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_proj, bool use_palette, bool use_last)
+void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_proj, bool use_palette)
{
Paint *paint = BKE_paint_get_active_from_context(C);
Palette *palette = BKE_paint_palette(paint);
+ PaletteColor *color;
Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
unsigned int col;
unsigned char *cp;
@@ -401,11 +402,16 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
CLAMP(x, 0, ar->winx);
CLAMP(y, 0, ar->winy);
- if (use_palette && !palette) {
- palette = BKE_palette_add(CTX_data_main(C), "Palette");
- BKE_paint_palette_set(paint, palette);
+ if (use_palette) {
+ if (!palette) {
+ palette = BKE_palette_add(CTX_data_main(C), "Palette");
+ BKE_paint_palette_set(paint, palette);
+ }
+
+ color = BKE_palette_color_add(palette);
}
+
if (CTX_wm_view3d(C) && texpaint_proj) {
/* first try getting a colour directly from the mesh faces if possible */
Scene *scene = CTX_data_scene(C);
@@ -451,22 +457,18 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
float rgba_fp[4];
bilinear_interpolation_color_wrap(ibuf, NULL, rgba_fp, u, v);
straight_to_premul_v4(rgba_fp);
- if (use_palette) {
- PaletteColor *color = BKE_palette_color_add(palette);
+ if (use_palette)
linearrgb_to_srgb_v3_v3(color->rgb, rgba_fp);
- } else if (br) {
+ else if (br)
linearrgb_to_srgb_v3_v3(br->rgb, rgba_fp);
- }
}
else {
unsigned char rgba[4];
bilinear_interpolation_color_wrap(ibuf, rgba, NULL, u, v);
- if (use_palette) {
- PaletteColor *color = BKE_palette_color_add(palette);
+ if (use_palette)
rgb_uchar_to_float(color->rgb, rgba);
- } else if (br) {
+ else if (br)
rgb_uchar_to_float(br->rgb, rgba);
- }
}
}
@@ -489,16 +491,10 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
}
cp = (unsigned char *)&col;
- if (use_palette) {
- PaletteColor *color;
- if (use_last && !BKE_palette_is_empty(palette))
- color = BKE_palette_color_get_last(palette);
- else
- color = BKE_palette_color_add(palette);
+ if (use_palette)
rgb_uchar_to_float(color->rgb, cp);
- } else if (br) {
+ else if (br)
rgb_uchar_to_float(br->rgb, cp);
- }
}
static int brush_curve_preset_exec(bContext *C, wmOperator *op)
More information about the Bf-blender-cvs
mailing list