fix [#28909] OpenCollada export / import sintel lite v2.1 crashes on import.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 14 Oct 2011 02:31:04 +0000 (02:31 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 14 Oct 2011 02:31:04 +0000 (02:31 +0000)
source/blender/collada/AnimationImporter.cpp
source/blender/makesrna/rna_cleanup/rna_cleaner.py
source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index 61f1b1dfa08d7c05b89c28fd5dda60dd3a8f0e54..f3a6e2371bb8feb1fc02d93003871388d77a9e76 100644 (file)
@@ -962,30 +962,32 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node ,
                        for (unsigned int j = 0; j < matBinds.getCount(); j++) {
                                const COLLADAFW::UniqueId & matuid = matBinds[j].getReferencedMaterial();
                                const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) (FW_object_map[matuid]);
-                               const COLLADAFW::CommonEffectPointerArray& commonEffects  =  ef->getCommonEffects();
-                               COLLADAFW::EffectCommon *efc = commonEffects[0];
-                               if((animType->material & MATERIAL_SHININESS) != 0){
-                                       const COLLADAFW::FloatOrParam *shin = &(efc->getShininess());
-                                       const COLLADAFW::UniqueId& listid =  shin->getAnimationList();
-                                       Assign_float_animations( listid, AnimCurves , "specular_hardness" );
-                               }
+                               if (ef != NULL) { /* can be NULL [#28909] */
+                                       const COLLADAFW::CommonEffectPointerArray& commonEffects  =  ef->getCommonEffects();
+                                       COLLADAFW::EffectCommon *efc = commonEffects[0];
+                                       if((animType->material & MATERIAL_SHININESS) != 0){
+                                               const COLLADAFW::FloatOrParam *shin = &(efc->getShininess());
+                                               const COLLADAFW::UniqueId& listid =  shin->getAnimationList();
+                                               Assign_float_animations( listid, AnimCurves , "specular_hardness" );
+                                       }
 
-                               if((animType->material & MATERIAL_IOR) != 0){
-                                       const COLLADAFW::FloatOrParam *ior = &(efc->getIndexOfRefraction());
-                                       const COLLADAFW::UniqueId& listid =  ior->getAnimationList();
-                                       Assign_float_animations( listid, AnimCurves , "raytrace_transparency.ior" );
-                               }
+                                       if((animType->material & MATERIAL_IOR) != 0){
+                                               const COLLADAFW::FloatOrParam *ior = &(efc->getIndexOfRefraction());
+                                               const COLLADAFW::UniqueId& listid =  ior->getAnimationList();
+                                               Assign_float_animations( listid, AnimCurves , "raytrace_transparency.ior" );
+                                       }
 
-                               if((animType->material & MATERIAL_SPEC_COLOR) != 0){
-                                       const COLLADAFW::ColorOrTexture *cot = &(efc->getSpecular());
-                                       const COLLADAFW::UniqueId& listid =  cot->getColor().getAnimationList();
-                                       Assign_color_animations( listid, AnimCurves , "specular_color" );
-                               }
+                                       if((animType->material & MATERIAL_SPEC_COLOR) != 0){
+                                               const COLLADAFW::ColorOrTexture *cot = &(efc->getSpecular());
+                                               const COLLADAFW::UniqueId& listid =  cot->getColor().getAnimationList();
+                                               Assign_color_animations( listid, AnimCurves , "specular_color" );
+                                       }
 
-                               if((animType->material & MATERIAL_DIFF_COLOR) != 0){
-                                       const COLLADAFW::ColorOrTexture *cot = &(efc->getDiffuse());
-                                       const COLLADAFW::UniqueId& listid =  cot->getColor().getAnimationList();
-                                       Assign_color_animations( listid, AnimCurves , "diffuse_color" );
+                                       if((animType->material & MATERIAL_DIFF_COLOR) != 0){
+                                               const COLLADAFW::ColorOrTexture *cot = &(efc->getDiffuse());
+                                               const COLLADAFW::UniqueId& listid =  cot->getColor().getAnimationList();
+                                               Assign_color_animations( listid, AnimCurves , "diffuse_color" );
+                                       }
                                }
                        }
                }       
@@ -1051,14 +1053,16 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
                for (unsigned int j = 0; j < matBinds.getCount(); j++) {
                        const COLLADAFW::UniqueId & matuid = matBinds[j].getReferencedMaterial();
                        const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) (FW_object_map[matuid]);
-                       const COLLADAFW::CommonEffectPointerArray& commonEffects  =  ef->getCommonEffects();
-                       if(!commonEffects.empty()) {
-                               COLLADAFW::EffectCommon *efc = commonEffects[0];
-                               types->material =  setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS);
-                               types->material =  setAnimType(&(efc->getSpecular().getColor()),(types->material), MATERIAL_SPEC_COLOR);
-                               types->material =  setAnimType(&(efc->getDiffuse().getColor()),(types->material), MATERIAL_DIFF_COLOR);
-                               // types->material =  setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY);
-                               types->material =  setAnimType(&(efc->getIndexOfRefraction()),(types->material), MATERIAL_IOR);
+                       if (ef != NULL) { /* can be NULL [#28909] */
+                               const COLLADAFW::CommonEffectPointerArray& commonEffects = ef->getCommonEffects();
+                               if(!commonEffects.empty()) {
+                                       COLLADAFW::EffectCommon *efc = commonEffects[0];
+                                       types->material =  setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS);
+                                       types->material =  setAnimType(&(efc->getSpecular().getColor()),(types->material), MATERIAL_SPEC_COLOR);
+                                       types->material =  setAnimType(&(efc->getDiffuse().getColor()),(types->material), MATERIAL_DIFF_COLOR);
+                                       // types->material =  setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY);
+                                       types->material =  setAnimType(&(efc->getIndexOfRefraction()),(types->material), MATERIAL_IOR);
+                               }
                        }
                }
        }
@@ -1067,10 +1071,10 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
 
 int AnimationImporter::setAnimType ( const COLLADAFW::Animatable * prop , int types, int addition)
 {
-               const COLLADAFW::UniqueId& listid =  prop->getAnimationList();
-               if (animlist_map.find(listid) != animlist_map.end()) 
-                               return types|addition;
-               else return types;
+       const COLLADAFW::UniqueId& listid =  prop->getAnimationList();
+       if (animlist_map.find(listid) != animlist_map.end())
+               return types|addition;
+       else return types;
 }              
 
 // Is not used anymore.
index ae17ade36d7507cc848689552ea11366f14152d6..5df6e9a86ffeb3bf831b7ab12b3ebde833471558 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3.1
+#! /usr/bin/env python3
 
 """
 This script is used to help cleaning RNA api.
index 8d2fe07b77476500142b4a2402d7d02571fda39c..89d95b5a62785b281b06fe3831b4ec34caac8a80 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python3.1
+#! /usr/bin/env python3
 
 import sys
 
index e6783d7c1061df5fa5991995f1ad3a49603bff3b..0f5176af60c7d4bb2a427a460ec49bf0d558046d 100644 (file)
@@ -1596,7 +1596,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
                                        objprop.m_boundclass = KX_BOUNDPOLYTOPE;
                                        break;
                                }
-                               // Object is not a mesh... fall through OB_BOUND_POLYH to 
+                               // Object is not a mesh... fall through OB_BOUND_TRIANGLE_MESH to
                                // OB_BOUND_SPHERE
                        case OB_BOUND_TRIANGLE_MESH:
                                if (blenderobject->type == OB_MESH)