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:
Diffstat (limited to 'intern/cycles/blender/blender_curves.cpp')
-rw-r--r--intern/cycles/blender/blender_curves.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 5ed021aa1e4..25455113f66 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -565,9 +565,12 @@ static void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CDa
return;
Attribute *attr_intercept = NULL;
+ Attribute *attr_index = 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);
/* compute and reserve size of arrays */
for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
@@ -612,12 +615,25 @@ static void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CDa
num_curve_keys++;
}
+ if(attr_index != NULL) {
+ attr_index->add(num_curves);
+ }
+
mesh->add_curve(num_keys, CData->psys_shader[sys]);
num_keys += num_curve_keys;
num_curves++;
}
}
+ 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";