[Bf-blender-cvs] [6ed15c5a411] master: Alembic export: support simple child hairs (Fix T51144)

Sybren A. Stüvel noreply at git.blender.org
Wed Apr 26 15:33:24 CEST 2017


Commit: 6ed15c5a41130b55cb57a43a8a9470a91d38c3d5
Author: Sybren A. Stüvel
Date:   Wed Apr 26 15:31:03 2017 +0200
Branches: master
https://developer.blender.org/rB6ed15c5a41130b55cb57a43a8a9470a91d38c3d5

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

===================================================================

M	source/blender/alembic/intern/abc_hair.cc

===================================================================

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);




More information about the Bf-blender-cvs mailing list