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:
authorSybren A. Stüvel <sybren@stuvel.eu>2017-04-26 16:31:03 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2017-04-26 16:31:03 +0300
commit6ed15c5a41130b55cb57a43a8a9470a91d38c3d5 (patch)
tree723168c780abcfa4a455fb384a682b2d43246422 /source/blender/alembic
parent51e3a184ea329cc01c6a5d632895a82d8a4a1bec (diff)
Alembic export: support simple child hairs (Fix T51144)
Simple child hairs don't have a face index number assigned, so the call to dm->getTessFaceData(dm, num, CD_MFACE) would cause a crash. To work around this, UV and normal vectors are copied from the parent hair. I've also removed an unnecessary call to dm->getTessFaceArray(dm); Reviewers: kevindietrich Differential Revision: https://developer.blender.org/D2638
Diffstat (limited to 'source/blender/alembic')
-rw-r--r--source/blender/alembic/intern/abc_hair.cc30
1 files changed, 25 insertions, 5 deletions
diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc
index 9a974273a46..2d42c532c9b 100644
--- a/source/blender/alembic/intern/abc_hair.cc
+++ b/source/blender/alembic/intern/abc_hair.cc
@@ -241,7 +241,6 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm,
invert_m4_m4_safe(inv_mat, m_object->obmat);
MTFace *mtface = static_cast<MTFace *>(CustomData_get_layer(&dm->faceData, CD_MTFACE));
- MFace *mface = dm->getTessFaceArray(dm);
MVert *mverts = dm->getVertArray(dm);
ParticleCacheKey **cache = m_psys->childcache;
@@ -253,12 +252,25 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm,
path = cache[p];
if (part->from == PART_FROM_FACE) {
- const int num = pc->num;
+ if (part->childtype == PART_CHILD_PARTICLES || !mtface) {
+ /* Face index is unknown for these particles, so just take info
+ * from the parent. */
+ uv_values.push_back(uv_values[pc->parent]);
+ norm_values.push_back(norm_values[pc->parent]);
+ }
+ else {
+ const int num = pc->num;
+ if (num < 0) {
+ ABC_LOG(m_settings.logger)
+ << "Warning, child particle of hair system " << m_psys->name
+ << " has unknown face index of geometry of "<< (m_object->id.name + 2)
+ << ", skipping child hair." << std::endl;
+ continue;
+ }
- MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, num, CD_MFACE));
- MTFace *tface = mtface + num;
+ MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, num, CD_MFACE));
+ MTFace *tface = mtface + num;
- if (mface && mtface) {
float r_uv[2], tmpnor[3], mapfw[4], vec[3];
psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv);
@@ -270,6 +282,14 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm,
norm_values.push_back(Imath::V3f(tmpnor[0], tmpnor[2], -tmpnor[1]));
}
}
+ else {
+ ABC_LOG(m_settings.logger)
+ << "Unknown particle type " << part->from
+ << " for child hair of system " << m_psys->name
+ << std::endl;
+ uv_values.push_back(uv_values[pc->parent]);
+ norm_values.push_back(norm_values[pc->parent]);
+ }
int steps = path->segments + 1;
hvertices.push_back(steps);