X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene3d%2Fpublic-api%2Floader%2Fscene-definition.cpp;h=370e92668149a89e6d7c0dfebd92a3234aee60b1;hb=4e0cc5969cece69de5948be184a3af174ee1e567;hp=cf5aa61a187be20fdc9be62ab04a9e28f10b5645;hpb=45d0e1bdc59206f580a65fd868b9eb50d2049090;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/public-api/loader/scene-definition.cpp b/dali-scene3d/public-api/loader/scene-definition.cpp index cf5aa61..370e926 100644 --- a/dali-scene3d/public-api/loader/scene-definition.cpp +++ b/dali-scene3d/public-api/loader/scene-definition.cpp @@ -48,39 +48,50 @@ const std::map& GetCons { static const std::map sConstraintFactory = { {Property::Type::BOOLEAN, - [](Actor& a, Property::Index i) { - return Constraint::New(a, i, [](bool& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetBoolean(); }); + [](Actor& a, Property::Index i) + { + return Constraint::New(a, i, [](bool& current, const PropertyInputContainer& inputs) + { current = inputs[0]->GetBoolean(); }); }}, {Property::Type::INTEGER, - [](Actor& a, Property::Index i) { - return Constraint::New(a, i, [](int& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetInteger(); }); + [](Actor& a, Property::Index i) + { + return Constraint::New(a, i, [](int& current, const PropertyInputContainer& inputs) + { current = inputs[0]->GetInteger(); }); }}, {Property::Type::FLOAT, - [](Actor& a, Property::Index i) { + [](Actor& a, Property::Index i) + { return Constraint::New(a, i, EqualToConstraint()); }}, {Property::Type::VECTOR2, - [](Actor& a, Property::Index i) { + [](Actor& a, Property::Index i) + { return Constraint::New(a, i, EqualToConstraint()); }}, {Property::Type::VECTOR3, - [](Actor& a, Property::Index i) { + [](Actor& a, Property::Index i) + { return Constraint::New(a, i, EqualToConstraint()); }}, {Property::Type::VECTOR4, - [](Actor& a, Property::Index i) { + [](Actor& a, Property::Index i) + { return Constraint::New(a, i, EqualToConstraint()); }}, {Property::Type::MATRIX, - [](Actor& a, Property::Index i) { + [](Actor& a, Property::Index i) + { return Constraint::New(a, i, EqualToConstraint()); }}, {Property::Type::MATRIX3, - [](Actor& a, Property::Index i) { + [](Actor& a, Property::Index i) + { return Constraint::New(a, i, EqualToConstraint()); }}, {Property::Type::ROTATION, - [](Actor& a, Property::Index i) { + [](Actor& a, Property::Index i) + { return Constraint::New(a, i, EqualToConstraint()); }}, }; @@ -159,7 +170,7 @@ void AddJointDebugVisual(Actor aJoint) aJoint.SetVisible(true); } -#endif //DEBUG_JOINTS +#endif // DEBUG_JOINTS class ActorCreatorVisitor : public NodeDefinition::IVisitor { @@ -234,7 +245,8 @@ void SortAndDeduplicateRequests(std::vector& requests) ++iter; } while(true); - requests.erase(std::remove_if(requests.begin(), requests.end(), [](const RequestType& sscr) { return !sscr.mShader; }), + requests.erase(std::remove_if(requests.begin(), requests.end(), [](const RequestType& sscr) + { return !sscr.mShader; }), requests.end()); } @@ -371,7 +383,10 @@ void SceneDefinition::CountResourceRefs(Index iNode, const Customization::Choice void Register(ResourceType::Value type, Index id) { - ++(*refCounts)[type][id]; + if((!(*refCounts)[type].Empty()) && (id >= 0) && ((*refCounts)[type].Size() > id)) + { + ++(*refCounts)[type][id]; + } } }; @@ -479,15 +494,15 @@ bool SceneDefinition::ReparentNode(const std::string& name, const std::string& n auto& node = *nodePtr; auto iNode = std::distance(mNodes.data(), nodePtr); - DEBUG_ONLY(auto dumpNode = [](NodeDefinition const& n) { + DEBUG_ONLY(auto dumpNode = [](NodeDefinition const& n) + { std::ostringstream stream; stream << n.mName << " (" << n.mParentIdx << "):"; for(auto i : n.mChildren) { stream << i << ", "; } - LOGD(("%s", stream.str().c_str())); - };) + LOGD(("%s", stream.str().c_str())); };) // Remove node from children of previous parent (if any). if(node->mParentIdx != INVALID_INDEX) @@ -533,15 +548,16 @@ bool SceneDefinition::RemoveNode(const std::string& name) auto& thisNodes = mNodes; unsigned int numReset = 0; std::function&)> resetFn = - [&thisNodes, &resetFn, &numReset](std::unique_ptr& nd) { - LOGD(("resetting %d", &nd - thisNodes.data())); - for(auto i : nd->mChildren) - { - resetFn(thisNodes[i]); - } - nd.reset(); - ++numReset; - }; + [&thisNodes, &resetFn, &numReset](std::unique_ptr& nd) + { + LOGD(("resetting %d", &nd - thisNodes.data())); + for(auto i : nd->mChildren) + { + resetFn(thisNodes[i]); + } + nd.reset(); + ++numReset; + }; resetFn(*node); @@ -564,7 +580,8 @@ bool SceneDefinition::RemoveNode(const std::string& name) { INDEX_FOR_REMOVAL = INVALID_INDEX }; - auto offsetter = [&offsets](Index& i) { + auto offsetter = [&offsets](Index& i) + { auto iFind = std::lower_bound(offsets.begin(), offsets.end(), i); if(iFind != offsets.end() && *iFind == i) { @@ -604,7 +621,8 @@ bool SceneDefinition::RemoveNode(const std::string& name) void SceneDefinition::GetNodeModelStack(Index index, MatrixStack& model) const { auto& thisNodes = mNodes; - std::function buildStack = [&model, &thisNodes, &buildStack](int i) { + std::function buildStack = [&model, &thisNodes, &buildStack](int i) + { auto node = thisNodes[i].get(); if(node->mParentIdx != INVALID_INDEX) { @@ -619,7 +637,8 @@ NodeDefinition* SceneDefinition::FindNode(const std::string& name, Index* outInd { auto iBegin = mNodes.begin(); auto iEnd = mNodes.end(); - auto iFind = std::find_if(iBegin, iEnd, [&name](const std::unique_ptr& nd) { return nd->mName == name; }); + auto iFind = std::find_if(iBegin, iEnd, [&name](const std::unique_ptr& nd) + { return nd->mName == name; }); auto result = iFind != iEnd ? iFind->get() : nullptr; if(result && outIndex) @@ -633,7 +652,8 @@ const NodeDefinition* SceneDefinition::FindNode(const std::string& name, Index* { auto iBegin = mNodes.begin(); auto iEnd = mNodes.end(); - auto iFind = std::find_if(iBegin, iEnd, [&name](const std::unique_ptr& nd) { return nd->mName == name; }); + auto iFind = std::find_if(iBegin, iEnd, [&name](const std::unique_ptr& nd) + { return nd->mName == name; }); auto result = iFind != iEnd ? iFind->get() : nullptr; if(result && outIndex) @@ -647,7 +667,8 @@ Index SceneDefinition::FindNodeIndex(const NodeDefinition& node) const { auto iBegin = mNodes.begin(); auto iEnd = mNodes.end(); - auto iFind = std::find_if(iBegin, iEnd, [&node](const std::unique_ptr& n) { return n.get() == &node; }); + auto iFind = std::find_if(iBegin, iEnd, [&node](const std::unique_ptr& n) + { return n.get() == &node; }); return iFind != iEnd ? std::distance(iBegin, iFind) : INVALID_INDEX; } @@ -938,7 +959,8 @@ bool SceneDefinition::FindNode(const std::string& name, std::unique_ptr& nd) { return nd->mName == name; }) + auto iFind = std::find_if(mNodes.rbegin(), mNodes.rend(), [&name](const std::unique_ptr& nd) + { return nd->mName == name; }) .base(); const bool success = iFind != mNodes.begin();