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
This commit is contained in:
parent
51e3a184ea
commit
6ed15c5a41
Notes:
blender-bot
2023-02-14 07:05:00 +01:00
Referenced by issue #51144, Alembic export with multires and hair crash blender
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue