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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-10-29 12:44:07 +0300
committerJacques Lucke <mail@jlucke.com>2019-10-29 12:44:07 +0300
commitdbfabe387097a7bdb8d7d73bc0c9cd0311d9926a (patch)
tree9ab2f5a7d40888e106135bfc6b331f9ae9a8f5e4 /object_scatter/operator.py
parentaeefe116e186f38b9b7813e7363b5460efa3b3a1 (diff)
Object Scatter: new Use Normal Rotation option
Diffstat (limited to 'object_scatter/operator.py')
-rw-r--r--object_scatter/operator.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/object_scatter/operator.py b/object_scatter/operator.py
index 742eec95..a01ca765 100644
--- a/object_scatter/operator.py
+++ b/object_scatter/operator.py
@@ -318,6 +318,8 @@ def scatter_from_source_point(bvhtree, point, seed, settings):
assert location is not None
normal.normalize()
+ up_direction = normal if settings.use_normal_rotation else Vector((0, 0, 1))
+
# Scale
min_scale = settings.scale * (1 - settings.random_scale)
max_scale = settings.scale
@@ -328,9 +330,9 @@ def scatter_from_source_point(bvhtree, point, seed, settings):
# Rotation
z_rotation = Euler((0, 0, random_uniform(sub_seed(seed, 3), 0, 2 * math.pi))).to_matrix()
- normal_rotation = normal.to_track_quat('Z', 'X').to_matrix()
+ up_rotation = up_direction.to_track_quat('Z', 'X').to_matrix()
local_rotation = random_euler(sub_seed(seed, 3), settings.rotation).to_matrix()
- rotation = local_rotation @ normal_rotation @ z_rotation
+ rotation = local_rotation @ up_rotation @ z_rotation
return Matrix.Translation(location) @ rotation.to_4x4() @ scale_matrix(scale)