Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2013-03-27 01:34:39 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-03-27 01:34:39 +0400
commit1942452ce52fa917198fee6f389f1bc7e4c620fe (patch)
treec0c8eb94447eee93bdea2e10fd3cc313546c7b01 /source/blender/blenkernel/intern/brush.c
parent974d73bfbfbd3f10ad28c3da52e2a6cd84a3b8b8 (diff)
Paint system:
Random texture mapping * Support for 2d painting. * Better random generation and useof the result.
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 888426735c5..aab2bcce70b 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -525,21 +525,17 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
float radius = 1.0f; /* Quite warnings */
float co[3];
- if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW ||
- mtex->brush_map_mode == MTEX_MAP_MODE_RANDOM)
+ if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW)
{
/* keep coordinates relative to mouse */
rotation += ups->brush_rotation;
- point_2d[0] -= ups->tex_mouse[0];
- point_2d[1] -= ups->tex_mouse[1];
+ x = point_2d[0] - ups->tex_mouse[0];
+ y = point_2d[1] - ups->tex_mouse[1];
/* use pressure adjusted size for fixed mode */
radius = ups->pixel_radius;
-
- x = point_2d[0];
- y = point_2d[1];
}
else if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) {
/* leave the coordinates relative to the screen */
@@ -549,6 +545,13 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
x = point_2d[0];
y = point_2d[1];
+ } else if (mtex->brush_map_mode == MTEX_MAP_MODE_RANDOM) {
+ rotation += ups->brush_rotation;
+ /* these contain a random coordinate */
+ x = point_2d[0] - ups->tex_mouse[0];
+ y = point_2d[1] - ups->tex_mouse[1];
+
+ radius = ups->pixel_radius;
}
x /= radius;
@@ -661,6 +664,14 @@ float BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2
rotation += ups->brush_rotation;
radius = ups->pixel_radius;
}
+ else if (mtex->brush_map_mode == MTEX_MAP_MODE_RANDOM) {
+ rotation += ups->brush_rotation;
+ /* these contain a random coordinate */
+ x -= ups->tex_mouse[0];
+ y -= ups->tex_mouse[1];
+
+ radius = ups->pixel_radius;
+ }
x /= radius;
y /= radius;
@@ -981,6 +992,13 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2],
}
}
+void BKE_brush_randomize_texture_coordinates(UnifiedPaintSettings *ups) {
+ /* we multiply with brush radius as an optimization for the brush
+ * texture sampling functions */
+ ups->tex_mouse[0] = BLI_rng_get_float(brush_rng)*ups->pixel_radius;
+ ups->tex_mouse[1] = BLI_rng_get_float(brush_rng)*ups->pixel_radius;
+}
+
/* Uses the brush curve control to find a strength value between 0 and 1 */
float BKE_brush_curve_strength_clamp(Brush *br, float p, const float len)
{