[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55171] trunk/blender/source/blender: Texpaint refactor complete!

Antony Riakiotakis kalast at gmail.com
Sun Mar 10 18:40:55 CET 2013


Revision: 55171
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55171
Author:   psy-fi
Date:     2013-03-10 17:40:55 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
Texpaint refactor complete!

* Projection painting files reside in paint_image_proj.c
* 2d projection files reside in paint_image_2d.c
* Common operator/paint operation code resides in paint_image.c

All old code layout is out. Phew...Now we can at least concentrate on
each system separately when debugging this beast. We could even separate
the paint structs for 2d/projective more easily should we choose to do
so.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_paint.h
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.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

Modified: trunk/blender/source/blender/blenkernel/BKE_paint.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_paint.h	2013-03-10 17:19:03 UTC (rev 55170)
+++ trunk/blender/source/blender/blenkernel/BKE_paint.h	2013-03-10 17:40:55 UTC (rev 55171)
@@ -55,13 +55,13 @@
 extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
 
 typedef enum PaintMode {
-	PAINT_SCULPT,
-	PAINT_VERTEX,
-	PAINT_WEIGHT,
-	PAINT_TEXTURE_PROJECTIVE,
-	PAINT_TEXTURE_2D,
-	PAINT_SCULPT_UV,
-	PAINT_INVALID
+	PAINT_SCULPT = 0,
+	PAINT_VERTEX = 1,
+	PAINT_WEIGHT = 2,
+	PAINT_TEXTURE_PROJECTIVE = 3,
+	PAINT_TEXTURE_2D = 4,
+	PAINT_SCULPT_UV = 5,
+	PAINT_INVALID = 6
 } PaintMode;
 
 void BKE_paint_init(struct Paint *p, const char col[3]);

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-10 17:19:03 UTC (rev 55170)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-10 17:40:55 UTC (rev 55171)
@@ -101,291 +101,13 @@
 
 #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)
 
-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 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)
-
-#define PROJ_SRC_VIEW       1
-#define PROJ_SRC_IMAGE_CAM  2
-#define PROJ_SRC_IMAGE_VIEW 3
-
 #define PROJ_VIEW_DATA_ID "view_data"
 #define PROJ_VIEW_DATA_SIZE (4 * 4 + 4 * 4 + 3) /* viewmat + winmat + clipsta + clipend + is_ortho */
 
-
-/* a slightly scaled down face is used to get fake 3D location for edge pixels in the seams
- * as this number approaches  1.0f the likelihood increases of float precision errors where
- * it is occluded by an adjacent face */
-#define PROJ_FACE_SCALE_SEAM    0.99f
-
-#define PROJ_BUCKET_NULL        0
-#define PROJ_BUCKET_INIT        (1 << 0)
-// #define PROJ_BUCKET_CLONE_INIT	(1<<1)
-
-/* used for testing doubles, if a point is on a line etc */
-#define PROJ_GEOM_TOLERANCE 0.00075f
-
-/* vert flags */
-#define PROJ_VERT_CULL 1
-
-/* This is mainly a convenience struct used so we can keep an array of images we use
- * Thir imbufs, etc, in 1 array, When using threads this array is copied for each thread
- * because 'partRedrawRect' and 'touch' values would not be thread safe */
-typedef struct ProjPaintImage {
-	Image *ima;
-	ImBuf *ibuf;
-	ImagePaintPartialRedraw *partRedrawRect;
-	void **undoRect; /* only used to build undo tiles after painting */
-	int touch;
-} ProjPaintImage;
-
-/* Main projection painting struct passed to all projection painting functions */
-typedef struct ProjPaintState {
-	View3D *v3d;
-	RegionView3D *rv3d;
-	ARegion *ar;
-	Scene *scene;
-	int source; /* PROJ_SRC_**** */
-
-	Brush *brush;
-	short tool, blend;
-	Object *ob;
-	/* end similarities with ImagePaintState */
-	
-	DerivedMesh    *dm;
-	int dm_totface;
-	int dm_totvert;
-	int dm_release;
-
-	MVert          *dm_mvert;
-	MFace          *dm_mface;
-	MTFace         *dm_mtface;
-	MTFace         *dm_mtface_clone;    /* other UV map, use for cloning between layers */
-	MTFace         *dm_mtface_stencil;
-	
-	/* projection painting only */
-	MemArena *arena_mt[BLENDER_MAX_THREADS]; /* for multithreading, the first item is sometimes used for non threaded cases too */
-	LinkNode **bucketRect;              /* screen sized 2D array, each pixel has a linked list of ProjPixel's */
-	LinkNode **bucketFaces;             /* bucketRect aligned array linkList of faces overlapping each bucket */
-	unsigned char *bucketFlags;         /* store if the bucks have been initialized  */
-#ifndef PROJ_DEBUG_NOSEAMBLEED
-	char *faceSeamFlags;                /* store info about faces, if they are initialized etc*/
-	float (*faceSeamUVs)[4][2];         /* expanded UVs for faces to use as seams */
-	LinkNode **vertFaces;               /* Only needed for when seam_bleed_px is enabled, use to find UV seams */
-#endif
-	char *vertFlags;                    /* store options per vert, now only store if the vert is pointing away from the view */
-	int buckets_x;                      /* The size of the bucket grid, the grid span's screenMin/screenMax so you can paint outsize the screen or with 2 brushes at once */
-	int buckets_y;
-
-	ProjPaintImage *projImages;
-	
-	int pixel_sizeof;           /* result of project_paint_pixel_sizeof(), constant per stroke */
-
-	int image_tot;              /* size of projectImages array */
-	
-	float (*screenCoords)[4];   /* verts projected into floating point screen space */
-	
-	float screenMin[2];         /* 2D bounds for mesh verts on the screen's plane (screenspace) */
-	float screenMax[2]; 
-	float screen_width;         /* Calculated from screenMin & screenMax */
-	float screen_height;
-	int winx, winy;             /* from the carea or from the projection render */
-	
-	/* options for projection painting */
-	int do_layer_clone;
-	int do_layer_stencil;
-	int do_layer_stencil_inv;
-	
-	short do_occlude;               /* Use raytraced occlusion? - ortherwise will paint right through to the back*/
-	short do_backfacecull;          /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */
-	short do_mask_normal;           /* mask out pixels based on their normals */
-	short do_new_shading_nodes;     /* cache BKE_scene_use_new_shading_nodes value */
-	float normal_angle;             /* what angle to mask at*/
-	float normal_angle_inner;
-	float normal_angle_range;       /* difference between normal_angle and normal_angle_inner, for easy access */
-	
-	short is_ortho;
-	bool do_masking;              /* use masking during painting. Some operations such as airbrush may disable */
-	short is_texbrush;              /* only to avoid running  */
-#ifndef PROJ_DEBUG_NOSEAMBLEED
-	float seam_bleed_px;
-#endif
-	/* clone vars */
-	float cloneOffset[2];
-	
-	float projectMat[4][4];     /* Projection matrix, use for getting screen coords */
-	float viewDir[3];           /* View vector, use for do_backfacecull and for ray casting with an ortho viewport  */
-	float viewPos[3];           /* View location in object relative 3D space, so can compare to verts  */
-	float clipsta, clipend;
-	
-	/* reproject vars */
-	Image *reproject_image;
-	ImBuf *reproject_ibuf;
-
-
-	/* threads */
-	int thread_tot;
-	int bucketMin[2];
-	int bucketMax[2];
-	int context_bucket_x, context_bucket_y; /* must lock threads while accessing these */
-} ProjPaintState;
-
-typedef union pixelPointer {
-	float *f_pt;            /* float buffer */
-	unsigned int *uint_pt; /* 2 ways to access a char buffer */
-	unsigned char *ch_pt;
-} PixelPointer;
-
-typedef union pixelStore {
-	unsigned char ch[4];
-	unsigned int uint;
-	float f[4];
-} PixelStore;
-
-typedef struct ProjPixel {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list