Cycles: remove option to disable transparent shadows globally.
[blender-staging.git] / intern / cycles / blender / blender_curves.cpp
index a1e2617d66f2d365cc0556ba0b3d91c815a10c1a..42b985305ea1f7e530c809473b8514f0087777f3 100644 (file)
  * limitations under the License.
  */
 
-#include "attribute.h"
-#include "camera.h"
-#include "curves.h"
-#include "mesh.h"
-#include "object.h"
-#include "scene.h"
+#include "render/attribute.h"
+#include "render/camera.h"
+#include "render/curves.h"
+#include "render/mesh.h"
+#include "render/object.h"
+#include "render/scene.h"
 
-#include "blender_sync.h"
-#include "blender_util.h"
+#include "blender/blender_sync.h"
+#include "blender/blender_util.h"
 
-#include "util_foreach.h"
-#include "util_logging.h"
+#include "util/util_foreach.h"
+#include "util/util_logging.h"
 
 CCL_NAMESPACE_BEGIN
 
-/* Utilities */
-
-/* Hair curve functions */
-
-void curveinterp_v3_v3v3v3v3(float3 *p, float3 *v1, float3 *v2, float3 *v3, float3 *v4, const float w[4]);
-void interp_weights(float t, float data[4]);
-float shaperadius(float shape, float root, float tip, float time);
-void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData);
-bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int uv_num);
-bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int vcol_num);
-bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background);
-void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData);
-void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
-                               float3 RotCam, bool is_ortho);
-void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resolution);
-void ExportCurveTriangleUV(ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata);
-void ExportCurveTriangleVcol(ParticleCurveData *CData, int vert_offset, int resol, uchar4 *cdata);
-
 ParticleCurveData::ParticleCurveData()
 {
 }
@@ -55,7 +37,7 @@ ParticleCurveData::~ParticleCurveData()
 {
 }
 
-void interp_weights(float t, float data[4])
+static void interp_weights(float t, float data[4])
 {
        /* Cardinal curve interpolation */
        float t2 = t * t;
@@ -68,17 +50,19 @@ void interp_weights(float t, float data[4])
        data[3] =  fc          * t3  - fc * t2;
 }
 
-void curveinterp_v3_v3v3v3v3(float3 *p, float3 *v1, float3 *v2, float3 *v3, float3 *v4, const float w[4])
+static void curveinterp_v3_v3v3v3v3(float3 *p,
+                                    float3 *v1, float3 *v2, float3 *v3, float3 *v4,
+                                    const float w[4])
 {
        p->x = v1->x * w[0] + v2->x * w[1] + v3->x * w[2] + v4->x * w[3];
        p->y = v1->y * w[0] + v2->y * w[1] + v3->y * w[2] + v4->y * w[3];
        p->z = v1->z * w[0] + v2->z * w[1] + v3->z * w[2] + v4->z * w[3];
 }
 
-float shaperadius(float shape, float root, float tip, float time)
+static float shaperadius(float shape, float root, float tip, float time)
 {
        float radius = 1.0f - time;
-       
+
        if(shape != 0.0f) {
                if(shape < 0.0f)
                        radius = powf(radius, 1.0f + shape);
@@ -90,7 +74,13 @@ float shaperadius(float shape, float root, float tip, float time)
 
 /* curve functions */
 
-void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData)
+static void InterpolateKeySegments(int seg,
+                                   int segno,
+                                   int key,
+                                   int curve,
+                                   float3 *keyloc,
+                                   float *time,
+                                   ParticleCurveData *CData)
 {
        float3 ckey_loc1 = CData->curvekey_co[key];
        float3 ckey_loc2 = ckey_loc1;
@@ -119,7 +109,11 @@ void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyl
                curveinterp_v3_v3v3v3v3(keyloc, &ckey_loc1, &ckey_loc2, &ckey_loc3, &ckey_loc4, t);
 }
 
-bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background)
+static bool ObtainCacheParticleData(Mesh *mesh,
+                                    BL::Mesh *b_mesh,
+                                    BL::Object *b_ob,
+                                    ParticleCurveData *CData,
+                                    bool background)
 {
        int curvenum = 0;
        int keyno = 0;
@@ -143,7 +137,7 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
                                int totparts = b_psys.particles.length();
                                int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f);
                                int totcurves = totchild;
-                               
+
                                if(b_part.child_type() == 0 || totchild == 0)
                                        totcurves += totparts;
 
@@ -161,7 +155,7 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
                                CData->psys_shader.push_back_slow(shader);
 
                                float radius = get_float(cpsys, "radius_scale") * 0.5f;
-       
+
                                CData->psys_rootradius.push_back_slow(radius * get_float(cpsys, "root_width"));
                                CData->psys_tipradius.push_back_slow(radius * get_float(cpsys, "tip_width"));
                                CData->psys_shape.push_back_slow(get_float(cpsys, "shape"));
@@ -181,7 +175,7 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
                                for(; pa_no < totparts+totchild; pa_no++) {
                                        int keynum = 0;
                                        CData->curve_firstkey.push_back_slow(keyno);
-                                       
+
                                        float curve_length = 0.0f;
                                        float3 pcKey;
                                        for(int step_no = 0; step_no < ren_step; step_no++) {
@@ -213,7 +207,12 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
        return true;
 }
 
-bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int uv_num)
+static bool ObtainCacheParticleUV(Mesh *mesh,
+                                  BL::Mesh *b_mesh,
+                                  BL::Object *b_ob,
+                                  ParticleCurveData *CData,
+                                  bool background,
+                                  int uv_num)
 {
        if(!(mesh && b_mesh && b_ob && CData))
                return false;
@@ -231,7 +230,7 @@ bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Parti
                                int totparts = b_psys.particles.length();
                                int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f);
                                int totcurves = totchild;
-                               
+
                                if(b_part.child_type() == 0 || totchild == 0)
                                        totcurves += totparts;
 
@@ -267,7 +266,12 @@ bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Parti
        return true;
 }
 
-bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background, int vcol_num)
+static bool ObtainCacheParticleVcol(Mesh *mesh,
+                                    BL::Mesh *b_mesh,
+                                    BL::Object *b_ob,
+                                    ParticleCurveData *CData,
+                                    bool background,
+                                    int vcol_num)
 {
        if(!(mesh && b_mesh && b_ob && CData))
                return false;
@@ -285,7 +289,7 @@ bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
                                int totparts = b_psys.particles.length();
                                int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f);
                                int totcurves = totchild;
-                               
+
                                if(b_part.child_type() == 0 || totchild == 0)
                                        totcurves += totparts;
 
@@ -333,16 +337,16 @@ static void set_resolution(BL::Object *b_ob, BL::Scene *scene, bool render)
        }
 }
 
-void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
-                               float3 RotCam, bool is_ortho)
+static void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
+                                      float3 RotCam, bool is_ortho)
 {
        int vertexno = mesh->verts.size();
        int vertexindex = vertexno;
        int numverts = 0, numtris = 0;
 
        /* compute and reserve size of arrays */
-       for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+       for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
                        if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
                                continue;
 
@@ -354,8 +358,8 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
        mesh->reserve_mesh(mesh->verts.size() + numverts, mesh->num_triangles() + numtris);
 
        /* actually export */
-       for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+       for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
                        if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
                                continue;
 
@@ -380,7 +384,7 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
 
                                if(curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1)
                                        v1 = CData->curvekey_co[curvekey] - CData->curvekey_co[max(curvekey - 1, CData->curve_firstkey[curve])];
-                               else 
+                               else
                                        v1 = CData->curvekey_co[curvekey + 1] - CData->curvekey_co[curvekey - 1];
 
                                time = CData->curvekey_time[curvekey]/CData->curve_length[curve];
@@ -407,6 +411,7 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
                }
        }
 
+       mesh->resize_mesh(mesh->verts.size(), mesh->num_triangles());
        mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
        mesh->add_face_normals();
@@ -416,28 +421,30 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData,
        /* texture coords still needed */
 }
 
-void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resolution)
+static void ExportCurveTriangleGeometry(Mesh *mesh,
+                                        ParticleCurveData *CData,
+                                        int resolution)
 {
        int vertexno = mesh->verts.size();
        int vertexindex = vertexno;
        int numverts = 0, numtris = 0;
 
        /* compute and reserve size of arrays */
-       for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+       for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
                        if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
                                continue;
 
-                       numverts += (CData->curve_keynum[curve] - 2)*2*resolution + resolution;
-                       numtris += (CData->curve_keynum[curve] - 2)*resolution;
+                       numverts += (CData->curve_keynum[curve] - 1)*resolution + resolution;
+                       numtris += (CData->curve_keynum[curve] - 1)*2*resolution;
                }
        }
 
        mesh->reserve_mesh(mesh->verts.size() + numverts, mesh->num_triangles() + numtris);
 
        /* actually export */
-       for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+       for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
                        if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
                                continue;
 
@@ -539,6 +546,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resol
                }
        }
 
+       mesh->resize_mesh(mesh->verts.size(), mesh->num_triangles());
        mesh->attributes.remove(ATTR_STD_VERTEX_NORMAL);
        mesh->attributes.remove(ATTR_STD_FACE_NORMAL);
        mesh->add_face_normals();
@@ -548,7 +556,7 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resol
        /* texture coords still needed */
 }
 
-void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
+static void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
 {
        int num_keys = 0;
        int num_curves = 0;
@@ -557,13 +565,13 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
                return;
 
        Attribute *attr_intercept = NULL;
-       
+
        if(mesh->need_attribute(scene, ATTR_STD_CURVE_INTERCEPT))
                attr_intercept = mesh->curve_attributes.add(ATTR_STD_CURVE_INTERCEPT);
 
        /* compute and reserve size of arrays */
-       for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+       for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
                        if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
                                continue;
 
@@ -582,8 +590,8 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
        num_curves = 0;
 
        /* actually export */
-       for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+       for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
                        if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
                                continue;
 
@@ -604,7 +612,7 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
                                num_curve_keys++;
                        }
 
-                       mesh->add_curve(num_keys, num_curve_keys, CData->psys_shader[sys]);
+                       mesh->add_curve(num_keys, CData->psys_shader[sys]);
                        num_keys += num_curve_keys;
                        num_curves++;
                }
@@ -635,7 +643,7 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
 
        /* export motion vectors for curve keys */
        size_t numkeys = mesh->curve_keys.size();
-       float3 *mP = attr_mP->data_float3() + time_index*numkeys;
+       float4 *mP = attr_mP->data_float4() + time_index*numkeys;
        bool have_motion = false;
        int i = 0;
 
@@ -656,13 +664,16 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
                                        if(CData->psys_closetip[sys] && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1))
                                                radius = 0.0f;
 
-                                       mP[i] = ickey_loc;
-                                       (void)radius;
+                                       /* curve motion keys store both position and radius in float4 */
+                                       mP[i] = float3_to_float4(ickey_loc);
+                                       mP[i].w = radius;
 
                                        /* unlike mesh coordinates, these tend to be slightly different
                                         * between frames due to particle transforms into/out of object
                                         * space, so we use an epsilon to detect actual changes */
-                                       if(len_squared(mP[i] - mesh->curve_keys[i]) > 1e-5f*1e-5f)
+                                       float4 curve_key = float3_to_float4(mesh->curve_keys[i]);
+                                       curve_key.w = mesh->curve_radius[i];
+                                       if(len_squared(mP[i] - curve_key) > 1e-5f*1e-5f)
                                                have_motion = true;
                                }
 
@@ -674,8 +685,13 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
        /* in case of new attribute, we verify if there really was any motion */
        if(new_attribute) {
                if(i != numkeys || !have_motion) {
-                       /* no motion, remove attributes again */
-                       VLOG(1) << "No motion, removing attribute";
+                       /* No motion or hair "topology" changed, remove attributes again. */
+                       if(i != numkeys) {
+                               VLOG(1) << "Hair topology changed, removing attribute.";
+                       }
+                       else {
+                               VLOG(1) << "No motion, removing attribute.";
+                       }
                        mesh->curve_attributes.remove(ATTR_STD_MOTION_VERTEX_POSITION);
                }
                else if(time_index > 0) {
@@ -684,16 +700,21 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
                        /* motion, fill up previous steps that we might have skipped because
                         * they had no motion, but we need them anyway now */
                        for(int step = 0; step < time_index; step++) {
-                               float3 *mP = attr_mP->data_float3() + step*numkeys;
+                               float4 *mP = attr_mP->data_float4() + step*numkeys;
 
-                               for(int key = 0; key < numkeys; key++)
-                                       mP[key] = mesh->curve_keys[key];
+                               for(int key = 0; key < numkeys; key++) {
+                                       mP[key] = float3_to_float4(mesh->curve_keys[key]);
+                                       mP[key].w = mesh->curve_radius[key];
+                               }
                        }
                }
        }
 }
 
-void ExportCurveTriangleUV(ParticleCurveData *CData, int vert_offset, int resol, float3 *uvdata)
+static void ExportCurveTriangleUV(ParticleCurveData *CData,
+                                  int vert_offset,
+                                  int resol,
+                                  float3 *uvdata)
 {
        if(uvdata == NULL)
                return;
@@ -703,8 +724,8 @@ void ExportCurveTriangleUV(ParticleCurveData *CData, int vert_offset, int resol,
 
        int vertexindex = vert_offset;
 
-       for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+       for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
                        if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
                                continue;
 
@@ -738,31 +759,34 @@ void ExportCurveTriangleUV(ParticleCurveData *CData, int vert_offset, int resol,
        }
 }
 
-void ExportCurveTriangleVcol(ParticleCurveData *CData, int vert_offset, int resol, uchar4 *cdata)
+static void ExportCurveTriangleVcol(ParticleCurveData *CData,
+                                    int vert_offset,
+                                    int resol,
+                                    uchar4 *cdata)
 {
        if(cdata == NULL)
                return;
 
        int vertexindex = vert_offset;
 
-       for(int sys = 0; sys < CData->psys_firstcurve.size() ; sys++) {
-               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
+       for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
+               for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
                        if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
                                continue;
 
                        for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
                                for(int section = 0; section < resol; section++) {
-                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
                                        vertexindex++;
-                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
                                        vertexindex++;
-                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
                                        vertexindex++;
-                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
                                        vertexindex++;
-                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
                                        vertexindex++;
-                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+                                       cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
                                        vertexindex++;
                                }
                        }
@@ -868,7 +892,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
        }
 
        /* obtain general settings */
-       bool use_curves = scene->curve_system_manager->use_curves;
+       const bool use_curves = scene->curve_system_manager->use_curves;
 
        if(!(use_curves && b_ob.mode() != b_ob.mode_PARTICLE_EDIT)) {
                if(!motion)
@@ -876,11 +900,11 @@ void BlenderSync::sync_curves(Mesh *mesh,
                return;
        }
 
-       int primitive = scene->curve_system_manager->primitive;
-       int triangle_method = scene->curve_system_manager->triangle_method;
-       int resolution = scene->curve_system_manager->resolution;
-       size_t vert_num = mesh->verts.size();
-       size_t tri_num = mesh->num_triangles();
+       const int primitive = scene->curve_system_manager->primitive;
+       const int triangle_method = scene->curve_system_manager->triangle_method;
+       const int resolution = scene->curve_system_manager->resolution;
+       const size_t vert_num = mesh->verts.size();
+       const size_t tri_num = mesh->num_triangles();
        int used_res = 1;
 
        /* extract particle hair data - should be combined with connecting to mesh later*/
@@ -980,7 +1004,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
 
                                        for(size_t curve = 0; curve < CData.curve_vcol.size(); curve++)
                                                if(!(CData.curve_keynum[curve] <= 1 || CData.curve_length[curve] == 0.0f))
-                                                       fdata[i++] = color_srgb_to_scene_linear(CData.curve_vcol[curve]);
+                                                       fdata[i++] = color_srgb_to_scene_linear_v3(CData.curve_vcol[curve]);
                                }
                        }
                }
@@ -1039,4 +1063,3 @@ void BlenderSync::sync_curves(Mesh *mesh,
 }
 
 CCL_NAMESPACE_END
-