Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-03-02 19:12:56 +0300
committerJacques Lucke <jacques@blender.org>2022-03-02 19:12:56 +0300
commit2fb31f34af84c39116742e20a12222099cd0ff9a (patch)
tree82f1144a9380b18accc037b2f554db4ec1595368
parent216a215ba58ac67af5e7bfa334bbcef4e812ea3f (diff)
Fix T95692: incorrect interpolated children particle hair
Differential Revision: https://developer.blender.org/D14227
-rw-r--r--source/blender/blenkernel/BKE_particle.h3
-rw-r--r--source/blender/blenkernel/intern/particle.c33
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c5
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_hair.cc6
4 files changed, 38 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 804331a3412..d39796ddbd1 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -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,
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 4dba13ce4c2..80f0ecd6baa 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -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);
}
}
}
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index ba3f99a2800..d8da3b5a497 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -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;
diff --git a/source/blender/io/alembic/exporter/abc_writer_hair.cc b/source/blender/io/alembic/exporter/abc_writer_hair.cc
index e8c156a2b8d..035638dcb99 100644
--- a/source/blender/io/alembic/exporter/abc_writer_hair.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_hair.cc
@@ -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,