[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55081] trunk/blender: Texture paint refactoring commit

Antony Riakiotakis kalast at gmail.com
Wed Mar 6 20:54:43 CET 2013


Revision: 55081
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55081
Author:   psy-fi
Date:     2013-03-06 19:54:43 +0000 (Wed, 06 Mar 2013)
Log Message:
-----------
Texture paint refactoring commit

Adding new file paint_image_proj.c which includes the projective texture painting part of texture
painting, using the stroke system. To access the new code path use Shift-LClick.
The new code path still is problematic with tablet pressure and I will be looking
into ways to unify this across paint systems next.

The old code is still present and can be accessed by regular Lclick as usual.

Also removed 3D (non-projective) painting from 3D viewport.

TODO:
* Add pressure influence code to stroke, remove from every other paint
system code, including texpaint.
* Put UnifiedPaintSettings update in PaintStroke code.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    trunk/blender/source/blender/editors/sculpt_paint/CMakeLists.txt
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
    trunk/blender/source/blender/editors/sculpt_paint/paint_ops.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/makesdna/DNA_scene_types.h
    trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c

Added Paths:
-----------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-03-06 18:17:01 UTC (rev 55080)
+++ trunk/blender/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-03-06 19:54:43 UTC (rev 55081)
@@ -1114,11 +1114,6 @@
         brush = context.tool_settings.image_paint.brush
         return (brush is not None)
 
-    def draw_header(self, context):
-        ipaint = context.tool_settings.image_paint
-
-        self.layout.prop(ipaint, "use_projection", text="")
-
     def draw(self, context):
         layout = self.layout
 
@@ -1127,15 +1122,12 @@
         toolsettings = context.tool_settings
         ipaint = toolsettings.image_paint
         settings = toolsettings.image_paint
-        use_projection = ipaint.use_projection
 
         col = layout.column()
-        col.active = use_projection
         col.prop(ipaint, "use_occlude")
         col.prop(ipaint, "use_backface_culling")
 
         row = layout.row()
-        row.active = (use_projection)
         row.prop(ipaint, "use_normal_falloff")
 
         sub = row.row()
@@ -1144,7 +1136,6 @@
 
         split = layout.split()
 
-        split.active = (use_projection)
         split.prop(ipaint, "use_stencil_layer", text="Stencil")
 
         row = split.row()

Modified: trunk/blender/source/blender/editors/sculpt_paint/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/CMakeLists.txt	2013-03-06 18:17:01 UTC (rev 55080)
+++ trunk/blender/source/blender/editors/sculpt_paint/CMakeLists.txt	2013-03-06 19:54:43 UTC (rev 55081)
@@ -43,6 +43,7 @@
 	paint_hide.c
 	paint_image.c
 	paint_image_2d.c
+	paint_image_proj.c
 	paint_mask.c
 	paint_ops.c
 	paint_stroke.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-06 18:17:01 UTC (rev 55080)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-06 19:54:43 UTC (rev 55081)
@@ -4956,8 +4956,6 @@
 
 	ViewContext vc;
 	wmTimer *timer;
-
-	short restore_projection;
 } PaintOperation;
 
 static void paint_redraw(bContext *C, ImagePaintState *s, int texpaint, int final)
@@ -5069,12 +5067,7 @@
 
 	/* initialize from context */
 	if (CTX_wm_region_view3d(C)) {
-		pop->mode = PAINT_MODE_3D;
-
-		if (!(settings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE))
-			pop->mode = PAINT_MODE_3D_PROJECT;
-		else
-			view3d_set_viewcontext(C, &pop->vc);
+		pop->mode = PAINT_MODE_3D_PROJECT;
 	}
 	else {
 		pop->s.sima = CTX_wm_space_image(C);
@@ -5239,9 +5232,6 @@
 	if (pop->timer)
 		WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), pop->timer);
 
-	if (pop->restore_projection)
-		settings->imapaint.flag &= ~IMAGEPAINT_PROJECT_DISABLE;
-
 	settings->imapaint.flag &= ~IMAGEPAINT_DRAWING;
 	imapaint_canvas_free(&pop->s);
 	BKE_brush_painter_free(pop->painter);
@@ -5259,10 +5249,10 @@
 		if (pop->s.dm_release)
 			pop->s.dm->release(pop->s.dm);
 	}
-	
+
 	paint_redraw(C, &pop->s, pop->mode == PAINT_MODE_3D, 1);
 	undo_paint_push_end(UNDO_PAINT_IMAGE);
-	
+
 	if (pop->s.warnmultifile)
 		BKE_reportf(op->reports, RPT_WARNING, "Image requires 4 color channels to paint: %s", pop->s.warnmultifile);
 	if (pop->s.warnpackedfile)

Copied: trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c (from rev 55078, trunk/blender/source/blender/editors/sculpt_paint/paint_image.c)
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	                        (rev 0)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-03-06 19:54:43 UTC (rev 55081)
@@ -0,0 +1,5187 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: some of this file.
+ *
+ * Contributor(s): Jens Ole Wund (bjornmose), Campbell Barton (ideasman42)
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/sculpt_paint/paint_image.c
+ *  \ingroup edsculpt
+ *  \brief Functions to paint images in 2D and 3D.
+ */
+
+#include <float.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "MEM_guardedalloc.h"
+
+#ifdef WIN32
+#  include "BLI_winstuff.h"
+#endif
+
+#include "BLI_math.h"
+#include "BLI_blenlib.h"
+#include "BLI_linklist.h"
+#include "BLI_memarena.h"
+#include "BLI_threads.h"
+#include "BLI_utildefines.h"
+
+#include "PIL_time.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_node_types.h"
+#include "DNA_object_types.h"
+
+#include "BKE_camera.h"
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_idprop.h"
+#include "BKE_brush.h"
+#include "BKE_image.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_mesh.h"
+#include "BKE_node.h"
+#include "BKE_object.h"
+#include "BKE_paint.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
+#include "BKE_colortools.h"
+
+#include "BKE_tessmesh.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "UI_view2d.h"
+
+#include "ED_image.h"
+#include "ED_screen.h"
+#include "ED_sculpt.h"
+#include "ED_uvedit.h"
+#include "ED_view3d.h"
+#include "ED_mesh.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "GPU_draw.h"
+
+#include "IMB_colormanagement.h"
+
+#include "paint_intern.h"
+
+/* Defines and Structs */
+/* FTOCHAR as inline function */
+BLI_INLINE unsigned char f_to_char(const float val)
+{
+	return FTOCHAR(val);
+}
+
+
+#define IMAPAINT_CHAR_TO_FLOAT(c) ((c) / 255.0f)
+
+#define IMAPAINT_FLOAT_RGB_TO_CHAR(c, f)  {                                   \
+	(c)[0] = f_to_char((f)[0]);                                               \
+	(c)[1] = f_to_char((f)[1]);                                               \
+	(c)[2] = f_to_char((f)[2]);                                               \
+} (void)0
+#define IMAPAINT_FLOAT_RGBA_TO_CHAR(c, f)  {                                  \
+	(c)[0] = f_to_char((f)[0]);                                               \
+	(c)[1] = f_to_char((f)[1]);                                               \
+	(c)[2] = f_to_char((f)[2]);                                               \
+	(c)[3] = f_to_char((f)[3]);                                               \
+} (void)0
+#define IMAPAINT_CHAR_RGB_TO_FLOAT(f, c)  {                                   \
+	(f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]);                                   \
+	(f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]);                                   \
+	(f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]);                                   \
+} (void)0
+#define IMAPAINT_CHAR_RGBA_TO_FLOAT(f, c)  {                                  \
+	(f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]);                                   \
+	(f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]);                                   \
+	(f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]);                                   \
+	(f)[3] = IMAPAINT_CHAR_TO_FLOAT((c)[3]);                                   \
+} (void)0
+
+#define IMAPAINT_FLOAT_RGB_COPY(a, b) copy_v3_v3(a, b)
+
+#define IMAPAINT_TILE_BITS          6
+#define IMAPAINT_TILE_SIZE          (1 << IMAPAINT_TILE_BITS)
+#define IMAPAINT_TILE_NUMBER(size)  (((size) + IMAPAINT_TILE_SIZE - 1) >> IMAPAINT_TILE_BITS)
+
+static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint);
+
+
+typedef struct ImagePaintState {
+	SpaceImage *sima;
+	View2D *v2d;
+	Scene *scene;
+	bScreen *screen;
+
+	Brush *brush;
+	short tool, blend;
+	Image *image;
+	ImBuf *canvas;
+	ImBuf *clonecanvas;
+	char *warnpackedfile;
+	char *warnmultifile;
+
+	/* viewport texture paint only, but _not_ project paint */
+	Object *ob;
+	int faceindex;
+	float uv[2];
+	int do_facesel;
+
+	DerivedMesh    *dm;
+	int             dm_totface;
+	int             dm_release;
+
+	MFace          *dm_mface;
+	MTFace         *dm_mtface;
+} ImagePaintState;
+
+typedef struct ImagePaintPartialRedraw {
+	int x1, y1, x2, y2;  /* XXX, could use 'rcti' */
+	int enabled;
+} ImagePaintPartialRedraw;
+
+typedef struct ImagePaintRegion {
+	int destx, desty;
+	int srcx, srcy;
+	int width, height;
+} ImagePaintRegion;
+
+/* ProjectionPaint defines */
+
+/* approx the number of buckets to have under the brush,
+ * used with the brush size to set the ps->buckets_x and ps->buckets_y value.
+ *
+ * When 3 - a brush should have ~9 buckets under it at once
+ * ...this helps for threading while painting as well as
+ * avoiding initializing pixels that wont touch the brush */
+#define PROJ_BUCKET_BRUSH_DIV 4
+
+#define PROJ_BUCKET_RECT_MIN 4
+#define PROJ_BUCKET_RECT_MAX 256
+
+#define PROJ_BOUNDBOX_DIV 8
+#define PROJ_BOUNDBOX_SQUARED  (PROJ_BOUNDBOX_DIV * PROJ_BOUNDBOX_DIV)
+
+//#define PROJ_DEBUG_PAINT 1
+//#define PROJ_DEBUG_NOSEAMBLEED 1
+//#define PROJ_DEBUG_PRINT_CLIP 1
+#define PROJ_DEBUG_WINCLIP 1
+
+/* projectFaceSeamFlags options */
+//#define PROJ_FACE_IGNORE	(1<<0)	/* When the face is hidden, backfacing or occluded */
+//#define PROJ_FACE_INIT	(1<<1)	/* When we have initialized the faces data */
+#define PROJ_FACE_SEAM1 (1 << 0)  /* If this face has a seam on any of its edges */
+#define PROJ_FACE_SEAM2 (1 << 1)
+#define PROJ_FACE_SEAM3 (1 << 2)
+#define PROJ_FACE_SEAM4 (1 << 3)
+
+#define PROJ_FACE_NOSEAM1   (1 << 4)
+#define PROJ_FACE_NOSEAM2   (1 << 5)
+#define PROJ_FACE_NOSEAM3   (1 << 6)
+#define PROJ_FACE_NOSEAM4   (1 << 7)
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list