<commit_before>//
//  poScene.cpp
//  BasicTest
//
//  Created by <NAME> on 3/17/14.
//
//
#include "cinder/app/App.h"

#include "poScene.h"
#include "poNodeContainer.h"


namespace po {
    SceneRef Scene::create()
    {
        return create(po::NodeContainer::create());
    }
    
    
    SceneRef Scene::create(NodeContainerRef rootNode)
    {
        SceneRef scene(new Scene(rootNode));
        scene->getRootNode()->setScene(scene);
        return scene;
    }
    
    Scene::Scene(NodeContainerRef rootNode)
    : mRootNode(rootNode)
    , mAutoCam(true)
    , eventCenter(EventCenter::create())
    {
    }
    
    Scene::~Scene()
    {
    }
    
    void Scene::setDrawOffset(ci::Vec2f offset) {
        eventCenter->setInteractionOffset(offset);
    }
    
    #pragma mark -
    
    void Scene::update()
    {
        //Send a copy of all over our children to be processed
        processTrackingQueue();
        eventCenter->processEvents(allChildren);
        
        mRootNode->updateTree();
        
        if(mAutoCam)
            mCamera.setOrtho( 0, ci::app::getWindowWidth(), ci::app::getWindowHeight(), 0, -1, 1 );
    }
    
    void Scene::draw()
    {
        drawOrderCounter = 0;
        
        if (mAutoCam) {
			ci::gl::setMatricesWindow(ci::app::getWindowSize());
        }
        
        mRootNode->drawTree();

    }
    
    #pragma mark -
    
    uint32_t Scene::getNextDrawOrder()
    {
        return drawOrderCounter++;
    }
    
    void Scene::setRootNode(NodeContainerRef node)
    {
        if(node) {
            mRootNode->removeScene();
            mRootNode = node;
            mRootNode->setScene(shared_from_this());
        }
    }
    
    
    
    #pragma mark -
    void Scene::trackChildNode(NodeRef node) {
        mTrackingQueue[node] = true;
    }
    
    void Scene::untrackChildNode(NodeRef node) {
        mTrackingQueue[node] = false;
    }
    
    void Scene::processTrackingQueue()
    {
        for (auto &kv : mTrackingQueue) {
            if(kv.second) {
                allChildren.push_back(kv.first);
            }
            
            else {
                std::vector<NodeRef>::iterator iter = std::find(allChildren.begin(), allChildren.end(), kv.first);
                if(iter != allChildren.end())
                    allChildren.erase(iter);
            }
        }
        
        mTrackingQueue.clear();
    }
}<commit_msg>Avoiding double addition of tracked objects<commit_after>//
//  poScene.cpp
//  BasicTest
//
//  Created by <NAME> on 3/17/14.
//
//
#include "cinder/app/App.h"

#include "poScene.h"
#include "poNodeContainer.h"


namespace po {
    SceneRef Scene::create()
    {
        return create(po::NodeContainer::create());
    }
    
    
    SceneRef Scene::create(NodeContainerRef rootNode)
    {
        SceneRef scene(new Scene(rootNode));
        scene->getRootNode()->setScene(scene);
        return scene;
    }
    
    Scene::Scene(NodeContainerRef rootNode)
    : mRootNode(rootNode)
    , mAutoCam(true)
    , eventCenter(EventCenter::create())
    {
    }
    
    Scene::~Scene()
    {
    }
    
    void Scene::setDrawOffset(ci::Vec2f offset) {
        eventCenter->setInteractionOffset(offset);
    }
    
    #pragma mark -
    
    void Scene::update()
    {
        //Send a copy of all over our children to be processed
        processTrackingQueue();
        eventCenter->processEvents(allChildren);
        
        mRootNode->updateTree();
        
        if(mAutoCam)
            mCamera.setOrtho( 0, ci::app::getWindowWidth(), ci::app::getWindowHeight(), 0, -1, 1 );
    }
    
    void Scene::draw()
    {
        drawOrderCounter = 0;
        
        if (mAutoCam) {
			ci::gl::setMatricesWindow(ci::app::getWindowSize());
        }
        
        mRootNode->drawTree();

    }
    
    #pragma mark -
    
    uint32_t Scene::getNextDrawOrder()
    {
        return drawOrderCounter++;
    }
    
    void Scene::setRootNode(NodeContainerRef node)
    {
        if(node) {
            mRootNode->removeScene();
            mRootNode = node;
            mRootNode->setScene(shared_from_this());
        }
    }
    
    
    
    #pragma mark -
    void Scene::trackChildNode(NodeRef node) {
        mTrackingQueue[node] = true;
    }
    
    void Scene::untrackChildNode(NodeRef node) {
        mTrackingQueue[node] = false;
    }
    
    void Scene::processTrackingQueue()
    {
        for (auto &kv : mTrackingQueue) {
            std::vector<NodeRef>::iterator iter = std::find(allChildren.begin(), allChildren.end(), kv.first);
            if(kv.second && iter == allChildren.end()) {
                allChildren.push_back(kv.first);
            }
            
            else {
                if(iter != allChildren.end())
                    allChildren.erase(iter);
            }
        }
        
        mTrackingQueue.clear();
    }
}
{'fraction_non_alphanumeric': 0.12727272727272726, 'fraction_numerical': 0.005311542390194076, 'mean_word_length': 1.8251586843623773, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7213643', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1499, 'n_words': 241}