Fix Cycles curve UVs wrong after recent changes.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 18 Mar 2019 17:51:24 +0000 (18:51 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 18 Mar 2019 18:02:59 +0000 (19:02 +0100)
intern/cycles/blender/blender_curves.cpp
intern/cycles/render/curves.h

index b5e49bbeeef3af7144afc79daad5c8deea19605d..35f5db1649792dd01ad991a1d43ec009254aab2d 100644 (file)
@@ -254,7 +254,7 @@ static bool ObtainCacheParticleUV(Mesh *mesh,
                                        BL::Mesh::tessface_uv_textures_iterator l;
                                        b_mesh->tessface_uv_textures.begin(l);
 
-                                       float3 uv = make_float3(0.0f, 0.0f, 0.0f);
+                                       float2 uv = make_float2(0.0f, 0.0f);
                                        if(b_mesh->tessface_uv_textures.length())
                                                b_psys.uv_on_emitter(psmd, *b_pa, pa_no, uv_num, &uv.x);
                                        CData->curve_uv.push_back_slow(uv);
@@ -776,14 +776,10 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
 static void ExportCurveTriangleUV(ParticleCurveData *CData,
                                   int vert_offset,
                                   int resol,
-                                  float3 *uvdata)
+                                  float2 *uvdata)
 {
        if(uvdata == NULL)
                return;
-
-       float time = 0.0f;
-       float prevtime = 0.0f;
-
        int vertexindex = vert_offset;
 
        for(int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
@@ -792,30 +788,20 @@ static void ExportCurveTriangleUV(ParticleCurveData *CData,
                                continue;
 
                        for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
-                               time = CData->curvekey_time[curvekey]/CData->curve_length[curve];
-
                                for(int section = 0; section < resol; section++) {
                                        uvdata[vertexindex] = CData->curve_uv[curve];
-                                       uvdata[vertexindex].z = prevtime;
                                        vertexindex++;
                                        uvdata[vertexindex] = CData->curve_uv[curve];
-                                       uvdata[vertexindex].z = time;
                                        vertexindex++;
                                        uvdata[vertexindex] = CData->curve_uv[curve];
-                                       uvdata[vertexindex].z = prevtime;
                                        vertexindex++;
                                        uvdata[vertexindex] = CData->curve_uv[curve];
-                                       uvdata[vertexindex].z = time;
                                        vertexindex++;
                                        uvdata[vertexindex] = CData->curve_uv[curve];
-                                       uvdata[vertexindex].z = prevtime;
                                        vertexindex++;
                                        uvdata[vertexindex] = CData->curve_uv[curve];
-                                       uvdata[vertexindex].z = time;
                                        vertexindex++;
                                }
-
-                               prevtime = time;
                        }
                }
        }
@@ -1094,9 +1080,9 @@ void BlenderSync::sync_curves(Mesh *mesh,
                                        if(active_render)
                                                attr_uv = mesh->attributes.add(std, name);
                                        else
-                                               attr_uv = mesh->attributes.add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CORNER);
+                                               attr_uv = mesh->attributes.add(name, TypeFloat2, ATTR_ELEMENT_CORNER);
 
-                                       float3 *uv = attr_uv->data_float3();
+                                       float2 *uv = attr_uv->data_float2();
 
                                        ExportCurveTriangleUV(&CData, tri_num * 3, used_res, uv);
                                }
@@ -1104,9 +1090,9 @@ void BlenderSync::sync_curves(Mesh *mesh,
                                        if(active_render)
                                                attr_uv = mesh->curve_attributes.add(std, name);
                                        else
-                                               attr_uv = mesh->curve_attributes.add(name, TypeDesc::TypePoint,  ATTR_ELEMENT_CURVE);
+                                               attr_uv = mesh->curve_attributes.add(name, TypeFloat2,  ATTR_ELEMENT_CURVE);
 
-                                       float3 *uv = attr_uv->data_float3();
+                                       float2 *uv = attr_uv->data_float2();
 
                                        if(uv) {
                                                size_t i = 0;
index cf75751c58f0cdddee8e5351e3c147eda8e31335..9db411bc04b2b861e8f4050090dacddd30dc5ed4 100644 (file)
@@ -75,7 +75,7 @@ public:
        array<int> curve_firstkey;
        array<int> curve_keynum;
        array<float> curve_length;
-       array<float3> curve_uv;
+       array<float2> curve_uv;
        array<float3> curve_vcol;
 
        array<float3> curvekey_co;