Fix broken Cycles curve motion radius after recent refactor, and fix warnings.

This commit is contained in:
Brecht Van Lommel
2016-05-30 22:44:17 +02:00
parent 1482826075
commit 0d4a7d50c6
5 changed files with 19 additions and 15 deletions

View File

@@ -604,7 +604,7 @@ void ExportCurveSegments(Scene *scene, Mesh *mesh, ParticleCurveData *CData)
num_curve_keys++; 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_keys += num_curve_keys;
num_curves++; num_curves++;
} }
@@ -635,7 +635,7 @@ static void ExportCurveSegmentsMotion(Mesh *mesh, ParticleCurveData *CData, int
/* export motion vectors for curve keys */ /* export motion vectors for curve keys */
size_t numkeys = mesh->curve_keys.size(); 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; bool have_motion = false;
int i = 0; 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)) if(CData->psys_closetip[sys] && (curvekey == CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1))
radius = 0.0f; radius = 0.0f;
mP[i] = ickey_loc; /* curve motion keys store both position and radius in float4 */
(void)radius; mP[i] = float3_to_float4(ickey_loc);
mP[i].w = radius;
/* unlike mesh coordinates, these tend to be slightly different /* unlike mesh coordinates, these tend to be slightly different
* between frames due to particle transforms into/out of object * between frames due to particle transforms into/out of object
* space, so we use an epsilon to detect actual changes */ * 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; 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 /* motion, fill up previous steps that we might have skipped because
* they had no motion, but we need them anyway now */ * they had no motion, but we need them anyway now */
for(int step = 0; step < time_index; step++) { 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++) for(int key = 0; key < numkeys; key++) {
mP[key] = mesh->curve_keys[key]; mP[key] = float3_to_float4(mesh->curve_keys[key]);
mP[key].w = mesh->curve_radius[key];
}
} }
} }
} }

View File

@@ -240,7 +240,7 @@ void Mesh::add_curve_key(float3 co, float radius)
curve_radius.push_back_reserved(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_first_key.push_back_reserved(first_key);
curve_shader.push_back_reserved(shader); curve_shader.push_back_reserved(shader);

View File

@@ -158,7 +158,7 @@ public:
void add_vertex(float3 P); void add_vertex(float3 P);
void add_triangle(int v0, int v1, int v2, int shader, bool smooth, bool forms_quad = false); 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_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); int split_vertex(int vertex);
void compute_bounds(); void compute_bounds();

View File

@@ -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; 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 */ /* 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_verts = (ef.tu0 + ef.tu1 + ef.tv0 + ef.tv1) + (Mu - 1)*(Mv - 1);
int num_tris = 0; EdgeDice::reserve(num_verts);
EdgeDice::reserve(num_verts, num_tris);
} }
float2 QuadDice::map_uv(SubPatch& sub, float u, float v) float2 QuadDice::map_uv(SubPatch& sub, float u, float v)
@@ -358,7 +357,7 @@ void TriangleDice::reserve(EdgeFactors& ef, int M)
if(!(M & 1)) if(!(M & 1))
num_verts++; num_verts++;
EdgeDice::reserve(num_verts, 0); EdgeDice::reserve(num_verts);
} }
float2 TriangleDice::map_uv(SubPatch& sub, float2 uv) float2 TriangleDice::map_uv(SubPatch& sub, float2 uv)

View File

@@ -72,7 +72,7 @@ public:
explicit EdgeDice(const SubdParams& params); 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); int add_vert(Patch *patch, float2 uv);
void add_triangle(Patch *patch, int v0, int v1, int v2); void add_triangle(Patch *patch, int v0, int v1, int v2);