Browse Source

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

Mike Lilligreen 11 years ago
parent
commit
0a03bffddd
1 changed files with 15 additions and 2 deletions
  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 );
     }
 
-    // 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.
     setValueScale( valueScale );