[Bf-blender-cvs] [6f0d2216c39] cycles_procedural_api: fix crashes when reading attributes

Kévin Dietrich noreply at git.blender.org
Sun Dec 6 06:26:30 CET 2020


Commit: 6f0d2216c39bd32b9797839fb7b7d5077f45ff6d
Author: Kévin Dietrich
Date:   Fri Dec 4 17:40:01 2020 +0100
Branches: cycles_procedural_api
https://developer.blender.org/rB6f0d2216c39bd32b9797839fb7b7d5077f45ff6d

fix crashes when reading attributes

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

M	intern/cycles/render/alembic.cpp
M	intern/cycles/render/alembic.h

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

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index ce0b1dcceba..3244a767372 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -206,10 +206,15 @@ static void add_uvs(const IV2fGeomParam &uvs, CachedData &cached_data, Progress
     return;
   }
 
-  const TimeSamplingPtr time_sampling = uvs.getTimeSampling();
+  const TimeSamplingPtr time_sampling_ptr = uvs.getTimeSampling();
+
+  TimeSampling time_sampling;
+  if (time_sampling_ptr) {
+    time_sampling = *time_sampling_ptr;
+  }
 
   CachedData::CachedAttribute &attr = cached_data.add_attribute(ustring(uvs.getName()),
-                                                                *time_sampling);
+                                                                time_sampling);
   attr.std = ATTR_STD_UV;
 
   for (size_t i = 0; i < uvs.getNumSamples(); ++i) {
@@ -220,7 +225,7 @@ static void add_uvs(const IV2fGeomParam &uvs, CachedData &cached_data, Progress
     const ISampleSelector iss = ISampleSelector(index_t(i));
     const IV2fGeomParam::Sample sample = uvs.getExpandedValue(iss);
 
-    const double time = time_sampling->getSampleTime(index_t(i));
+    const double time = time_sampling.getSampleTime(index_t(i));
 
     const IV2fGeomParam::Sample uvsample = uvs.getIndexedValue(iss);
 
@@ -870,15 +875,15 @@ void AlembicObject::read_attribute(const ICompoundProperty &arb_geom_params,
     return;
   }
 
-  CachedData::CachedAttribute &attribute = cached_data.add_attribute(attr_name,
-                                                                     *prop->getTimeSampling());
-
   if (IV2fProperty::matches(prop->getMetaData()) && Alembic::AbcGeom::isUV(*prop)) {
     const IV2fGeomParam &param = IV2fGeomParam(arb_geom_params, prop->getName());
 
     IV2fGeomParam::Sample sample;
     param.getIndexed(sample, iss);
 
+    CachedData::CachedAttribute &attribute = cached_data.add_attribute(attr_name,
+                                                                       *param.getTimeSampling());
+
     const chrono_t time = param.getTimeSampling()->getSampleTime(index);
 
     if (param.getScope() == kFacevaryingScope) {
@@ -923,6 +928,9 @@ void AlembicObject::read_attribute(const ICompoundProperty &arb_geom_params,
     IC3fGeomParam::Sample sample;
     param.getIndexed(sample, iss);
 
+    CachedData::CachedAttribute &attribute = cached_data.add_attribute(attr_name,
+                                                                       *param.getTimeSampling());
+
     const chrono_t time = param.getTimeSampling()->getSampleTime(index);
 
     C3fArraySamplePtr values = sample.getVals();
@@ -968,6 +976,9 @@ void AlembicObject::read_attribute(const ICompoundProperty &arb_geom_params,
     IC4fGeomParam::Sample sample;
     param.getIndexed(sample, iss);
 
+    CachedData::CachedAttribute &attribute = cached_data.add_attribute(attr_name,
+                                                                       *param.getTimeSampling());
+
     const chrono_t time = param.getTimeSampling()->getSampleTime(index);
 
     C4fArraySamplePtr values = sample.getVals();
diff --git a/intern/cycles/render/alembic.h b/intern/cycles/render/alembic.h
index 5ee68404e41..5b3bc167392 100644
--- a/intern/cycles/render/alembic.h
+++ b/intern/cycles/render/alembic.h
@@ -215,7 +215,7 @@ struct CachedData {
       }
     }
 
-    auto &attr = attributes.emplace_back();
+    CachedAttribute &attr = attributes.emplace_back();
     attr.name = name;
     attr.data.set_time_sampling(time_sampling);
     return attr;



More information about the Bf-blender-cvs mailing list