[Bf-blender-cvs] [c1f4e81] soc-2013-paint: merge with trunk

Antony Riakiotakis noreply at git.blender.org
Tue Apr 1 19:59:33 CEST 2014


Commit: c1f4e81fbb87cbe6c1a5da4b64435c75a96a1c38
Author: Antony Riakiotakis
Date:   Tue Apr 1 20:59:09 2014 +0300
https://developer.blender.org/rBc1f4e81fbb87cbe6c1a5da4b64435c75a96a1c38

merge with trunk

===================================================================



===================================================================

diff --cc source/blender/blenkernel/BKE_material.h
index ea54360,89d3107..2e2a349
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@@ -85,14 -83,9 +85,14 @@@ void assign_matarar(struct Object *ob, 
  
  short find_material_index(struct Object *ob, struct Material *ma);
  
- int object_add_material_slot(struct Object *ob);
- int object_remove_material_slot(struct Object *ob);
+ bool object_add_material_slot(struct Object *ob);
+ bool object_remove_material_slot(struct Object *ob);
  
 +bool get_mtex_slot_valid_texpaint(struct MTex *);
 +void refresh_texpaint_image_cache(struct Material *ma);
 +struct MTex *give_current_texpaint_slot(struct Material *ma);
 +void refresh_object_texpaint_images(struct Object*);
 +
  /* rna api */
  void BKE_material_resize_id(struct ID *id, short totcol, bool do_id_user);
  void BKE_material_append_id(struct ID *id, struct Material *ma);
diff --cc source/blender/blenkernel/intern/material.c
index d548cb1,01bbd1d..ac10a44
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@@ -1280,83 -1281,9 +1281,83 @@@ bool object_remove_material_slot(Objec
  		}
  	}
  
- 	return TRUE;
+ 	return true;
  }
  
 +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;
 +}
 +
 +void refresh_texpaint_image_cache(Material *ma)
 +{
 +	MTex **mtex, *validmtex = NULL;
 +
 +	short index = 0, i = 0;
 +
 +	if (!ma)
 +		return;
 +
 +	ma->texpaintima = NULL;
 +
 +	for(mtex = ma->mtex; i < MAX_MTEX; i++, mtex++) {
 +		if (get_mtex_slot_valid_texpaint(*mtex)) {
 +			if (index++ == ma->texactpaint) {
 +				ma->texpaintima = (*mtex)->tex->ima;
 +				return;
 +			}
 +
 +			validmtex = *mtex;
 +		}
 +	}
 +
 +	/* possible to not have selected anything as active texture. Just set to a valid index */
 +	if (index > 0) {
 +		ma->texactpaint = index;
 +		ma->texpaintima = validmtex->tex->ima;
 +	}
 +
 +	return;
 +}
 +
 +void refresh_object_texpaint_images(struct Object *ob)
 +{
 +	int i;
 +
 +	if (!ob)
 +		return;
 +
 +	for (i = 1; i < ob->totcol + 1; i++) {
 +		Material *ma = give_current_material(ob, i);
 +		refresh_texpaint_image_cache(ma);
 +	}
 +}
 +
 +/* no caching - slow, but not as useful as image */
 +struct MTex *give_current_texpaint_slot(Material *ma)
 +{
 +	MTex **mtex, *validmtex = NULL;
 +
 +	short index = 0, i = 0;
 +
 +	for(mtex = ma->mtex; i < MAX_MTEX; i++, mtex++) {
 +		if (get_mtex_slot_valid_texpaint(*mtex)) {
 +			if (index++ == ma->texactpaint)
 +				return (*mtex);
 +
 +			validmtex = *mtex;
 +		}
 +	}
 +
 +	/* possible to not have selected anything as active texture. Just set to a valid index */
 +	if (index > 0) {
 +		ma->texactpaint = index;
 +	}
 +
 +	return validmtex;
 +}
  
  /* r_col = current value, col = new value, (fac == 0) is no change */
  void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
diff --cc source/blender/editors/include/UI_interface.h
index 28522a6,2177b06..a08334e
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@@ -917,14 -909,7 +917,14 @@@ void uiItemMenuEnumO(uiLayout *layout, 
  void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon);
  
  /* UI Operators */
 +typedef struct uiDragColorHandle {
 +	float color[3];
 +	bool gamma_corrected;
 +} uiDragColorHandle;
 +
  void UI_buttons_operatortypes(void);
 +void UI_drop_color_copy(struct wmDrag *drag, struct wmDropBox *drop);
- int UI_drop_color_poll(struct bContext *C, struct wmDrag *drag, const struct wmEvent *event);
++bool UI_drop_color_poll(struct bContext *C, struct wmDrag *drag, const struct wmEvent *event);
  
  /* Helpers for Operators */
  uiBut *uiContextActiveButton(const struct bContext *C);
diff --cc source/blender/editors/interface/interface_ops.c
index fc3a3bd,4bbccec..ef020c0
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@@ -829,90 -827,6 +829,90 @@@ static void UI_OT_reloadtranslation(wmO
  	ot->exec = reloadtranslation_exec;
  }
  
- int UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
++bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
 +{
 +	/* should only return true for regions that include buttons, for now
 +	 * return true always */
 +	if (drag->type == WM_DRAG_COLOR){
 +		SpaceImage *sima = CTX_wm_space_image(C);
 +		ARegion *ar = CTX_wm_region(C);
 +
 +		if (UI_but_active_drop_color(C))
- 			return TRUE;
++			return true;
 +
 +		/* 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))
- 			return TRUE;
++			return true;
 +	}
 +
- 	return FALSE;
++	return false;
 +}
 +
 +void UI_drop_color_copy(wmDrag *drag, wmDropBox *drop)
 +{
 +	uiDragColorHandle *drag_info = (uiDragColorHandle *)drag->poin;
 +
 +	RNA_float_set_array(drop->ptr, "color", drag_info->color);
 +	RNA_boolean_set(drop->ptr, "gamma", drag_info->gamma_corrected);
 +}
 +
 +static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 +{
 +	ARegion *ar = CTX_wm_region(C);
 +	uiBut *but = NULL;
 +	float color[3];
 +	bool gamma;
 +
 +	RNA_float_get_array(op->ptr, "color", color);
 +	gamma = RNA_boolean_get(op->ptr, "gamma");
 +
 +	/* find button under mouse, check if it has RNA color property and
 +	 * if it does copy the data */
 +	but = ui_but_find_activated(ar);
 +
 +	if (but && but->type == COLOR && but->rnaprop) {
 +		if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
 +			if (!gamma)
 +				linearrgb_to_srgb_v3_v3(color, color);
 +			RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color);
 +			RNA_property_update(C, &but->rnapoin, but->rnaprop);
 +		}
 +		else if (RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
 +			if (gamma)
 +				srgb_to_linearrgb_v3_v3(color, color);
 +			RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color);
 +			RNA_property_update(C, &but->rnapoin, but->rnaprop);
 +		}
 +	}
 +	else {
 +		if(gamma)
 +			srgb_to_linearrgb_v3_v3(color, color);
 +
 +		paint_bucket_fill(C, color, op);
 +	}
 +
 +	ED_region_tag_redraw(ar);
 +
 +	return OPERATOR_FINISHED;
 +}
 +
 +
 +static void UI_OT_drop_color(wmOperatorType *ot)
 +{
 +	ot->name = "Drop Color";
 +	ot->idname = "UI_OT_drop_color";
 +	ot->description = "Drop colors to buttons";
 +
 +	ot->invoke = drop_color_invoke;
 +
 +	RNA_def_float_color(ot->srna, "color", 3, NULL, 0.0, FLT_MAX, "Color", "Source color", 0.0, 1.0);
 +	RNA_def_boolean(ot->srna, "gamma", 0, "Gamma Corrected", "The source color is gamma corrected ");
 +}
 +
 +
 +
  /* ********************************************************* */
  /* Registration */
  
diff --cc source/blender/editors/interface/interface_templates.c
index 903b764,a493751..51bc02f
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@@ -2314,56 -2312,6 +2314,56 @@@ void uiTemplateColorPicker(uiLayout *la
  	}
  }
  
 +/* This template now follows User Preference for type - name is not correct anymore... */
 +void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, int UNUSED(colors))
 +{
 +	PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 +	PointerRNA cptr;
 +	Palette *palette;
 +	PaletteColor *color;
 +	uiBlock *block;
 +	uiLayout *col;
 +	int row_cols = 0;
 +	int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1);
 +
 +	if (!prop) {
 +		RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
 +		return;
 +	}
 +
 +	cptr = RNA_property_pointer_get(ptr, prop);
 +	if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette))
 +		return;
 +
 +	block = uiLayoutGetBlock(layout);
 +
 +	palette = cptr.data;
 +	color = palette->colors.first;
 +
- 	col = uiLayoutColumn(layout, TRUE);
- 	uiLayoutRow(col, TRUE);
++	col = uiLayoutColumn(layout, true);
++	uiLayoutRow(col, true);
 +
 +	for (; color; color = color->next) {
 +		PointerRNA ptr;
 +
 +		if (row_cols >= cols_per_row) {
- 			uiLayoutRow(col, TRUE);
++			uiLayoutRow(col, true);
 +			row_cols = 0;
 +		}
 +
 +		RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &ptr);
 +		uiDefButR(block, COLOR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ptr, "color",
 +		          -1, 0.0, 1.0, UI_COLOR_PALETTE, 0.0, "");
 +
 +		row_cols++;
 +	}
 +
- 	col = uiLayoutColumn(layout, TRUE);
- 	uiLayoutRow(col, TRUE);
++	col = uiLayoutColumn(layout, true);
++	uiLayoutRow(col, true);
 +	uiDefIconButO(block, BUT, "PALETTE_OT_color_add", WM_OP_INVOKE_DEFAULT, ICON_PLUS, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
 +}
 +
 +
  /********************* Layer Buttons Template ************************/
  
  static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
diff --cc source/blender/editors/sculpt_paint/paint_cursor.c
index 609ff83,81177dd..c67c807
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@@ -44,8 -44,8 +44,9 @@@
  
  #include "BKE_brush.h"
  #include "BKE_context.h"
 +#include "BKE_curve.h"
  #include "BKE_image.h"
+ #include "BKE_node.h"
  #include "BKE_paint.h"
  #include "BKE_colortools.h"
  
diff --cc source/blender/editors/sculpt_paint/paint_image_proj.c
index 91d42fb,c6de574..a414866
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@@ -70,8 -67,8 +70,9 @@@
  #include "BKE_image.h"
  #include "BKE_library.h"
  #include "BKE_main.h"
 +#include "BKE_material.h"
  #include "BKE_mesh.h"
+ #include "BKE_mesh_mapping.h"
  #include "BKE_node.h"
  #include "BKE_object.h"
  #include "BKE_paint.h"
@@@ -946,9 -903,11 +940,11 @@@ static bool check_seam(const ProjPaintS
  
  			/* Only need to check if 'i2_fidx' is valid because we know i1_fidx is the same vert on both faces */
  			if (i2_fidx != -1) {
 -				Image *tpage = project_paint_face_image(ps, ps-

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list