[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46648] trunk/blender/source/blender: Code cleanups for sculpt-related code.
Nicholas Bishop
nicholasbishop at gmail.com
Tue May 15 06:44:14 CEST 2012
Revision: 46648
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46648
Author: nicholasbishop
Date: 2012-05-15 04:44:13 +0000 (Tue, 15 May 2012)
Log Message:
-----------
Code cleanups for sculpt-related code.
* Renamed flip_coord as flip_v3_v3
* Added flip_v3 for same input/output
* Moved special case for grab brush's normal into calc_area_normal()
* Renamed 'fixed' texture mode as 'view plane', mirrors
Brush.sculpt_plane terminology
Modified Paths:
--------------
trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c
trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
trunk/blender/source/blender/makesdna/DNA_texture_types.h
trunk/blender/source/blender/makesrna/intern/rna_brush.c
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c 2012-05-15 02:47:23 UTC (rev 46647)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c 2012-05-15 04:44:13 UTC (rev 46648)
@@ -86,7 +86,7 @@
mtex->rot == snap->rot) &&
/* make brush smaller shouldn't cause a resample */
- ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED &&
+ ((mtex->brush_map_mode == MTEX_MAP_MODE_VIEW &&
(BKE_brush_size_get(vc->scene, brush) <= snap->BKE_brush_size_get)) ||
(BKE_brush_size_get(vc->scene, brush) == snap->BKE_brush_size_get)) &&
@@ -154,7 +154,7 @@
make_snap(&snap, br, vc);
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
int s = BKE_brush_size_get(vc->scene, br);
int r = 1;
@@ -239,7 +239,7 @@
avg += br->texture_sample_bias;
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED)
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW)
avg *= BKE_brush_curve_strength(br, len, 1); /* Falloff curve */
buffer[index] = 255 - (GLubyte)(255 * avg);
@@ -278,7 +278,7 @@
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
+ if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
}
@@ -376,7 +376,7 @@
/* check for overlay mode */
if (!(brush->flag & BRUSH_TEXTURE_OVERLAY) ||
- !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED)))
+ !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_VIEW, MTEX_MAP_MODE_TILED)))
{
return;
}
@@ -405,7 +405,7 @@
glPushMatrix();
glLoadIdentity();
- if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
+ if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
/* brush rotation */
glTranslatef(0.5, 0.5, 0);
glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ?
Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2012-05-15 02:47:23 UTC (rev 46647)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2012-05-15 04:44:13 UTC (rev 46648)
@@ -537,7 +537,7 @@
}
/* Uses symm to selectively flip any axis of a coordinate. */
-static void flip_coord(float out[3], float in[3], const char symm)
+static void flip_v3_v3(float out[3], const float in[3], const char symm)
{
if (symm & SCULPT_SYMM_X)
out[0] = -in[0];
@@ -553,13 +553,18 @@
out[2] = in[2];
}
+static void flip_v3(float v[3], const char symm)
+{
+ flip_v3_v3(v, v, symm);
+}
+
static float calc_overlap(StrokeCache *cache, const char symm, const char axis, const float angle)
{
float mirror[3];
float distsq;
- /* flip_coord(mirror, cache->traced_location, symm); */
- flip_coord(mirror, cache->true_location, symm);
+ /* flip_v3_v3(mirror, cache->traced_location, symm); */
+ flip_v3_v3(mirror, cache->true_location, symm);
if (axis != 0) {
float mat[4][4] = MAT4_UNITY;
@@ -745,15 +750,16 @@
* position in order to project it. This insures that the
* brush texture will be oriented correctly. */
- flip_coord(symm_point, point, ss->cache->mirror_symmetry_pass);
+ flip_v3_v3(symm_point, point, ss->cache->mirror_symmetry_pass);
if (ss->cache->radial_symmetry_pass)
mul_m4_v3(ss->cache->symm_rot_mat_inv, symm_point);
ED_view3d_project_float_v2(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat);
- /* if fixed mode, keep coordinates relative to mouse */
- if (mtex->brush_map_mode == MTEX_MAP_MODE_FIXED) {
+ if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
+ /* keep coordinates relative to mouse */
+
rotation += ss->cache->special_rotation;
point_2d[0] -= ss->cache->tex_mouse[0];
@@ -765,8 +771,8 @@
x = point_2d[0] + ss->cache->vc->ar->winrct.xmin;
y = point_2d[1] + ss->cache->vc->ar->winrct.ymin;
}
- else { /* else (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) */
- /* leave the coordinates relative to the screen */
+ else if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) {
+ /* leave the coordinates relative to the screen */
/* use unadjusted size for tiled mode */
radius = BKE_brush_size_get(ss->cache->vc->scene, br);
@@ -882,10 +888,14 @@
static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
- int n;
-
float out_flip[3] = {0.0f, 0.0f, 0.0f};
+ int n, original;
+ /* Grab brush requires to test on original data (see r33888 and
+ bug #25371) */
+ original = (paint_brush(&sd->paint)->sculpt_tool == SCULPT_TOOL_GRAB ?
+ TRUE : ss->cache->original);
+
(void)sd; /* unused w/o openmp */
zero_v3(an);
@@ -901,7 +911,7 @@
unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
sculpt_brush_test_init(ss, &test);
- if (ss->cache->original) {
+ if (original) {
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_fast(&test, unode->co[vd.i])) {
@@ -989,7 +999,7 @@
}
else {
copy_v3_v3(an, ss->cache->last_area_normal);
- flip_coord(an, an, ss->cache->mirror_symmetry_pass);
+ flip_v3(an, ss->cache->mirror_symmetry_pass);
mul_m4_v3(ss->cache->symm_rot_mat, an);
}
}
@@ -1506,13 +1516,8 @@
int n;
float len;
- if (brush->normal_weight > 0 || brush->flag & BRUSH_FRONTFACE) {
- int cache = 1;
- /* grab brush requires to test on original data */
- SWAP(int, ss->cache->original, cache);
+ if (brush->normal_weight > 0 || brush->flag & BRUSH_FRONTFACE)
calc_sculpt_normal(sd, ob, an, nodes, totnode);
- SWAP(int, ss->cache->original, cache);
- }
copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
@@ -2082,10 +2087,10 @@
copy_v3_v3(fc, ss->cache->last_center);
/* for area normal */
- flip_coord(an, an, ss->cache->mirror_symmetry_pass);
+ flip_v3(an, ss->cache->mirror_symmetry_pass);
/* for flatten center */
- flip_coord(fc, fc, ss->cache->mirror_symmetry_pass);
+ flip_v3(fc, ss->cache->mirror_symmetry_pass);
/* for area normal */
mul_m4_v3(ss->cache->symm_rot_mat, an);
@@ -2816,9 +2821,9 @@
{
(void)sd; /* unused */
- flip_coord(cache->location, cache->true_location, symm);
- flip_coord(cache->grab_delta_symmetry, cache->grab_delta, symm);
- flip_coord(cache->view_normal, cache->true_view_normal, symm);
+ flip_v3_v3(cache->location, cache->true_location, symm);
+ flip_v3_v3(cache->grab_delta_symmetry, cache->grab_delta, symm);
+ flip_v3_v3(cache->view_normal, cache->true_view_normal, symm);
/* XXX This reduces the length of the grab delta if it approaches the line of symmetry
* XXX However, a different approach appears to be needed */
@@ -3364,7 +3369,7 @@
{
copy_v2_v2(cache->tex_mouse, cache->mouse);
- if ((brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) &&
+ if ((brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) &&
(brush->flag & BRUSH_RANDOM_ROTATION) &&
!(brush->flag & BRUSH_RAKE))
{
Modified: trunk/blender/source/blender/makesdna/DNA_texture_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_texture_types.h 2012-05-15 02:47:23 UTC (rev 46647)
+++ trunk/blender/source/blender/makesdna/DNA_texture_types.h 2012-05-15 04:44:13 UTC (rev 46648)
@@ -517,7 +517,7 @@
#define MTEX_LIN_LIGHT 16
/* brush_map_mode */
-#define MTEX_MAP_MODE_FIXED 0
+#define MTEX_MAP_MODE_VIEW 0
#define MTEX_MAP_MODE_TILED 1
#define MTEX_MAP_MODE_3D 2
Modified: trunk/blender/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_brush.c 2012-05-15 02:47:23 UTC (rev 46647)
+++ trunk/blender/source/blender/makesrna/intern/rna_brush.c 2012-05-15 04:44:13 UTC (rev 46648)
@@ -164,7 +164,7 @@
static int rna_SculptCapabilities_has_random_texture_angle_get(PointerRNA *ptr)
{
Brush *br = (Brush *)ptr->data;
- return ((br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) &&
+ return ((br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) &&
!(br->flag & BRUSH_ANCHORED) &&
!ELEM4(br->sculpt_tool,
SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
@@ -393,7 +393,7 @@
PropertyRNA *prop;
static EnumPropertyItem prop_map_mode_items[] = {
- {MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""},
+ {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", 0, "View Plane", ""},
{MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""},
{MTEX_MAP_MODE_3D, "3D", 0, "3D", ""},
{0, NULL, 0, NULL, NULL}
More information about the Bf-blender-cvs
mailing list