[Bf-blender-cvs] [5f2b572] soc-2013-paint: Code cleanup: style and float<>double promotion
Campbell Barton
noreply at git.blender.org
Mon Jun 23 09:41:15 CEST 2014
Commit: 5f2b57206f2f0b1d587f1c33fbb3bc9a4ca16df8
Author: Campbell Barton
Date: Mon Jun 23 17:40:39 2014 +1000
https://developer.blender.org/rB5f2b57206f2f0b1d587f1c33fbb3bc9a4ca16df8
Code cleanup: style and float<>double promotion
===================================================================
M source/blender/blenkernel/BKE_material.h
M source/blender/blenkernel/intern/brush.c
M source/blender/blenkernel/intern/material.c
M source/blender/blenkernel/intern/paint.c
M source/blender/blenlib/intern/math_color_blend_inline.c
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/interface/interface_ops.c
M source/blender/editors/sculpt_paint/paint_cursor.c
M source/blender/editors/sculpt_paint/paint_curve.c
M source/blender/editors/sculpt_paint/paint_image.c
M source/blender/editors/sculpt_paint/paint_image_2d.c
M source/blender/editors/sculpt_paint/paint_image_proj.c
M source/blender/editors/sculpt_paint/paint_intern.h
M source/blender/editors/sculpt_paint/paint_ops.c
M source/blender/editors/sculpt_paint/paint_stroke.c
M source/blender/editors/sculpt_paint/paint_undo.c
M source/blender/editors/sculpt_paint/paint_utils.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/space_view3d/drawmesh.c
M source/blender/editors/space_view3d/space_view3d.c
M source/blender/editors/transform/transform.c
M source/blender/editors/transform/transform_constraints.c
M source/blender/imbuf/IMB_imbuf.h
M source/blender/imbuf/intern/rectop.c
M source/blender/makesrna/intern/rna_sculpt_paint.c
M source/blender/windowmanager/intern/wm_dragdrop.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index 17ef89b..723bae2 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -91,7 +91,7 @@ bool object_remove_material_slot(struct Object *ob);
bool get_mtex_slot_valid_texpaint(struct MTex *);
void refresh_texpaint_image_cache(struct Material *ma, bool use_nodes);
struct MTex *give_current_texpaint_slot(struct Material *ma);
-void refresh_object_texpaint_images(struct Object*, bool use_nodes);
+void refresh_object_texpaint_images(struct Object *ob, bool use_nodes);
/* rna api */
void BKE_material_resize_id(struct ID *id, short totcol, bool do_id_user);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 9454ab0..2e1ce95 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -756,14 +756,14 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br,
rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool);
}
- CLAMP(intensity, 0.0, 1.0);
+ CLAMP(intensity, 0.0f, 1.0f);
- switch(br->mask_pressure) {
+ switch (br->mask_pressure) {
case BRUSH_MASK_PRESSURE_CUTOFF:
- intensity = ((1.0 - intensity) < ups->size_pressure_value)? 1.0 : 0.0;
+ intensity = ((1.0f - intensity) < ups->size_pressure_value) ? 1.0f : 0.0f;
break;
case BRUSH_MASK_PRESSURE_RAMP:
- intensity = ups->size_pressure_value + intensity * (1.0 - ups->size_pressure_value);
+ intensity = ups->size_pressure_value + intensity * (1.0f - ups->size_pressure_value);
break;
default:
break;
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 451e04a..5b32c01 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1308,9 +1308,9 @@ bool object_remove_material_slot(Object *ob)
bool get_mtex_slot_valid_texpaint(struct MTex *mtex)
{
- return mtex && (mtex->texco == TEXCO_UV) &&
- mtex->tex && (mtex->tex->type == TEX_IMAGE) &&
- mtex->tex->ima;
+ return (mtex && (mtex->texco == TEXCO_UV) &&
+ mtex->tex && (mtex->tex->type == TEX_IMAGE) &&
+ mtex->tex->ima);
}
@@ -1359,7 +1359,7 @@ void refresh_texpaint_image_cache(Material *ma, bool use_nodes)
}
}
else {
- for(mtex = ma->mtex, i = 0; i < MAX_MTEX; i++, mtex++) {
+ for (mtex = ma->mtex, i = 0; i < MAX_MTEX; i++, mtex++) {
if (get_mtex_slot_valid_texpaint(*mtex)) {
count++;
}
@@ -1374,7 +1374,7 @@ void refresh_texpaint_image_cache(Material *ma, bool use_nodes)
ma->texpaintslot = MEM_callocN(sizeof(*ma->texpaintslot) * count, "texpaint_slots");
- for(mtex = ma->mtex, i = 0; i < MAX_MTEX; i++, mtex++) {
+ for (mtex = ma->mtex, i = 0; i < MAX_MTEX; i++, mtex++) {
if (get_mtex_slot_valid_texpaint(*mtex)) {
ma->texpaintslot[index].ima = (*mtex)->tex->ima;
BLI_strncpy(ma->texpaintslot[index++].uvname, (*mtex)->uvname, 64);
@@ -1413,7 +1413,7 @@ struct MTex *give_current_texpaint_slot(Material *ma)
short index = 0, i = 0;
- for(mtex = ma->mtex; i < MAX_MTEX; i++, mtex++) {
+ for (mtex = ma->mtex; i < MAX_MTEX; i++, mtex++) {
if (get_mtex_slot_valid_texpaint(*mtex)) {
if (index++ == ma->paint_active_slot)
return (*mtex);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 47bf92b..f943aa5 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -338,7 +338,8 @@ Palette *BKE_palette_add(Main *bmain, const char *name)
return palette;
}
-void BKE_free_palette (Palette *palette) {
+void BKE_free_palette (Palette *palette)
+{
BLI_freelistN(&palette->colors);
}
diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c
index 2a01afa..9613132 100644
--- a/source/blender/blenlib/intern/math_color_blend_inline.c
+++ b/source/blender/blenlib/intern/math_color_blend_inline.c
@@ -35,6 +35,10 @@
#ifndef __MATH_COLOR_BLEND_INLINE_C__
#define __MATH_COLOR_BLEND_INLINE_C__
+/* don't add any saturation to a completly black and white image */
+#define EPS_SATURATION 0.0005f
+#define EPS_ALPHA 0.0005f
+
/***************************** Color Blending ********************************
*
* - byte colors are assumed to be straight alpha
@@ -779,8 +783,9 @@ MINLINE void blend_color_saturation_byte(unsigned char dst[4], unsigned const ch
rgb_to_hsv(src1[0] / 255.0f, src1[1] / 255.0f, src1[2] / 255.0f, &h1, &s1, &v1);
rgb_to_hsv(src2[0] / 255.0f, src2[1] / 255.0f, src2[2] / 255.0f, &h2, &s2, &v2);
- if (s1 > 0.0005) // don't add any saturation to a completly black and white image
+ if (s1 > EPS_SATURATION) {
s1 = s2;
+ }
hsv_to_rgb(h1, s1, v1, &r, &g, &b);
@@ -983,8 +988,9 @@ MINLINE void blend_color_erase_alpha_float(float dst[4], const float src1[4], co
float alpha = max_ff(src1[3] - src2[3], 0.0f);
float map_alpha;
- if (alpha <= 0.0005f)
+ if (alpha <= EPS_ALPHA) {
alpha = 0.0f;
+ }
map_alpha = alpha / src1[3];
@@ -1009,8 +1015,9 @@ MINLINE void blend_color_add_alpha_float(float dst[4], const float src1[4], cons
float alpha = min_ff(src1[3] + src2[3], 1.0f);
float map_alpha;
- if (alpha >= 1.0f - 0.0005f)
+ if (alpha >= 1.0f - EPS_ALPHA) {
alpha = 1.0f;
+ }
map_alpha = (src1[3] > 0.0f) ? alpha / src1[3] : 1.0f;
@@ -1562,8 +1569,9 @@ MINLINE void blend_color_saturation_float(float dst[3], const float src1[3], con
rgb_to_hsv(src1[0], src1[1], src1[2], &h1, &s1, &v1);
rgb_to_hsv(src2[0], src2[1], src2[2], &h2, &s2, &v2);
- if (s1 > 0.0005) // don't add any saturation to a completly black and white image
+ if (s1 > EPS_SATURATION) {
s1 = s2;
+ }
hsv_to_rgb(h1, s1, v1, &r, &g, &b);
dst[0] = (r * fac + src1[0] * mfac);
@@ -1619,4 +1627,6 @@ MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], co
dst[3] = mt * src1[3] + t * src2[3];
}
+#undef EPS_SATURATION
+
#endif /* __MATH_COLOR_BLEND_INLINE_C__ */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index acda6ef..6d556ad 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1252,14 +1252,17 @@ static bool ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data,
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, drag_info->color);
drag_info->gamma_corrected = true;
valid = true;
- } else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
+ }
+ else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, drag_info->color);
drag_info->gamma_corrected = false;
valid = true;
- } else if (but->pointype == UI_BUT_POIN_FLOAT) {
+ }
+ else if (but->pointype == UI_BUT_POIN_FLOAT) {
copy_v3_v3(drag_info->color, (float *)but->poin);
valid = true;
- } else if (but->pointype == UI_BUT_POIN_CHAR) {
+ }
+ else if (but->pointype == UI_BUT_POIN_CHAR) {
rgba_uchar_to_float(drag_info->color, (unsigned char *)but->poin);
valid = true;
}
@@ -4083,8 +4086,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
}
}
#ifdef USE_DRAG_TOGGLE
- if (event->type == LEFTMOUSE && event->val == KM_PRESS
- && (ui_is_but_drag_toggle(but)))
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS && (ui_is_but_drag_toggle(but)))
{
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
@@ -4249,8 +4251,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
}
}
#ifdef USE_DRAG_TOGGLE
- if (event->type == LEFTMOUSE && event->val == KM_PRESS)
- {
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
data->dragstarty = event->y;
@@ -4326,7 +4327,8 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color);
srgb_to_linearrgb_v3_v3(target, color);
- } else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
+ }
+ else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, target);
}
}
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 7df54a5..7279163 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -814,7 +814,7 @@ int UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(e
{
/* should only return true for regions that include buttons, for now
* return true always */
- if (drag->type == WM_DRAG_COLOR){
+ if (drag->type == WM_DRAG_COLOR) {
SpaceImage *sima = CTX_wm_space_image(C);
ARegion *ar = CTX_wm_region(C);
@@ -823,9 +823,11 @@ int UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(e
/* should only return true for regions that include buttons, for now
* return true always */
- if (sima && (sima->mode == SI_MODE_PAINT)
- && sima->image && (ar && ar->regiontype == RGN_TYPE_WINDOW))
+ if (sima && (sima->mode == SI_MODE_PAINT) &&
+ sima->image && (ar && ar->regiontype == RGN_TYPE_WINDOW))
+ {
return 1;
+ }
}
return 0;
@@ -868,8 +870,9 @@ static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
}
}
else {
- if(gamma)
+ if (gamma) {
srgb_to_linearrgb_v3_v3(color, color);
+ }
paint_bucket_fill(C, color, op);
}
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 7c71636..44d
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list