[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48210] branches/soc-2012-bratwurst/source /blender: Refactoring: Move Sculpt variables that deal with brush drawing to
Antony Riakiotakis
kalast at gmail.com
Fri Jun 22 21:40:59 CEST 2012
Revision: 48210
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48210
Author: psy-fi
Date: 2012-06-22 19:40:58 +0000 (Fri, 22 Jun 2012)
Log Message:
-----------
Refactoring: Move Sculpt variables that deal with brush drawing to
inified paint settings in preparation to unification of display
function.
Modified Paths:
--------------
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/sculpt.c
branches/soc-2012-bratwurst/source/blender/makesdna/DNA_scene_types.h
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-22 19:20:40 UTC (rev 48209)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c 2012-06-22 19:40:58 UTC (rev 48210)
@@ -115,7 +115,7 @@
snap->winy = vc->ar->winy;
}
-static int load_tex(Sculpt *sd, Brush *br, ViewContext *vc)
+static int load_tex(Brush *br, ViewContext *vc)
{
static GLuint overlay_texture = 0;
static int init = 0;
@@ -130,10 +130,6 @@
int j;
int refresh;
-#ifndef _OPENMP
- (void)sd; /* quied unused warning */
-#endif
-
if (br->mtex.brush_map_mode == MTEX_MAP_MODE_TILED && !br->mtex.tex) return 0;
refresh =
@@ -185,7 +181,7 @@
buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex");
- #pragma omp parallel for schedule(static) if (sd->flags & SCULPT_USE_OPENMP)
+ #pragma omp parallel for schedule(static)
for (j = 0; j < size; j++) {
int i;
float y;
@@ -370,7 +366,7 @@
/* Draw an overlay that shows what effect the brush's texture will
* have on brush strength */
/* TODO: sculpt only for now */
-static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
+static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
ViewContext *vc, int x, int y)
{
rctf quad;
@@ -395,7 +391,7 @@
GL_VIEWPORT_BIT |
GL_TEXTURE_BIT);
- if (load_tex(sd, brush, vc)) {
+ if (load_tex(brush, vc)) {
glEnable(GL_BLEND);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@@ -410,24 +406,24 @@
/* brush rotation */
glTranslatef(0.5, 0.5, 0);
glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ?
- sd->last_angle : sd->special_rotation),
+ ups->last_angle : ups->special_rotation),
0.0, 0.0, 1.0);
glTranslatef(-0.5f, -0.5f, 0);
/* scale based on tablet pressure */
- if (sd->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush)) {
+ if (ups->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush)) {
glTranslatef(0.5f, 0.5f, 0);
- glScalef(1.0f / sd->pressure_value, 1.0f / sd->pressure_value, 1);
+ glScalef(1.0f / ups->pressure_value, 1.0f / ups->pressure_value, 1);
glTranslatef(-0.5f, -0.5f, 0);
}
- if (sd->draw_anchored) {
- const float *aim = sd->anchored_initial_mouse;
+ if (ups->draw_anchored) {
+ const float *aim = ups->anchored_initial_mouse;
const rcti *win = &vc->ar->winrct;
- quad.xmin = aim[0] - sd->anchored_size - win->xmin;
- quad.ymin = aim[1] - sd->anchored_size - win->ymin;
- quad.xmax = aim[0] + sd->anchored_size - win->xmin;
- quad.ymax = aim[1] + sd->anchored_size - win->ymin;
+ quad.xmin = aim[0] - ups->anchored_size - win->xmin;
+ quad.ymin = aim[1] - ups->anchored_size - win->ymin;
+ quad.xmax = aim[0] + ups->anchored_size - win->xmin;
+ quad.ymax = aim[1] + ups->anchored_size - win->ymin;
}
else {
const int radius = BKE_brush_size_get(vc->scene, brush);
@@ -470,7 +466,7 @@
/* Special actions taken when paint cursor goes over mesh */
/* TODO: sculpt only for now */
-static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc,
+static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewContext *vc,
const float location[3])
{
float unprojected_radius, projected_radius;
@@ -478,8 +474,8 @@
/* update the brush's cached 3D radius */
if (!BKE_brush_use_locked_size(vc->scene, brush)) {
/* get 2D brush radius */
- if (sd->draw_anchored)
- projected_radius = sd->anchored_size;
+ if (ups->draw_anchored)
+ projected_radius = ups->anchored_size;
else {
if (brush->flag & BRUSH_ANCHORED)
projected_radius = 8;
@@ -492,8 +488,8 @@
projected_radius);
/* scale 3D brush radius by pressure */
- if (sd->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush))
- unprojected_radius *= sd->pressure_value;
+ if (ups->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush))
+ unprojected_radius *= ups->pressure_value;
/* set cached value in either Brush or UnifiedPaintSettings */
BKE_brush_unprojected_radius_set(vc->scene, brush, unprojected_radius);
@@ -503,6 +499,7 @@
static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
{
Scene *scene = CTX_data_scene(C);
+ UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
Paint *paint = paint_get_active_from_context(C);
Brush *brush = paint_brush(paint);
ViewContext vc;
@@ -528,7 +525,6 @@
/* TODO: as sculpt and other paint modes are unified, this
* special mode of drawing will go away */
if (vc.obact->sculpt) {
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
float location[3];
int pixel_radius, hit;
@@ -541,14 +537,14 @@
const float v = 1 - u;
const float r = RAKE_THRESHHOLD;
- const float dx = sd->last_x - x;
- const float dy = sd->last_y - y;
+ const float dx = ups->last_pos[0] - x;
+ const float dy = ups->last_pos[1] - y;
if (dx * dx + dy * dy >= r * r) {
- sd->last_angle = atan2(dx, dy);
+ ups->last_angle = atan2(dx, dy);
- sd->last_x = u * sd->last_x + v * x;
- sd->last_y = u * sd->last_y + v * y;
+ ups->last_pos[0] = u * ups->last_pos[0] + v * x;
+ ups->last_pos[1] = u * ups->last_pos[1] + v * y;
}
}
@@ -556,7 +552,7 @@
hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location);
/* draw overlay */
- paint_draw_alpha_overlay(sd, brush, &vc, x, y);
+ paint_draw_alpha_overlay(ups, brush, &vc, x, y);
if (BKE_brush_use_locked_size(scene, brush))
BKE_brush_size_set(scene, brush, pixel_radius);
@@ -564,6 +560,7 @@
/* check if brush is subtracting, use different color then */
/* TODO: no way currently to know state of pen flip or
* invert key modifier without starting a stroke */
+ /* TODO no.2 add interface to query the tool if it supports inversion */
if ((!(brush->flag & BRUSH_INVERTED) ^
!(brush->flag & BRUSH_DIR_IN)) &&
ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW,
@@ -575,12 +572,12 @@
/* only do if brush is over the mesh */
if (hit)
- paint_cursor_on_hit(sd, brush, &vc, location);
+ paint_cursor_on_hit(ups, brush, &vc, location);
- if (sd->draw_anchored) {
- final_radius = sd->anchored_size;
- translation[0] = sd->anchored_initial_mouse[0] - vc.ar->winrct.xmin;
- translation[1] = sd->anchored_initial_mouse[1] - vc.ar->winrct.ymin;
+ if (ups->draw_anchored) {
+ final_radius = ups->anchored_size;
+ translation[0] = ups->anchored_initial_mouse[0] - vc.ar->winrct.xmin;
+ translation[1] = ups->anchored_initial_mouse[1] - vc.ar->winrct.ymin;
}
}
Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/sculpt.c 2012-06-22 19:20:40 UTC (rev 48209)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/sculpt.c 2012-06-22 19:40:58 UTC (rev 48210)
@@ -3291,6 +3291,7 @@
/* Initialize the stroke cache invariants from operator properties */
static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSession *ss, wmOperator *op, const float mouse[2])
{
+ UnifiedPaintSettings *ups = &CTX_data_scene(C)->toolsettings->unified_paint_settings;
StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
Brush *brush = paint_brush(&sd->paint);
ViewContext *vc = paint_stroke_view_context(op->customdata);
@@ -3396,7 +3397,7 @@
}
}
- cache->special_rotation = (brush->flag & BRUSH_RAKE) ? sd->last_angle : 0;
+ cache->special_rotation = (brush->flag & BRUSH_RAKE) ? ups->last_angle : 0;
cache->first_time = 1;
@@ -3405,7 +3406,7 @@
sculpt_omp_start(sd, ss);
}
-static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush)
+static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Brush *brush)
{
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
@@ -3470,17 +3471,17 @@
copy_v3_v3(cache->old_grab_location, grab_location);
if (tool == SCULPT_TOOL_GRAB)
- copy_v3_v3(sd->anchored_location, cache->true_location);
+ copy_v3_v3(ups->anchored_location, cache->true_location);
else if (tool == SCULPT_TOOL_THUMB)
- copy_v3_v3(sd->anchored_location, cache->orig_grab_location);
+ copy_v3_v3(ups->anchored_location, cache->orig_grab_location);
if (ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) {
/* location stays the same for finding vertices in brush radius */
copy_v3_v3(cache->true_location, cache->orig_grab_location);
- sd->draw_anchored = 1;
- copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse);
- sd->anchored_size = cache->pixel_radius;
+ ups->draw_anchored = 1;
+ copy_v2_v2(ups->anchored_initial_mouse, cache->initial_mouse);
+ ups->anchored_size = cache->pixel_radius;
}
}
}
@@ -3490,6 +3491,7 @@
struct PaintStroke *stroke,
PointerRNA *ptr)
{
+ UnifiedPaintSettings *ups = &CTX_data_scene(C)->toolsettings->unified_paint_settings;
Scene *scene = CTX_data_scene(C);
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
@@ -3521,8 +3523,8 @@
/* Truly temporary data that isn't stored in properties */
- sd->draw_pressure = 1;
- sd->pressure_value = cache->pressure;
+ ups->draw_pressure = 1;
+ ups->pressure_value = cache->pressure;
cache->previous_pixel_radius = cache->pixel_radius;
cache->pixel_radius = BKE_brush_size_get(scene, brush);
@@ -3568,7 +3570,7 @@
dx = cache->mouse[0] - cache->initial_mouse[0];
dy = cache->mouse[1] - cache->initial_mouse[1];
- sd->anchored_size = cache->pixel_radius = sqrt(dx * dx + dy * dy);
+ ups->anchored_size = cache->pixel_radius = sqrt(dx * dx + dy * dy);
cache->special_rotation = atan2(dx, dy) + M_PI;
@@ -3580,27 +3582,27 @@
halfway[1] = (float)dy * 0.5f + cache->initial_mouse[1];
if (sculpt_stroke_get_location(C, out, halfway)) {
- copy_v3_v3(sd->anchored_location, out);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list