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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-14 16:32:38 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-14 16:55:46 +0300
commitf6107af4cf4d907495e2e9c18e5866fd1d420650 (patch)
treeebac5a9d08145af572e5400c0697156797b73130 /intern/cycles/blender
parentc8e661706fcdd88f1cf371f2e5e4eb76bf09fda3 (diff)
Cycles: change Index output of Hair and Particle Info to Random, in 0..1 range.
These are used for randomization, so it's convenient if the index is already hashed and consistent with the Object Info node.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/blender_curves.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index c8eb879e5cb..f7cb0b66d29 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -25,6 +25,7 @@
#include "blender/blender_util.h"
#include "util/util_foreach.h"
+#include "util/util_hash.h"
#include "util/util_logging.h"
CCL_NAMESPACE_BEGIN
@@ -565,12 +566,12 @@ static void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CDa
return;
Attribute *attr_intercept = NULL;
- Attribute *attr_index = NULL;
+ Attribute *attr_random = NULL;
if(mesh->need_attribute(scene, ATTR_STD_CURVE_INTERCEPT))
attr_intercept = mesh->curve_attributes.add(ATTR_STD_CURVE_INTERCEPT);
- if(mesh->need_attribute(scene, ATTR_STD_CURVE_INDEX))
- attr_index = mesh->curve_attributes.add(ATTR_STD_CURVE_INDEX);
+ if(mesh->need_attribute(scene, ATTR_STD_CURVE_RANDOM))
+ attr_random = mesh->curve_attributes.add(ATTR_STD_CURVE_RANDOM);
/* compute and reserve size of arrays */
for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
@@ -615,8 +616,8 @@ static void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CDa
num_curve_keys++;
}
- if(attr_index != NULL) {
- attr_index->add(num_curves);
+ if(attr_random != NULL) {
+ attr_random->add(hash_int_01(num_curves));
}
mesh->add_curve(num_keys, CData->psys_shader[sys]);
@@ -625,15 +626,6 @@ static void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CDa
}
}
- if(attr_index != NULL) {
- /* Normalize index to 0..1 range. */
- float *curve_index = attr_index->data_float();
- const float norm_factor = 1.0f / (float)num_curves;
- for(int i = 0; i < num_curves; ++i) {
- curve_index[i] *= norm_factor;
- }
- }
-
/* check allocation */
if((mesh->curve_keys.size() != num_keys) || (mesh->num_curves() != num_curves)) {
VLOG(1) << "Allocation failed, clearing data";