Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-10-14 06:31:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-14 06:31:04 +0400
commit0c0259d93100bdbcd19c4c9deda6799de2a1f075 (patch)
tree98b2174b93a076e685e9daadf4c4ca66276e64c4 /source/blender/collada
parent9e17ecf0100af4e95f32a7b03673e880a9fc8d1e (diff)
fix [#28909] OpenCollada export / import sintel lite v2.1 crashes on import.
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/AnimationImporter.cpp70
1 files changed, 37 insertions, 33 deletions
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 61f1b1dfa08..f3a6e2371bb 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -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.