[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48087] branches/soc-2012-bratwurst: Brush Zoom Scale
Antony Riakiotakis
kalast at gmail.com
Tue Jun 19 19:21:49 CEST 2012
Revision: 48087
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48087
Author: psy-fi
Date: 2012-06-19 17:21:43 +0000 (Tue, 19 Jun 2012)
Log Message:
-----------
Brush Zoom Scale
=================
* initial commit, enabled for all paint modes. Pending code to make zoom
to mouse position slightly better. For projection viewport it is a
impossible to get the same brush radius on a different view than the one
we have currently though.
Modified Paths:
--------------
branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2012-bratwurst/source/blender/editors/space_view3d/view3d_edit.c
branches/soc-2012-bratwurst/source/blender/makesdna/DNA_brush_types.h
branches/soc-2012-bratwurst/source/blender/makesrna/intern/rna_brush.c
Modified: branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2012-06-19 16:45:48 UTC (rev 48086)
+++ branches/soc-2012-bratwurst/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2012-06-19 17:21:43 UTC (rev 48087)
@@ -496,6 +496,9 @@
if tool != 'ADD':
col.prop(brush, "strength", slider=True)
+ row = col.row(align=True)
+ col.prop(brush, "zoom_scale")
+
if tool == 'ADD':
col.prop(brush, "count")
col = layout.column()
@@ -631,6 +634,9 @@
col.prop(brush, "use_persistent")
col.operator("sculpt.set_persistent_base")
+ row = col.row(align=True)
+ col.prop(brush, "zoom_scale")
+
# Texture Paint Mode #
elif context.image_paint_object and brush:
@@ -658,6 +664,7 @@
col = layout.column()
col.active = (brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'})
col.prop(brush, "use_alpha")
+ col.prop(brush, "zoom_scale")
# Weight Paint Mode #
elif context.weight_paint_object and brush:
@@ -681,6 +688,9 @@
row.prop(brush, "jitter", slider=True)
row.prop(brush, "use_pressure_jitter", toggle=True, text="")
+ row = col.row(align=True)
+ col.prop(brush, "zoom_scale")
+
# Vertex Paint Mode #
elif context.vertex_paint_object and brush:
col = layout.column()
@@ -700,7 +710,10 @@
#row.prop(brush, "jitter", slider=True)
#row.prop(brush, "use_pressure_jitter", toggle=True, text="")
+ row = col.row(align=True)
+ col.prop(brush, "zoom_scale")
+
class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
bl_label = "Texture"
bl_options = {'DEFAULT_CLOSED'}
Modified: branches/soc-2012-bratwurst/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/space_view3d/view3d_edit.c 2012-06-19 16:45:48 UTC (rev 48086)
+++ branches/soc-2012-bratwurst/source/blender/editors/space_view3d/view3d_edit.c 2012-06-19 17:21:43 UTC (rev 48087)
@@ -39,6 +39,7 @@
#include "DNA_scene_types.h"
#include "DNA_camera_types.h"
#include "DNA_lamp_types.h"
+#include "DNA_brush_types.h"
#include "MEM_guardedalloc.h"
@@ -59,6 +60,8 @@
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */
+#include "BKE_paint.h"
+#include "BKE_brush.h"
#include "BIF_gl.h"
@@ -347,6 +350,7 @@
/* ************************** init for view ops **********************************/
typedef struct ViewOpsData {
+ Scene *scene;
ScrArea *sa;
ARegion *ar;
View3D *v3d;
@@ -410,6 +414,7 @@
/* store data */
op->customdata = vod;
+ vod->scene = CTX_data_scene(C);
vod->sa = CTX_wm_area(C);
vod->ar = CTX_wm_region(C);
vod->v3d = vod->sa->spacedata.first;
@@ -1448,9 +1453,22 @@
WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom");
}
-static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my)
+static void viewzoom_texpaint_brush_radius_update(Scene *scene, float factor)
{
+ Paint *p = paint_get_active(scene);
+ Brush *brush = paint_brush(p);
+
+ if (brush && (brush->flag & BRUSH_ZOOM_SCALE))
+ {
+ int oldsize = BKE_brush_size_get(scene, brush);
+ BKE_brush_size_set(scene, brush, oldsize*factor);
+ }
+}
+
+static void view_zoom_mouseloc(ARegion *ar, Scene *scene, float dfac, int mx, int my)
+{
RegionView3D *rv3d = ar->regiondata;
+ float old_dist = rv3d->dist;
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
float dvec[3];
@@ -1484,6 +1502,8 @@
else {
rv3d->dist *= dfac;
}
+
+ viewzoom_texpaint_brush_radius_update(scene, old_dist/rv3d->dist);
}
@@ -1561,7 +1581,7 @@
if (zfac != 1.0f && zfac * vod->rv3d->dist > 0.001f * vod->grid &&
zfac * vod->rv3d->dist < 10.0f * vod->far)
{
- view_zoom_mouseloc(vod->ar, zfac, vod->oldx, vod->oldy);
+ view_zoom_mouseloc(vod->ar, vod->scene, zfac, vod->oldx, vod->oldy);
}
}
@@ -1630,6 +1650,7 @@
ScrArea *sa;
ARegion *ar;
short use_cam_zoom;
+ Scene *scene = CTX_data_scene(C);
int delta = RNA_int_get(op->ptr, "delta");
int mx, my;
@@ -1660,7 +1681,7 @@
if (rv3d->camzoom < RV3D_CAMZOOM_MIN) rv3d->camzoom = RV3D_CAMZOOM_MIN;
}
else if (rv3d->dist < 10.0f * v3d->far) {
- view_zoom_mouseloc(ar, 1.2f, mx, my);
+ view_zoom_mouseloc(ar, scene, 1.2f, mx, my);
}
}
else {
@@ -1669,7 +1690,7 @@
if (rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom = RV3D_CAMZOOM_MAX;
}
else if (rv3d->dist > 0.001f * v3d->grid) {
- view_zoom_mouseloc(ar, 0.83333f, mx, my);
+ view_zoom_mouseloc(ar, scene, 0.83333f, mx, my);
}
}
Modified: branches/soc-2012-bratwurst/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/makesdna/DNA_brush_types.h 2012-06-19 16:45:48 UTC (rev 48086)
+++ branches/soc-2012-bratwurst/source/blender/makesdna/DNA_brush_types.h 2012-06-19 17:21:43 UTC (rev 48087)
@@ -140,7 +140,8 @@
/* temporary flag which sets up automatically for correct brush
* drawing when inverted modal operator is running */
- BRUSH_INVERTED = (1 << 29)
+ BRUSH_INVERTED = (1 << 29),
+ BRUSH_ZOOM_SCALE = (1 << 30)
} BrushFlags;
/* Brush.sculpt_tool */
Modified: branches/soc-2012-bratwurst/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/makesrna/intern/rna_brush.c 2012-06-19 16:45:48 UTC (rev 48086)
+++ branches/soc-2012-bratwurst/source/blender/makesrna/intern/rna_brush.c 2012-06-19 17:21:43 UTC (rev 48087)
@@ -832,6 +832,11 @@
"Automatically adjust strength to give consistent results for different spacings");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop = RNA_def_property(srna, "zoom_scale", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ZOOM_SCALE);
+ RNA_def_property_ui_text(prop, "Zoom Scale", "Resize the brush when zooming");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
/* adaptive space is not implemented yet */
prop = RNA_def_property(srna, "use_adaptive_space", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ADAPTIVE_SPACE);
More information about the Bf-blender-cvs
mailing list