MCPcopy Create free account
hub / github.com/OGRECave/ogre-next / overlayObject

Method overlayObject

OgreMain/src/OgreScriptCompiler.cpp:652–839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

650 }
651
652 void ScriptCompiler::overlayObject( const AbstractNodePtr &source, ObjectAbstractNode *dest )
653 {
654 if( source->type == ANT_OBJECT )
655 {
656 ObjectAbstractNode *src = static_cast<ObjectAbstractNode *>( source.get() );
657
658 // Overlay the environment of one on top the other first
659 for( map<String, String>::type::const_iterator i = src->getVariables().begin();
660 i != src->getVariables().end(); ++i )
661 {
662 std::pair<bool, String> var = dest->getVariable( i->first );
663 if( !var.first )
664 dest->setVariable( i->first, i->second );
665 }
666
667 // Create a vector storing each pairing of override between source and destination
668 vector<std::pair<AbstractNodePtr, AbstractNodeList::iterator> >::type overrides;
669 // A list of indices for each destination node tracks the minimum
670 // source node they can index-match against
671 map<ObjectAbstractNode *, size_t>::type indices;
672 // A map storing which nodes have overridden from the destination node
673 map<ObjectAbstractNode *, bool>::type overridden;
674
675 // Fill the vector with objects from the source node (base)
676 // And insert non-objects into the overrides list of the destination
677 AbstractNodeList::iterator insertPos = dest->children.begin();
678 for( AbstractNodeList::const_iterator i = src->children.begin(); i != src->children.end();
679 ++i )
680 {
681 if( ( *i )->type == ANT_OBJECT )
682 {
683 overrides.push_back( std::make_pair( *i, dest->children.end() ) );
684 }
685 else
686 {
687 AbstractNodePtr newNode( ( *i )->clone() );
688 newNode->parent = dest;
689 dest->overrides.push_back( newNode );
690 }
691 }
692
693 // Track the running maximum override index in the name-matching phase
694 size_t maxOverrideIndex = 0;
695
696 // Loop through destination children searching for name-matching overrides
697 for( AbstractNodeList::iterator i = dest->children.begin(); i != dest->children.end(); )
698 {
699 if( ( *i )->type == ANT_OBJECT )
700 {
701 // Start tracking the override index position for this object
702 size_t overrideIndex = 0;
703
704 ObjectAbstractNode *node = static_cast<ObjectAbstractNode *>( ( *i ).get() );
705 indices[node] = maxOverrideIndex;
706 overridden[node] = false;
707
708 // special treatment for materials with * in their name
709 bool nodeHasWildcard = node->name.find( '*' ) != String::npos;

Callers

nothing calls this directly

Calls 12

getVariableMethod · 0.80
setVariableMethod · 0.80
getMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
cloneMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected