Fix T37704: cycles hair render error with hair density vertex group.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 10 Dec 2013 18:47:27 +0000 (19:47 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 10 Dec 2013 18:47:27 +0000 (19:47 +0100)
Zero length hairs were causing problems, now it skips rendering them as they
are invisible anyway.

intern/cycles/blender/blender_curves.cpp

index b780877a158a91cd18a4a307f15019ca5d815442..da4acf16a4d20ad8d0475238f266a91b48f1cdda 100644 (file)
@@ -400,6 +400,8 @@ void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, float3 RotC
 
        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_length[curve] == 0.0f)
+                               continue;
 
                        float3 xbasis;
                        float3 v1;
@@ -460,6 +462,8 @@ void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int resol
 
        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_length[curve] == 0.0f)
+                               continue;
 
                        float3 firstxbasis = cross(make_float3(1.0f,0.0f,0.0f),CData->curvekey_co[CData->curve_firstkey[curve]+1] - CData->curvekey_co[CData->curve_firstkey[curve]]);
                        if(len_squared(firstxbasis)!= 0.0f)
@@ -593,7 +597,7 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
 
                for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
 
-                       if(CData->curve_keynum[curve] <= 1)
+                       if(CData->curve_keynum[curve] <= 1 || CData->curve_length[curve] == 0.0f)
                                continue;
 
                        size_t num_curve_keys = 0;
@@ -644,7 +648,7 @@ static void ExportCurveSegmentsMotion(Scene *scene, Mesh *mesh, ParticleCurveDat
                        continue;
 
                for(int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys]; curve++) {
-                       if(CData->curve_keynum[curve] <= 1)
+                       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]; curvekey++) {
@@ -683,6 +687,8 @@ void ExportCurveTriangleUV(Mesh *mesh, ParticleCurveData *CData, int vert_offset
                for( int curve = CData->psys_firstcurve[sys]; curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys] ; curve++) {
 
                        for( int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
+                               if(CData->curve_length[curve] == 0.0f)
+                                       continue;
 
                                time = CData->curvekey_time[curvekey]/CData->curve_length[curve];
 
@@ -724,6 +730,8 @@ void ExportCurveTriangleVcol(Mesh *mesh, ParticleCurveData *CData, int vert_offs
 
        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_length[curve] == 0.0f)
+                               continue;
 
                        for( int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {