Commit: 8d26f2c2228f0553972c0c3419bd570d02312780
Author: Sybren A. Stüvel
Date:   Tue May 23 12:29:58 2017 +0200
Branches: master
https://developer.blender.org/rB8d26f2c2228f0553972c0c3419bd570d02312780

Fix T51319: Alembic export crash w/simple child particles if Display value < 
100%

This was two-fold.

1) The export used viewport settings to obtain the particle cache, rather
   than render settings.
2) The child hair writer tried to obtain UV-coordinates from the parent
   chair, without checking whether those were available in the first place.

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

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 2d42c532c9b..8f8ed2019d5 100644
--- a/source/blender/alembic/intern/abc_hair.cc
+++ b/source/blender/alembic/intern/abc_hair.cc
@@ -76,7 +76,7 @@ void AbcHairWriter::do_write()
                return;
        }
 
-       DerivedMesh *dm = mesh_create_derived_view(m_scene, m_object, 
CD_MASK_MESH);
+       DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, 
CD_MASK_MESH);
        DM_ensure_tessface(dm);
 
        std::vector<Imath::V3f> verts;
@@ -251,44 +251,38 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh 
*dm,
        for (int p = 0; p < m_psys->totchild; ++p, ++pc) {
                path = cache[p];
 
-               if (part->from == PART_FROM_FACE) {
-                       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]);
+               if (part->from == PART_FROM_FACE &&
+                       part->childtype != PART_CHILD_PARTICLES &&
+                       mtface) {
+                       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;
                        }
-                       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;
 
-                               float r_uv[2], tmpnor[3], mapfw[4], vec[3];
+                       float r_uv[2], tmpnor[3], mapfw[4], vec[3];
 
-                               psys_interpolate_uvs(tface, face->v4, pc->fuv, 
r_uv);
-                               uv_values.push_back(Imath::V2f(r_uv[0], 
r_uv[1]));
+                       psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv);
+                       uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1]));
 
-                               psys_interpolate_face(mverts, face, tface, 
NULL, mapfw, vec, tmpnor, NULL, NULL, NULL, NULL);
+                       psys_interpolate_face(mverts, face, tface, NULL, mapfw, 
vec, tmpnor, NULL, NULL, NULL, NULL);
 
-                               /* Convert Z-up to Y-up. */
-                               norm_values.push_back(Imath::V3f(tmpnor[0], 
tmpnor[2], -tmpnor[1]));
-                       }
+                       /* Convert Z-up to Y-up. */
+                       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]);
+                       if (uv_values.size()) {
+                               uv_values.push_back(uv_values[pc->parent]);
+                       }
+                       if (norm_values.size()) {
+                               norm_values.push_back(norm_values[pc->parent]);
+                       }
                }
 
                int steps = path->segments + 1;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to