瀏覽代碼

Fixes a crash bug when reading in ParticleAsset fields that do not have keys assigned

Mike Lilligreen 11 年之前
父節點
當前提交
0a03bffddd
共有 1 個文件被更改,包括 15 次插入2 次删除
  1. 15 2
      engine/source/2d/assets/ParticleAssetField.cc

+ 15 - 2
engine/source/2d/assets/ParticleAssetField.cc

@@ -670,8 +670,21 @@ void ParticleAssetField::onTamlCustomRead( const TamlCustomNode* pCustomNode )
         keys.push_back( key );
         keys.push_back( key );
     }
     }
 
 
-    // Set the value bounds.
-    setValueBounds( maxTime, minValue, maxValue, defaultValue );
+    // If value bounds are present but no keys, assign the field its default values.
+    if ( !keys.size() )
+    {
+        DataKey key;
+        key.mTime = getMinTime();
+        key.mValue = getDefaultValue();
+        keys.push_back( key );
+    }
+
+    // Did we read in any value bounds?
+    if ( mValueBoundsDirty )
+    {
+        // Set the value bounds.
+        setValueBounds( maxTime, minValue, maxValue, defaultValue );
+    }
 
 
     // Set the value scale.
     // Set the value scale.
     setValueScale( valueScale );
     setValueScale( valueScale );