[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48389] branches/soc-2012-bratwurst/source /blender: Fixes to synchronize rake overlay with actual result for texpaint in 3D
Antony Riakiotakis
kalast at gmail.com
Fri Jun 29 00:42:28 CEST 2012
Revision: 48389
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48389
Author: psy-fi
Date: 2012-06-28 22:42:12 +0000 (Thu, 28 Jun 2012)
Log Message:
-----------
Fixes to synchronize rake overlay with actual result for texpaint in 3D
view.
Modified Paths:
--------------
branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_brush.h
branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_paint.h
branches/soc-2012-bratwurst/source/blender/blenkernel/intern/brush.c
branches/soc-2012-bratwurst/source/blender/blenkernel/intern/paint.c
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c
branches/soc-2012-bratwurst/source/blender/makesdna/DNA_scene_types.h
Modified: branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_brush.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_brush.h 2012-06-28 22:18:13 UTC (rev 48388)
+++ branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_brush.h 2012-06-28 22:42:12 UTC (rev 48389)
@@ -75,7 +75,7 @@
/* painting */
struct BrushPainter;
typedef struct BrushPainter BrushPainter;
-typedef int (*BrushFunc)(void *user, struct ImBuf *ibuf, const float lastpos[2], const float pos[2]);
+typedef int (*BrushFunc)(void *user, struct ImBuf *ibuf, const float lastpos[2], const float pos[2], float rotation);
BrushPainter *BKE_brush_painter_new(struct Scene *scene, struct Brush *brush);
void BKE_brush_painter_require_imbuf(BrushPainter *painter, short flt,
Modified: branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_paint.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_paint.h 2012-06-28 22:18:13 UTC (rev 48388)
+++ branches/soc-2012-bratwurst/source/blender/blenkernel/BKE_paint.h 2012-06-28 22:42:12 UTC (rev 48389)
@@ -45,6 +45,7 @@
struct PBVH;
struct Scene;
struct StrokeCache;
+struct UnifiedPaintSettings;
extern const char PAINT_CURSOR_SCULPT[3];
extern const char PAINT_CURSOR_VERTEX_PAINT[3];
@@ -75,6 +76,8 @@
float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level,
unsigned x, unsigned y);
+void paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups, const float mouse_pos[]);
+
/* Session data (mode-specific) */
typedef struct SculptSession {
Modified: branches/soc-2012-bratwurst/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/blenkernel/intern/brush.c 2012-06-28 22:18:13 UTC (rev 48388)
+++ branches/soc-2012-bratwurst/source/blender/blenkernel/intern/brush.c 2012-06-28 22:42:12 UTC (rev 48389)
@@ -1079,7 +1079,7 @@
brush_painter_do_partial(painter, NULL, x1, y2, x2, ibuf->y, 0, 0, pos);
}
-static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2], int use_color_correction)
+static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2], int use_color_correction, float special_rotation)
{
const Scene *scene = painter->scene;
Brush *brush = painter->brush;
@@ -1089,7 +1089,7 @@
short flt;
const int diameter = 2 * BKE_brush_size_randomized_get(scene, brush);
const float alpha = BKE_brush_alpha_get(scene, brush);
- const float rotation = scene->toolsettings->unified_paint_settings.last_angle;
+ const float rotation = -special_rotation + brush->mtex.rot;
if (diameter != cache->lastsize ||
alpha != cache->lastalpha ||
@@ -1177,9 +1177,10 @@
void *user, int use_color_correction)
{
Scene *scene = painter->scene;
- UnifiedPaintSettings *unified_paint_settings = &scene->toolsettings->unified_paint_settings;
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
Brush *brush = painter->brush;
int totpaintops = 0;
+ float special_rotation = 0.0;
BKE_brush_randomize_size(brush);
@@ -1195,15 +1196,17 @@
painter->startpaintpos[1] = pos[1];
if(brush->flag & BRUSH_RANDOM_ROTATION)
- unified_paint_settings->last_angle = BLI_frand()*2*M_PI;
- else if(!(brush->flag & BRUSH_RAKE))
- unified_paint_settings->last_angle = brush->mtex.rot;
- copy_v2_v2(unified_paint_settings->last_pos, pos);
+ special_rotation = BLI_frand()*2*M_PI;
+ else if(brush->flag & BRUSH_RAKE) {
+ paint_calculate_rake_rotation(ups, pos);
+ special_rotation = ups->last_angle;
+ }
+ copy_v2_v2(ups->last_pos, pos);
brush_pressure_apply(painter, brush, pressure);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, pos, use_color_correction);
- totpaintops += func(user, painter->cache.ibuf, pos, pos);
+ brush_painter_refresh_cache(painter, pos, use_color_correction, special_rotation);
+ totpaintops += func(user, painter->cache.ibuf, pos, pos, special_rotation);
painter->lasttime = time;
painter->firsttouch = 0;
@@ -1261,25 +1264,11 @@
painter->accumdistance += len;
if(brush->flag & BRUSH_RAKE) {
- float mrakediff[2];
- sub_v2_v2v2(mrakediff, pos, unified_paint_settings->last_pos);
-
- if(len_squared_v2(mrakediff) > RAKE_THRESHHOLD*RAKE_THRESHHOLD) {
- float angle;
- angle = atan2(dmousepos[1], dmousepos[0]);
- unified_paint_settings->last_angle = angle;
- unified_paint_settings->last_angle += brush->mtex.rot;
-
- /* to match sculpt behaviour */
- interp_v2_v2v2(unified_paint_settings->last_pos, unified_paint_settings->last_pos,
- pos, 0.5);
- }
+ paint_calculate_rake_rotation(ups, pos);
+ special_rotation = ups->last_angle;
} else if(brush->flag & BRUSH_RANDOM_ROTATION)
- unified_paint_settings->last_angle = BLI_frand()*2*M_PI;
- else
- unified_paint_settings->last_angle = brush->mtex.rot;
+ special_rotation = BLI_frand()*2*M_PI;
-
if (brush->flag & BRUSH_SPACE) {
/* do paint op over unpainted distance */
while ((len > 0.0f) && (painter->accumdistance >= spacing)) {
@@ -1295,10 +1284,10 @@
BKE_brush_jitter_pos(scene, brush, paintpos, finalpos);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, finalpos, use_color_correction);
+ brush_painter_refresh_cache(painter, finalpos, use_color_correction, special_rotation);
totpaintops +=
- func(user, painter->cache.ibuf, painter->lastpaintpos, finalpos);
+ func(user, painter->cache.ibuf, painter->lastpaintpos, finalpos, special_rotation);
painter->lastpaintpos[0] = paintpos[0];
painter->lastpaintpos[1] = paintpos[1];
@@ -1310,9 +1299,9 @@
BKE_brush_jitter_pos(scene, brush, pos, finalpos);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, finalpos, use_color_correction);
+ brush_painter_refresh_cache(painter, finalpos, use_color_correction, special_rotation);
- totpaintops += func(user, painter->cache.ibuf, pos, finalpos);
+ totpaintops += func(user, painter->cache.ibuf, pos, finalpos, special_rotation);
painter->lastpaintpos[0] = pos[0];
painter->lastpaintpos[1] = pos[1];
@@ -1338,10 +1327,10 @@
BKE_brush_jitter_pos(scene, brush, pos, finalpos);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, finalpos, use_color_correction);
+ brush_painter_refresh_cache(painter, finalpos, use_color_correction, special_rotation);
totpaintops +=
- func(user, painter->cache.ibuf, painter->lastmousepos, finalpos);
+ func(user, painter->cache.ibuf, painter->lastmousepos, finalpos, special_rotation);
painter->accumtime -= (double)brush->rate;
}
Modified: branches/soc-2012-bratwurst/source/blender/blenkernel/intern/paint.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/blenkernel/intern/paint.c 2012-06-28 22:18:13 UTC (rev 48388)
+++ branches/soc-2012-bratwurst/source/blender/blenkernel/intern/paint.c 2012-06-28 22:42:12 UTC (rev 48389)
@@ -39,6 +39,7 @@
#include "BLI_bitmap.h"
#include "BLI_utildefines.h"
+#include "BLI_math_vector.h"
#include "BKE_brush.h"
#include "BKE_context.h"
@@ -230,3 +231,19 @@
return gpm->data[(y * factor) * gridsize + (x * factor)];
}
+
+void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, const float mouse_pos[2])
+{
+ const float u = 0.5f;
+ const float r = RAKE_THRESHHOLD;
+
+ float dpos[2];
+ sub_v2_v2v2(dpos, ups->last_pos, mouse_pos);
+
+ if (len_squared_v2(dpos) >= r * r) {
+ ups->last_angle = atan2(dpos[0], dpos[1]);
+
+ interp_v2_v2v2(ups->last_pos, ups->last_pos,
+ mouse_pos, u);
+ }
+}
Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c 2012-06-28 22:18:13 UTC (rev 48388)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c 2012-06-28 22:42:12 UTC (rev 48389)
@@ -683,22 +683,8 @@
* account the brush movements before the stroke
* starts, but this doesn't really belong in draw code
* TODO) */
- {
- const float u = 0.5f;
- const float v = 1 - u;
- const float r = RAKE_THRESHHOLD;
+ paint_calculate_rake_rotation(ups, translation);
- const float dx = ups->last_pos[0] - x;
- const float dy = ups->last_pos[1] - y;
-
- if (dx * dx + dy * dy >= r * r) {
- ups->last_angle = atan2(dx, dy);
-
- ups->last_pos[0] = u * ups->last_pos[0] + v * x;
- ups->last_pos[1] = u * ups->last_pos[1] + v * y;
- }
- }
-
if(!in_uv_editor) {
/* test if brush is over the mesh. sculpt only for now */
hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location);
Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c 2012-06-28 22:18:13 UTC (rev 48388)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c 2012-06-28 22:42:12 UTC (rev 48389)
@@ -339,6 +339,7 @@
int bucketMin[2];
int bucketMax[2];
int context_bucket_x, context_bucket_y; /* must lock threads while accessing these */
+ float rotation;
} ProjPaintState;
typedef union pixelPointer {
@@ -3933,7 +3934,7 @@
if (falloff > 0.0f) {
if (ps->is_texbrush) {
/* note, for clone and smear, we only use the alpha, could be a special function */
- BKE_brush_sample_tex(ps->scene, ps->brush, samplecos, rgba, thread_index, unified_paint_settings->last_angle);
+ BKE_brush_sample_tex(ps->scene, ps->brush, samplecos, rgba, thread_index, -ps->rotation + ps->brush->mtex.rot);
alpha = rgba[3];
}
else {
@@ -4043,20 +4044,28 @@
return NULL;
}
-static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastpos[2], const float pos[2])
+static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastpos[2], const float pos[2], float rotation)
{
/* First unpack args from the struct */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list