diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-05-30 23:44:17 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2016-06-08 22:45:40 +0300 |
commit | a72de9116e0a4f760ed5c59b7f500d641c5369d4 (patch) | |
tree | f3110d54f9b51a8e9d015c2c91ae08973dc8eb2a | |
parent | 00aa6a8c91920fdf9c88d13c52832c071e469b74 (diff) |
Fix broken Cycles curve motion radius after recent refactor, and fix warnings.
-rw-r--r-- | intern/cycles/blender/blender_curves.cpp | 21 | ||||
-rw-r--r-- | intern/cycles/render/mesh.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/mesh.h | 2 | ||||
-rw-r--r-- | intern/cycles/subd/subd_dice.cpp | 7 | ||||
-rw-r--r-- | intern/cycles/subd/subd_dice.h | 2 |
5 files changed, 19 insertions, 15 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp index a1e2617d66f..378ae67f0c7 100644 --- a/intern/cycles/blender/blender_curves.cpp +++ b/intern/cycles/blender/blender_curves.cpp @@ -604,7 +604,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 +635,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 +656,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; } @@ -684,10 +687,12 @@ 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]; + } } } } diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 00b8e02f87f..d92226d6910 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -240,7 +240,7 @@ void Mesh::add_curve_key(float3 co, float radius) curve_radius.push_back_reserved(radius); } -void Mesh::add_curve(int first_key, int num_keys, int shader) +void Mesh::add_curve(int first_key, int shader) { curve_first_key.push_back_reserved(first_key); curve_shader.push_back_reserved(shader); diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h index 7556b7ccf1e..5c788fc12c7 100644 --- a/intern/cycles/render/mesh.h +++ b/intern/cycles/render/mesh.h @@ -158,7 +158,7 @@ public: void add_vertex(float3 P); void add_triangle(int v0, int v1, int v2, int shader, bool smooth, bool forms_quad = false); void add_curve_key(float3 loc, float radius); - void add_curve(int first_key, int num_keys, int shader); + void add_curve(int first_key, int shader); int split_vertex(int vertex); void compute_bounds(); diff --git a/intern/cycles/subd/subd_dice.cpp b/intern/cycles/subd/subd_dice.cpp index 9542ac48eda..8dba1379855 100644 --- a/intern/cycles/subd/subd_dice.cpp +++ b/intern/cycles/subd/subd_dice.cpp @@ -41,7 +41,7 @@ EdgeDice::EdgeDice(const SubdParams& params_) } } -void EdgeDice::reserve(int num_verts, int num_tris) +void EdgeDice::reserve(int num_verts) { Mesh *mesh = params.mesh; @@ -147,8 +147,7 @@ void QuadDice::reserve(EdgeFactors& ef, int Mu, int Mv) { /* XXX need to make this also work for edge factor 0 and 1 */ int num_verts = (ef.tu0 + ef.tu1 + ef.tv0 + ef.tv1) + (Mu - 1)*(Mv - 1); - int num_tris = 0; - EdgeDice::reserve(num_verts, num_tris); + EdgeDice::reserve(num_verts); } float2 QuadDice::map_uv(SubPatch& sub, float u, float v) @@ -358,7 +357,7 @@ void TriangleDice::reserve(EdgeFactors& ef, int M) if(!(M & 1)) num_verts++; - EdgeDice::reserve(num_verts, 0); + EdgeDice::reserve(num_verts); } float2 TriangleDice::map_uv(SubPatch& sub, float2 uv) diff --git a/intern/cycles/subd/subd_dice.h b/intern/cycles/subd/subd_dice.h index 49f786e949e..85bd0ea28f0 100644 --- a/intern/cycles/subd/subd_dice.h +++ b/intern/cycles/subd/subd_dice.h @@ -72,7 +72,7 @@ public: explicit EdgeDice(const SubdParams& params); - void reserve(int num_verts, int num_tris); + void reserve(int num_verts); int add_vert(Patch *patch, float2 uv); void add_triangle(Patch *patch, int v0, int v1, int v2); |