X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene3d%2Fpublic-api%2Floader%2Fdli-loader.cpp;h=8eb596de9a9b80a4a915e8940f4474aa4e78aac6;hb=b48987716e9793bdc837507524325cae8067d008;hp=b5382e3667797bff522cb8df73301f7ce1e2a317;hpb=900f0f0169974d175e56b67b3761c1546ba90e19;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/public-api/loader/dli-loader.cpp b/dali-scene3d/public-api/loader/dli-loader.cpp index b5382e3..8eb596d 100644 --- a/dali-scene3d/public-api/loader/dli-loader.cpp +++ b/dali-scene3d/public-api/loader/dli-loader.cpp @@ -407,83 +407,86 @@ void DliLoader::Impl::ParseScene(LoadParams& params) // get index of root node. auto docRoot = mParser.GetRoot(); - - // Process resources first - these are shared - if(auto environments = docRoot->GetChild("environment")) + if(docRoot) { - ParseEnvironments(environments, output.mResources); // NOTE: must precede parsing of materials - } + // Process resources first - these are shared + if(auto environments = docRoot->GetChild("environment")) + { + ParseEnvironments(environments, output.mResources); // NOTE: must precede parsing of materials + } - if(auto meshes = docRoot->GetChild("meshes")) - { - ParseMeshes(meshes, output.mResources); - } + if(auto meshes = docRoot->GetChild("meshes")) + { + ParseMeshes(meshes, output.mResources); + } - if(auto shaders = docRoot->GetChild("shaders")) - { - ParseShaders(shaders, output.mResources); - } + if(auto shaders = docRoot->GetChild("shaders")) + { + ParseShaders(shaders, output.mResources); + } - if(auto materials = docRoot->GetChild("materials")) - { - ParseMaterials(materials, input.mConvertColorCode, output.mResources); - } + if(auto materials = docRoot->GetChild("materials")) + { + ParseMaterials(materials, input.mConvertColorCode, output.mResources); + } - for(auto& c : input.mPreNodeCategoryProcessors) - { - if(auto node = docRoot->GetChild(c.first)) + for(auto& c : input.mPreNodeCategoryProcessors) { - Property::Array array; - ParseProperties(*node, array); - c.second(std::move(array), mOnError); + if(auto node = docRoot->GetChild(c.first)) + { + Property::Array array; + ParseProperties(*node, array); + c.second(std::move(array), mOnError); + } } - } - // Process scenes - Index iScene = 0; // default scene - ReadIndex(docRoot->GetChild("scene"), iScene); + // Process scenes + Index iScene = 0; // default scene + ReadIndex(docRoot->GetChild("scene"), iScene); - auto tnScenes = RequireChild(docRoot, "scenes"); - auto tnNodes = RequireChild(docRoot, "nodes"); - ParseSceneInternal(iScene, tnScenes, tnNodes, params); + auto tnScenes = RequireChild(docRoot, "scenes"); + auto tnNodes = RequireChild(docRoot, "nodes"); + ParseSceneInternal(iScene, tnScenes, tnNodes, params); - ParseSkeletons(docRoot->GetChild("skeletons"), output.mScene, output.mResources); + ParseSkeletons(docRoot->GetChild("skeletons"), output.mScene, output.mResources); - output.mScene.EnsureUniqueSkinningShaderInstances(output.mResources); - output.mScene.EnsureUniqueBlendShapeShaderInstances(output.mResources); + output.mScene.EnsureUniqueSkinningShaderInstances(output.mResources); + output.mScene.EnsureUniqueBlendShapeShaderInstances(output.mResources); - // Ger cameras and lights - GetCameraParameters(output.mCameraParameters); - GetLightParameters(output.mLightParameters); + // Ger cameras and lights + GetCameraParameters(output.mCameraParameters); + GetLightParameters(output.mLightParameters); - // Post-node processors and animations last - for(auto& c : input.mPostNodeCategoryProcessors) - { - if(auto node = docRoot->GetChild(c.first)) + // Post-node processors and animations last + for(auto& c : input.mPostNodeCategoryProcessors) { - Property::Array array; - ParseProperties(*node, array); - c.second(std::move(array), mOnError); + if(auto node = docRoot->GetChild(c.first)) + { + Property::Array array; + ParseProperties(*node, array); + c.second(std::move(array), mOnError); + } } - } - if(auto animations = docRoot->GetChild("animations")) - { - ParseAnimations(animations, params); - } + if(auto animations = docRoot->GetChild("animations")) + { + ParseAnimations(animations, params); + } - if(!output.mAnimationDefinitions.empty()) - { - if(auto animationGroups = docRoot->GetChild("animationGroups")) + if(!output.mAnimationDefinitions.empty()) { - ParseAnimationGroups(animationGroups, params); + if(auto animationGroups = docRoot->GetChild("animationGroups")) + { + ParseAnimationGroups(animationGroups, params); + } } } } void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode* tnScenes, const Toolkit::TreeNode* tnNodes, LoadParams& params) { - auto getSceneRootIdx = [tnScenes, tnNodes](Index iScene) { + auto getSceneRootIdx = [tnScenes, tnNodes](Index iScene) + { auto tn = GetNthChild(tnScenes, iScene); // now a "scene" object if(!tn) { @@ -1192,19 +1195,25 @@ void DliLoader::Impl::ParseNodesInternal(const TreeNode* const nodes, Index inde ReadArcField(eRenderable, *arcNode); } - if(renderable) // process common properties of all renderables + register payload + if(renderable && eRenderable != nullptr) // process common properties of all renderables + register payload { // shader renderable->mShaderIdx = 0; auto eShader = eRenderable->GetChild("shader"); - resourceIds.push_back({ResourceType::Shader, eShader, renderable->mShaderIdx}); + if(eShader) + { + resourceIds.push_back({ResourceType::Shader, eShader, renderable->mShaderIdx}); + } // color if(modelNode) { modelNode->mMaterialIdx = 0; // must offer default of 0 auto eMaterial = eRenderable->GetChild("material"); - resourceIds.push_back({ResourceType::Material, eMaterial, modelNode->mMaterialIdx}); + if(eMaterial) + { + resourceIds.push_back({ResourceType::Material, eMaterial, modelNode->mMaterialIdx}); + } if(!ReadColorCodeOrColor(eRenderable, modelNode->mColor, params.input.mConvertColorCode)) {