Fix T95692: incorrect interpolated children particle hair
Differential Revision: https://developer.blender.org/D14227
This commit is contained in:
parent
216a215ba5
commit
2fb31f34af
@ -596,7 +596,8 @@ void psys_get_texture(struct ParticleSimulationData *sim,
|
||||
/**
|
||||
* Interpolate a location on a face based on face coordinates.
|
||||
*/
|
||||
void psys_interpolate_face(struct MVert *mvert,
|
||||
void psys_interpolate_face(struct Mesh *mesh,
|
||||
struct MVert *mvert,
|
||||
const float (*vert_normals)[3],
|
||||
struct MFace *mface,
|
||||
struct MTFace *tface,
|
||||
|
@ -1673,7 +1673,8 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach
|
||||
/* Particles on a dm */
|
||||
/************************************************/
|
||||
|
||||
void psys_interpolate_face(MVert *mvert,
|
||||
void psys_interpolate_face(Mesh *mesh,
|
||||
MVert *mvert,
|
||||
const float (*vert_normals)[3],
|
||||
MFace *mface,
|
||||
MTFace *tface,
|
||||
@ -1793,6 +1794,7 @@ void psys_interpolate_face(MVert *mvert,
|
||||
else {
|
||||
interp_v3_v3v3v3(orco, o1, o2, o3, w);
|
||||
}
|
||||
BKE_mesh_orco_verts_transform(mesh, (float(*)[3])orco, 1, true);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(orco, vec);
|
||||
@ -2137,6 +2139,7 @@ void psys_particle_on_dm(Mesh *mesh_final,
|
||||
if (orco) {
|
||||
if (orcodata) {
|
||||
copy_v3_v3(orco, orcodata[mapindex]);
|
||||
BKE_mesh_orco_verts_transform(mesh_final, (float(*)[3])orco, 1, true);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(orco, vec);
|
||||
@ -2162,8 +2165,18 @@ void psys_particle_on_dm(Mesh *mesh_final,
|
||||
}
|
||||
|
||||
if (from == PART_FROM_VOLUME) {
|
||||
psys_interpolate_face(
|
||||
mvert, vert_normals, mface, mtface, orcodata, mapfw, vec, tmpnor, utan, vtan, orco);
|
||||
psys_interpolate_face(mesh_final,
|
||||
mvert,
|
||||
vert_normals,
|
||||
mface,
|
||||
mtface,
|
||||
orcodata,
|
||||
mapfw,
|
||||
vec,
|
||||
tmpnor,
|
||||
utan,
|
||||
vtan,
|
||||
orco);
|
||||
if (nor) {
|
||||
copy_v3_v3(nor, tmpnor);
|
||||
}
|
||||
@ -2175,8 +2188,18 @@ void psys_particle_on_dm(Mesh *mesh_final,
|
||||
add_v3_v3(vec, tmpnor);
|
||||
}
|
||||
else {
|
||||
psys_interpolate_face(
|
||||
mvert, vert_normals, mface, mtface, orcodata, mapfw, vec, nor, utan, vtan, orco);
|
||||
psys_interpolate_face(mesh_final,
|
||||
mvert,
|
||||
vert_normals,
|
||||
mface,
|
||||
mtface,
|
||||
orcodata,
|
||||
mapfw,
|
||||
vec,
|
||||
nor,
|
||||
utan,
|
||||
vtan,
|
||||
orco);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ static void distribute_from_volume_exec(ParticleTask *thread, ParticleData *pa,
|
||||
tot = mesh->totface;
|
||||
|
||||
psys_interpolate_face(
|
||||
mvert, BKE_mesh_vertex_normals_ensure(mesh), mface, 0, 0, pa->fuv, co, nor, 0, 0, 0);
|
||||
mesh, mvert, BKE_mesh_vertex_normals_ensure(mesh), mface, 0, 0, pa->fuv, co, nor, 0, 0, 0);
|
||||
|
||||
normalize_v3(nor);
|
||||
negate_v3(nor);
|
||||
@ -958,6 +958,9 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
/* After this #BKE_mesh_orco_verts_transform can be used safely from multiple threads. */
|
||||
BKE_mesh_texspace_ensure(final_mesh);
|
||||
|
||||
/* Create trees and original coordinates if needed */
|
||||
if (from == PART_FROM_CHILD) {
|
||||
distr = PART_DISTR_RAND;
|
||||
|
@ -174,7 +174,8 @@ void ABCHairWriter::write_hair_sample(const HierarchyContext &context,
|
||||
psys_interpolate_uvs(tface, face->v4, pa->fuv, r_uv);
|
||||
uv_values.emplace_back(r_uv[0], r_uv[1]);
|
||||
|
||||
psys_interpolate_face(mverts,
|
||||
psys_interpolate_face(mesh,
|
||||
mverts,
|
||||
vert_normals,
|
||||
face,
|
||||
tface,
|
||||
@ -289,7 +290,8 @@ void ABCHairWriter::write_hair_child_sample(const HierarchyContext &context,
|
||||
psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv);
|
||||
uv_values.emplace_back(r_uv[0], r_uv[1]);
|
||||
|
||||
psys_interpolate_face(mverts,
|
||||
psys_interpolate_face(mesh,
|
||||
mverts,
|
||||
vert_normals,
|
||||
face,
|
||||
tface,
|
||||
|
Loading…
Reference in New Issue
Block a user