Browse Source

Safeguard CollisionShape against empty models to prevent Bullet asserts.
Reset Font type to none when (re)loading.

Lasse Öörni 11 years ago
parent
commit
973b353a08

+ 2 - 2
Source/Engine/Physics/CollisionShape.cpp

@@ -933,7 +933,7 @@ void CollisionShape::UpdateShape()
             
             
         case SHAPE_TRIANGLEMESH:
         case SHAPE_TRIANGLEMESH:
             size_ = size_.Abs();
             size_ = size_.Abs();
-            if (model_)
+            if (model_ && model_->GetNumGeometries())
             {
             {
                 // Check the geometry cache
                 // Check the geometry cache
                 Pair<Model*, unsigned> id = MakePair(model_.Get(), lodLevel_);
                 Pair<Model*, unsigned> id = MakePair(model_.Get(), lodLevel_);
@@ -973,7 +973,7 @@ void CollisionShape::UpdateShape()
                 else
                 else
                     LOGWARNING("Could not find custom geometry component from node ID " + String(customGeometryID_) + " for convex shape creation");
                     LOGWARNING("Could not find custom geometry component from node ID " + String(customGeometryID_) + " for convex shape creation");
             }
             }
-            else if (model_)
+            else if (model_ && model_->GetNumGeometries())
             {
             {
                 // Check the geometry cache
                 // Check the geometry cache
                 Pair<Model*, unsigned> id = MakePair(model_.Get(), lodLevel_);
                 Pair<Model*, unsigned> id = MakePair(model_.Get(), lodLevel_);

+ 1 - 0
Source/Engine/Resource/ResourceCache.cpp

@@ -465,6 +465,7 @@ Resource* ResourceCache::GetResource(ShortStringHash type, const char* nameIn, b
 
 
     LOGDEBUG("Loading resource " + name);
     LOGDEBUG("Loading resource " + name);
     resource->SetName(file->GetName());
     resource->SetName(file->GetName());
+
     if (!resource->Load(*(file.Get())))
     if (!resource->Load(*(file.Get())))
     {
     {
         // Error should already been logged by corresponding resource descendant class
         // Error should already been logged by corresponding resource descendant class

+ 3 - 2
Source/Engine/UI/Font.cpp

@@ -408,7 +408,8 @@ bool Font::Load(Deserializer& source)
     Graphics* graphics = GetSubsystem<Graphics>();
     Graphics* graphics = GetSubsystem<Graphics>();
     if (!graphics)
     if (!graphics)
         return true;
         return true;
-        
+    
+    fontType_ = FONT_NONE;
     faces_.Clear();
     faces_.Clear();
     
     
     fontDataSize_ = source.GetSize();
     fontDataSize_ = source.GetSize();
@@ -625,7 +626,7 @@ FontFace* Font::GetFaceFreeType(int pointSize)
     
     
     if (!fontDataSize_)
     if (!fontDataSize_)
     {
     {
-        LOGERROR("Font not loaded");
+        LOGERROR("Could not create font face from zero size data");
         return 0;
         return 0;
     }
     }