2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-scene3d/public-api/loader/scene-definition.h>
22 #include <dali/devel-api/common/map-wrapper.h>
23 #include <dali/public-api/animation/constraints.h>
26 #include <dali-scene3d/internal/graphics/builtin-shader-extern-gen.h>
27 #include <dali-scene3d/internal/model-components/model-node-impl.h>
28 #include <dali-scene3d/public-api/loader/blend-shape-details.h>
29 #include <dali-scene3d/public-api/loader/skinning-details.h>
30 #include <dali-scene3d/public-api/loader/utils.h>
32 // #define DEBUG_SCENE_DEFINITION
33 // #define DEBUG_JOINTS
35 #if defined(DEBUG_SCENE_DEFINITION) || defined(DEBUG_JOINTS)
36 #define DEBUG_ONLY(x) x
41 #define LOGD(x) DEBUG_ONLY(printf x; printf("\n"); fflush(stdout))
43 namespace Dali::Scene3D::Loader
47 const std::map<Property::Type, Constraint (*)(Actor&, Property::Index)>& GetConstraintFactory()
49 static const std::map<Property::Type, Constraint (*)(Actor&, Property::Index)> sConstraintFactory = {
50 {Property::Type::BOOLEAN,
51 [](Actor& a, Property::Index i) {
52 return Constraint::New<bool>(a, i, [](bool& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetBoolean(); });
54 {Property::Type::INTEGER,
55 [](Actor& a, Property::Index i) {
56 return Constraint::New<int>(a, i, [](int& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetInteger(); });
58 {Property::Type::FLOAT,
59 [](Actor& a, Property::Index i) {
60 return Constraint::New<float>(a, i, EqualToConstraint());
62 {Property::Type::VECTOR2,
63 [](Actor& a, Property::Index i) {
64 return Constraint::New<Vector2>(a, i, EqualToConstraint());
66 {Property::Type::VECTOR3,
67 [](Actor& a, Property::Index i) {
68 return Constraint::New<Vector3>(a, i, EqualToConstraint());
70 {Property::Type::VECTOR4,
71 [](Actor& a, Property::Index i) {
72 return Constraint::New<Vector4>(a, i, EqualToConstraint());
74 {Property::Type::MATRIX,
75 [](Actor& a, Property::Index i) {
76 return Constraint::New<Matrix>(a, i, EqualToConstraint());
78 {Property::Type::MATRIX3,
79 [](Actor& a, Property::Index i) {
80 return Constraint::New<Matrix3>(a, i, EqualToConstraint());
82 {Property::Type::ROTATION,
83 [](Actor& a, Property::Index i) {
84 return Constraint::New<Quaternion>(a, i, EqualToConstraint());
87 return sConstraintFactory;
90 struct ResourceReflector : IResourceReflector
92 Index* iMesh = nullptr;
93 Index* iShader = nullptr;
95 void Reflect(ResourceType::Value type, Index& id)
99 case ResourceType::Shader:
100 DALI_ASSERT_ALWAYS(!iShader && "Shader index already assigned!");
104 case ResourceType::Mesh:
105 DALI_ASSERT_ALWAYS(!iMesh && "Mesh index already assigned!");
109 default: // Other resource types are not relevant to the problem at hand.
117 Shader sJointDebugShader;
120 void EnsureJointDebugShaderCreated()
124 sJointDebugShader = Shader::New(SHADER_SCENE3D_JOINT_DEBUG_VERT, SHADER_SCENE3D_JOINT_DEBUG_FRAG, Shader::Hint::NONE, "SCENE3D_JOINT_DEBUG");
129 void AddJointDebugVisual(Actor aJoint)
131 Property::Map attribs;
132 attribs["aPosition"] = Property::Type::VECTOR3;
133 attribs["aColor"] = Property::Type::FLOAT;
135 PropertyBuffer vbo = PropertyBuffer::New(attribs);
142 {Vector3::ZERO, .999f + .999f * 256.f + .999f * 256.f * 256.f},
143 {Vector3::XAXIS, .999f},
144 {Vector3::YAXIS, .999f * 256.f},
145 {Vector3::ZAXIS, .999f * 256.f * 256.f},
148 vbo.SetData(&vertices, std::extent<decltype(vertices)>::value);
150 uint16_t indices[] = {0, 1, 0, 2, 0, 3};
152 Geometry geo = Geometry::New();
153 geo.AddVertexBuffer(vbo);
154 geo.SetIndexBuffer(indices, std::extent<decltype(indices)>::value);
155 geo.SetType(Geometry::LINES);
157 Renderer r = Renderer::New(geo, sJointDebugShader);
158 aJoint.AddRenderer(r);
160 aJoint.SetVisible(true);
162 #endif // DEBUG_JOINTS
164 class ActorCreatorVisitor : public NodeDefinition::IVisitor
167 ActorCreatorVisitor(NodeDefinition::CreateParams& params)
168 : mCreationContext(params)
172 void Start(NodeDefinition& n)
174 mCreationContext.mXforms.modelStack.Push(n.GetLocalSpace());
176 ModelNode a = n.CreateModelNode(mCreationContext);
177 if(!mActorStack.empty())
179 mActorStack.back().Add(a);
185 mActorStack.push_back(a);
188 void Finish(NodeDefinition& n)
190 mActorStack.pop_back();
191 mCreationContext.mXforms.modelStack.Pop();
194 ModelNode GetRoot() const
200 NodeDefinition::CreateParams& mCreationContext;
201 std::vector<ModelNode> mActorStack;
205 template<typename RequestType>
206 void SortAndDeduplicateRequests(std::vector<RequestType>& requests)
208 // Sort requests by shaders and primitives.
209 std::sort(requests.begin(), requests.end());
211 // Remove duplicates.
212 auto iter = requests.begin();
213 auto iterEnd = requests.end();
215 Shader shader = iter->mShader;
216 ModelPrimitive modelPrimitive = iter->mPrimitive;
220 // Multiple identical shader and primitive instances are removed.
221 while(iter != iterEnd && iter->mShader == shader && iter->mPrimitive == modelPrimitive)
224 iter->mShader = Shader();
232 shader = iter->mShader;
233 modelPrimitive = iter->mPrimitive;
237 requests.erase(std::remove_if(requests.begin(), requests.end(), [](const RequestType& sscr) { return !sscr.mShader; }),
241 void ConfigureBoneMatrix(const Matrix& ibm, ModelNode joint, ModelPrimitive primitive, Index& boneIdx)
243 // Register bone transform on shader.
244 Internal::GetImplementation(joint).SetBoneMatrix(ibm, primitive, boneIdx);
248 template<class Visitor, class SceneDefinition>
249 void VisitInternal(Index iNode, const Customization::Choices& choices, Visitor& v, SceneDefinition& sd)
251 auto& node = *sd.GetNode(iNode);
254 if(node.mCustomization)
256 if(!node.mChildren.empty())
258 auto choice = choices.Get(node.mCustomization->mTag);
259 Index i = std::min(choice != Customization::NONE ? choice : 0, static_cast<Index>(node.mChildren.size() - 1));
260 sd.Visit(node.mChildren[i], choices, v);
265 for(auto i : node.mChildren)
267 sd.Visit(i, choices, v);
276 SceneDefinition::SceneDefinition()
281 EnsureJointDebugShaderCreated();
285 SceneDefinition::SceneDefinition(SceneDefinition&& other)
286 : mNodes(std::move(other.mNodes)),
287 mRootNodeIds(std::move(other.mRootNodeIds))
290 EnsureJointDebugShaderCreated();
294 SceneDefinition::~SceneDefinition()
300 sJointDebugShader = Shader();
305 uint32_t Dali::Scene3D::Loader::SceneDefinition::AddRootNode(Index iNode)
307 if(iNode < mNodes.size())
309 uint32_t result = mRootNodeIds.size();
310 mRootNodeIds.push_back(iNode);
315 ExceptionFlinger(ASSERT_LOCATION) << "Failed to add new root with node " << iNode << " -- index out of bounds.";
320 const std::vector<Index>& SceneDefinition::GetRoots() const
325 void SceneDefinition::RemoveRootNode(Index iRoot)
327 if(iRoot < mRootNodeIds.size())
329 mRootNodeIds.erase(mRootNodeIds.begin() + iRoot);
333 ExceptionFlinger(ASSERT_LOCATION) << "Failed to remove root " << iRoot << " -- index out of bounds.";
337 uint32_t SceneDefinition::GetNodeCount() const
339 return mNodes.size();
342 const NodeDefinition* SceneDefinition::GetNode(Index iNode) const
344 return mNodes[iNode].get();
347 NodeDefinition* SceneDefinition::GetNode(Index iNode)
349 if(iNode != Scene3D::Loader::INVALID_INDEX && iNode < mNodes.size())
351 return mNodes[iNode].get();
356 void SceneDefinition::Visit(Index iNode, const Customization::Choices& choices, NodeDefinition::IVisitor& v)
358 VisitInternal(iNode, choices, v, *this);
361 void SceneDefinition::Visit(Index iNode, const Customization::Choices& choices, NodeDefinition::IConstVisitor& v) const
363 VisitInternal(iNode, choices, v, *this);
366 void SceneDefinition::CountResourceRefs(Index iNode, const Customization::Choices& choices, ResourceRefCounts& refCounts) const
368 struct RefCounter : IResourceReceiver
370 ResourceRefCounts* refCounts;
372 void Register(ResourceType::Value type, Index id)
374 if((!(*refCounts)[type].Empty()) && ((*refCounts)[type].Size() > id))
376 ++(*refCounts)[type][id];
381 struct : NodeDefinition::IConstVisitor
385 void Start(const NodeDefinition& n)
387 for(auto& renderable : n.mRenderables)
389 renderable->RegisterResources(counter);
393 void Finish(const NodeDefinition& n)
398 refCounterVisitor.counter.refCounts = &refCounts;
400 Visit(iNode, choices, refCounterVisitor);
403 ModelNode SceneDefinition::CreateNodes(Index iNode, const Customization::Choices& choices, NodeDefinition::CreateParams& params)
405 ActorCreatorVisitor actorCreatorVisitor(params);
407 Visit(iNode, choices, actorCreatorVisitor);
409 return actorCreatorVisitor.GetRoot();
412 void SceneDefinition::GetCustomizationOptions(const Customization::Choices& choices,
413 Customization::Map& outCustomizationOptions,
414 Customization::Choices* outMissingChoices) const
416 struct : NodeDefinition::IConstVisitor
418 const Customization::Choices* choices; // choices that we know about.
419 Customization::Map* options; // tags are registered here. NO OWNERSHIP.
420 Customization::Choices* missingChoices; // tags will be registered with the default 0. NO OWNERSHIP.
422 void Start(const NodeDefinition& n)
426 const std::string& tag = n.mCustomization->mTag;
427 if(missingChoices != nullptr && choices->Get(tag) == Customization::NONE)
429 missingChoices->Set(tag, 0);
432 auto customization = options->Get(tag);
435 customization = options->Set(tag, {});
437 customization->nodes.push_back(n.mName);
438 customization->numOptions = std::max(customization->numOptions,
439 static_cast<uint32_t>(n.mChildren.size()));
443 void Finish(const NodeDefinition& n)
447 } customizationRegistrationVisitor;
448 customizationRegistrationVisitor.choices = &choices;
449 customizationRegistrationVisitor.options = &outCustomizationOptions;
450 customizationRegistrationVisitor.missingChoices = outMissingChoices;
452 for(auto i : mRootNodeIds)
454 Visit(i, choices, customizationRegistrationVisitor);
458 NodeDefinition* SceneDefinition::AddNode(std::unique_ptr<NodeDefinition>&& nodeDef)
460 // add next index (to which we're about to push) as a child to the designated parent, if any.
461 if(nodeDef->mParentIdx != INVALID_INDEX)
463 mNodes[nodeDef->mParentIdx]->mChildren.push_back(mNodes.size());
466 mNodes.push_back(std::move(nodeDef));
468 return mNodes.back().get();
471 bool SceneDefinition::ReparentNode(const std::string& name, const std::string& newParentName, Index siblingOrder)
473 LOGD(("reparenting %s to %s @ %d", name.c_str(), newParentName.c_str(), siblingOrder));
475 std::unique_ptr<NodeDefinition>* nodePtr = nullptr;
476 std::unique_ptr<NodeDefinition>* newParentPtr = nullptr;
477 if(!FindNode(name, &nodePtr) || !FindNode(newParentName, &newParentPtr))
482 auto& node = *nodePtr;
483 auto iNode = std::distance(mNodes.data(), nodePtr);
485 DEBUG_ONLY(auto dumpNode = [](NodeDefinition const& n) {
486 std::ostringstream stream;
487 stream << n.mName << " (" << n.mParentIdx << "):";
488 for(auto i : n.mChildren)
492 LOGD(("%s", stream.str().c_str())); };)
494 // Remove node from children of previous parent (if any).
495 if(node->mParentIdx != INVALID_INDEX)
497 LOGD(("old parent:"));
498 DEBUG_ONLY(dumpNode(*mNodes[node->mParentIdx]);)
500 auto& children = mNodes[node->mParentIdx]->mChildren;
501 children.erase(std::remove(children.begin(), children.end(), iNode), children.end());
503 DEBUG_ONLY(dumpNode(*mNodes[node->mParentIdx]);)
506 // Register node to new parent.
507 LOGD(("new parent:"));
508 DEBUG_ONLY(dumpNode(**newParentPtr);)
509 auto& children = (*newParentPtr)->mChildren;
510 if(siblingOrder > children.size())
512 siblingOrder = children.size();
514 children.insert(children.begin() + siblingOrder, 1, iNode);
515 DEBUG_ONLY(dumpNode(**newParentPtr);)
517 // Update parent index.
519 DEBUG_ONLY(dumpNode(*node);)
520 auto iParent = std::distance(mNodes.data(), newParentPtr);
521 node->mParentIdx = iParent;
522 DEBUG_ONLY(dumpNode(*node);)
526 bool SceneDefinition::RemoveNode(const std::string& name)
528 std::unique_ptr<NodeDefinition>* node = nullptr;
529 if(!FindNode(name, &node))
534 // Reset node def pointers recursively.
535 auto& thisNodes = mNodes;
536 unsigned int numReset = 0;
537 std::function<void(std::unique_ptr<NodeDefinition>&)> resetFn =
538 [&thisNodes, &resetFn, &numReset](std::unique_ptr<NodeDefinition>& nd) {
539 LOGD(("resetting %d", &nd - thisNodes.data()));
540 for(auto i : nd->mChildren)
542 resetFn(thisNodes[i]);
550 // Gather indices of dead nodes into a vector which we sort on insertion.
551 std::vector<Index> offsets;
552 offsets.reserve(numReset);
553 for(auto& n : mNodes)
557 offsets.push_back(std::distance(mNodes.data(), &n));
561 // Erase dead nodes as they don't have to be processed anymore.
562 mNodes.erase(std::remove(mNodes.begin(), mNodes.end(), decltype(mNodes)::value_type()), mNodes.end());
564 // Offset all indices (parent and child) by the index they'd sort into in offsets.
567 INDEX_FOR_REMOVAL = INVALID_INDEX
569 auto offsetter = [&offsets](Index& i) {
570 auto iFind = std::lower_bound(offsets.begin(), offsets.end(), i);
571 if(iFind != offsets.end() && *iFind == i)
573 LOGD(("marking %d for removal.", i));
574 i = INDEX_FOR_REMOVAL;
579 auto distance = std::distance(offsets.begin(), iFind);
582 LOGD(("offsetting %d by %d.", i, distance));
589 for(auto& nd : mNodes)
591 bool parentOffsetResult = offsetter(nd->mParentIdx);
592 DALI_ASSERT_ALWAYS(parentOffsetResult); // since nodes were recursively removed, we should not be finding invalid parents at this point.
594 auto& children = nd->mChildren;
595 for(auto i0 = children.begin(), i1 = children.end(); i0 != i1; ++i0)
600 children.erase(std::remove(children.begin(), children.end(), INDEX_FOR_REMOVAL), children.end());
606 void SceneDefinition::GetNodeModelStack(Index index, MatrixStack& model) const
608 auto& thisNodes = mNodes;
609 std::function<void(int)> buildStack = [&model, &thisNodes, &buildStack](int i) {
610 auto node = thisNodes[i].get();
611 if(node->mParentIdx != INVALID_INDEX)
613 buildStack(node->mParentIdx);
615 model.Push(node->GetLocalSpace());
620 NodeDefinition* SceneDefinition::FindNode(const std::string& name, Index* outIndex)
622 auto iBegin = mNodes.begin();
623 auto iEnd = mNodes.end();
624 auto iFind = std::find_if(iBegin, iEnd, [&name](const std::unique_ptr<NodeDefinition>& nd) { return nd->mName == name; });
626 auto result = iFind != iEnd ? iFind->get() : nullptr;
627 if(result && outIndex)
629 *outIndex = std::distance(iBegin, iFind);
634 const NodeDefinition* SceneDefinition::FindNode(const std::string& name, Index* outIndex) const
636 auto iBegin = mNodes.begin();
637 auto iEnd = mNodes.end();
638 auto iFind = std::find_if(iBegin, iEnd, [&name](const std::unique_ptr<NodeDefinition>& nd) { return nd->mName == name; });
640 auto result = iFind != iEnd ? iFind->get() : nullptr;
641 if(result && outIndex)
643 *outIndex = std::distance(iBegin, iFind);
648 Index SceneDefinition::FindNodeIndex(const NodeDefinition& node) const
650 auto iBegin = mNodes.begin();
651 auto iEnd = mNodes.end();
652 auto iFind = std::find_if(iBegin, iEnd, [&node](const std::unique_ptr<NodeDefinition>& n) { return n.get() == &node; });
653 return iFind != iEnd ? std::distance(iBegin, iFind) : INVALID_INDEX;
656 void SceneDefinition::FindNodes(NodePredicate predicate, NodeConsumer consumer, unsigned int limit)
659 for(auto& defp : mNodes)
673 void SceneDefinition::FindNodes(NodePredicate predicate, ConstNodeConsumer consumer, unsigned int limit) const
676 for(auto& defp : mNodes)
690 void SceneDefinition::ApplyConstraints(Actor& root,
691 std::vector<ConstraintRequest>&& constrainables,
692 StringCallback onError) const
694 for(auto& cr : constrainables)
696 auto& nodeDef = mNodes[cr.mConstraint->mSourceIdx];
697 auto sourceName = nodeDef->mName.c_str();
698 Property::Index iTarget = cr.mTarget.GetPropertyIndex(cr.mConstraint->mProperty);
699 if(iTarget != Property::INVALID_INDEX)
701 auto propertyType = cr.mTarget.GetPropertyType(iTarget);
702 auto iFind = GetConstraintFactory().find(propertyType);
703 if(iFind == GetConstraintFactory().end())
705 onError(FormatString("node '%s': Property '%s' has unsupported type '%s'; ignored.",
707 cr.mConstraint->mProperty.c_str(),
708 PropertyTypes::GetName(propertyType)));
712 Constraint constraint = iFind->second(cr.mTarget, iTarget);
714 Actor source = root.FindChildByName(nodeDef->mName);
717 auto targetName = cr.mTarget.GetProperty(Actor::Property::NAME).Get<std::string>();
718 onError(FormatString("node '%s': Failed to locate constraint source %s@%s; ignored.",
720 cr.mConstraint->mProperty.c_str(),
721 targetName.c_str()));
724 else if(source == cr.mTarget)
726 onError(FormatString("node '%s': Cyclic constraint definition for property '%s'; ignored.",
728 cr.mConstraint->mProperty.c_str()));
732 Property::Index iSource = source.GetPropertyIndex(cr.mConstraint->mProperty);
733 constraint.AddSource(Source{source, iSource});
738 auto targetName = cr.mTarget.GetProperty(Actor::Property::NAME).Get<std::string>();
739 onError(FormatString("node '%s': Failed to create constraint for property %s@%s; ignored.",
741 cr.mConstraint->mProperty.c_str(),
742 targetName.c_str()));
747 void SceneDefinition::EnsureUniqueSkinningShaderInstances(ResourceBundle& resources) const
749 std::map<Index, std::map<Index, std::vector<Index*>>> skinningShaderUsers;
750 for(auto& node : mNodes)
752 for(auto& renderable : node->mRenderables)
754 ResourceReflector reflector;
755 renderable->ReflectResources(reflector);
759 const auto& mesh = resources.mMeshes[*reflector.iMesh].first;
762 skinningShaderUsers[*reflector.iShader][mesh.mSkeletonIdx].push_back(reflector.iShader);
768 // For each shader, and each skeleton using the same shader as the first skeleton,
769 // update the shader references (from nodes with skinned meshes) with a new copy of
770 // the shader definition from the node using the first skeleton.
771 for(auto& users : skinningShaderUsers)
773 auto& skeletons = users.second;
774 auto iterSkeleton = skeletons.begin();
775 // skipping the first skeleton.
778 resources.mShaders.reserve(resources.mShaders.size() + std::distance(iterSkeleton, skeletons.end()));
779 const ShaderDefinition& shaderDef = resources.mShaders[users.first].first;
781 while(iterSkeleton != skeletons.end())
783 Index iShader = resources.mShaders.size();
784 resources.mShaders.push_back({shaderDef, Shader()});
786 for(auto& i : iterSkeleton->second)
795 void SceneDefinition::ConfigureSkinningShaders(const ResourceBundle& resources,
797 std::vector<SkinningShaderConfigurationRequest>&& requests) const
804 SortAndDeduplicateRequests(requests);
806 for(auto& request : requests)
808 auto& skeleton = resources.mSkeletons[request.mSkeletonIdx];
809 if(skeleton.mJoints.empty())
811 LOGD(("Skeleton %d has no joints.", request.mSkeletonIdx));
816 for(auto& joint : skeleton.mJoints)
818 auto node = GetNode(joint.mNodeIdx);
819 ModelNode modelNode = ModelNode::DownCast(rootActor.FindChildByName(node->mName));
824 ConfigureBoneMatrix(joint.mInverseBindMatrix, modelNode, request.mPrimitive, boneIdx);
829 bool SceneDefinition::ConfigureBlendshapeShaders(const ResourceBundle& resources,
831 std::vector<BlendshapeShaderConfigurationRequest>&& requests,
832 StringCallback onError) const
839 SortAndDeduplicateRequests(requests);
841 // Configure the rest.
844 for(auto& request : requests)
847 if(FindNode(request.mNodeName, &iNode))
849 const auto& node = GetNode(iNode);
851 const auto& mesh = resources.mMeshes[request.mMeshIdx];
853 if(mesh.first.HasBlendShapes())
855 Actor actor = rootActor.FindChildByName(node->mName);
856 Scene3D::ModelNode node = Scene3D::ModelNode::DownCast(actor);
861 BlendShapes::BlendShapeData data;
862 data.components = 0x0;
863 for(auto&& blendShape : mesh.first.mBlendShapes)
865 data.names.push_back(blendShape.name);
866 data.weights.push_back(blendShape.weight);
867 data.components |= (blendShape.deltas.IsDefined() * BlendShapes::Component::POSITIONS) |
868 (blendShape.normals.IsDefined() * BlendShapes::Component::NORMALS) | (blendShape.tangents.IsDefined() * BlendShapes::Component::TANGENTS);
870 for(auto&& factor : mesh.second.blendShapeUnnormalizeFactor)
872 data.unnormalizeFactors.push_back(factor);
874 data.version = mesh.first.mBlendShapeVersion;
875 data.bufferOffset = mesh.second.blendShapeBufferOffset;
877 Internal::GetImplementation(node).SetBlendShapeData(data, request.mPrimitive);
885 void SceneDefinition::EnsureUniqueBlendShapeShaderInstances(ResourceBundle& resources) const
887 std::map<Index, std::map<std::string, std::vector<Index*>>> blendShapeShaderUsers;
888 for(auto& node : mNodes)
890 for(auto& renderable : node->mRenderables)
892 ResourceReflector reflector;
893 renderable->ReflectResources(reflector);
897 const auto& mesh = resources.mMeshes[*reflector.iMesh].first;
898 if(mesh.HasBlendShapes())
900 blendShapeShaderUsers[*reflector.iShader][node->mName].push_back(reflector.iShader);
906 for(auto& users : blendShapeShaderUsers)
908 resources.mShaders.reserve(resources.mShaders.size() + users.second.size() - 1u);
909 const ShaderDefinition& shaderDef = resources.mShaders[users.first].first;
911 auto nodesIt = users.second.begin();
912 auto nodesEndIt = users.second.end();
913 // skipping the first node.
915 while(nodesIt != nodesEndIt)
917 Index iShader = resources.mShaders.size();
918 resources.mShaders.push_back({shaderDef, Shader()});
920 auto& nodes = *nodesIt;
921 for(auto& shader : nodes.second)
930 SceneDefinition& SceneDefinition::operator=(SceneDefinition&& other)
932 SceneDefinition temp(std::move(other));
933 std::swap(mNodes, temp.mNodes);
934 std::swap(mRootNodeIds, temp.mRootNodeIds);
938 bool SceneDefinition::FindNode(const std::string& name, std::unique_ptr<NodeDefinition>** result)
940 // We're searching from the end assuming a higher probability of operations targeting
941 // recently added nodes. (conf.: root, which is immovable, cannot be removed, and was
942 // the first to be added, is index 0.)
943 auto iFind = std::find_if(mNodes.rbegin(), mNodes.rend(), [&name](const std::unique_ptr<NodeDefinition>& nd) { return nd->mName == name; })
946 const bool success = iFind != mNodes.begin();
947 if(success && result)
956 } // namespace Dali::Scene3D::Loader