Beispiel #1
0
    DiTransUnitPtr DiCullNode::DetachObject( unsigned short index )
    {
        DiTransUnitPtr ret;
        if (index < mObjectsByName.size())
        {

            ObjectMap::iterator i = mObjectsByName.begin();
            while (index--)++i;

            ret = i->second;
            mObjectsByName.erase(i);

            if (ret->GetParentNode() == this)
            {
                ret->NotifyAttached((DiCullNode*)0);
            }

            NeedUpdate();

            return ret;

        }
        else
        {
            DI_ERROR("Cannot detach object, invalid index");
            return NULL;
        }
    }
Beispiel #2
0
 DiCullNode::~DiCullNode(void)
 {
     ObjectMap::iterator itr;
     DiTransUnitPtr ret;
     for ( itr = mObjectsByName.begin(); itr != mObjectsByName.end(); ++itr )
     {
         ret = itr->second;
         ret->NotifyAttached((DiCullNode*)NULL);
     }
     mObjectsByName.clear();
 }
Beispiel #3
0
    void DiCullNode::AttachObject(DiTransUnitPtr obj)
    {
        if (obj->IsAttached())
        {
            DI_ERROR("The object has been attached");
        }

        obj->NotifyAttached(this);

        DI_ASSERT(!mObjectsByName.contains(obj->GetName()));
        mObjectsByName.insert(ObjectMap::value_type(obj->GetName(), obj));

        NeedUpdate();
    }
Beispiel #4
0
    void DiCullNode::AttachObject(DiTransUnitPtr obj)
    {
        if (obj->IsAttached())
        {
            DI_WARNING("The object has been attached");
            return;
        }

        obj->NotifyAttached(this);

        mObjects.push_back(obj);

        NeedUpdate();
    }
Beispiel #5
0
    void DiCullNode::DetachAllObjects( void )
    {
        ObjectMap::iterator itr;
        DiTransUnitPtr ret;
        for ( itr = mObjectsByName.begin(); 
            itr != mObjectsByName.end(); ++itr )
        {
            ret = itr->second;
            if (ret->GetParentNode() == this)
            {
                ret->NotifyAttached((DiCullNode*)0);
            }
        }
        mObjectsByName.clear();

        NeedUpdate();
    }
Beispiel #6
0
    DiTransUnitPtr DiCullNode::DetachObject( const DiString& name )
    {
        ObjectMap::iterator it = mObjectsByName.find(name);
        if (it == mObjectsByName.end())
        {
            DI_ERROR("Cannot find the object : %s", name.c_str());
        }
        DiTransUnitPtr ret = it->second;
        mObjectsByName.erase(it);
        if (ret->GetParentNode() == this)
        {
            ret->NotifyAttached((DiCullNode*)0);
        }
        NeedUpdate();

        return ret;
    }
Beispiel #7
0
    void DiCullNode::DetachObject(DiTransUnitPtr obj)
    {
        ObjectMap::iterator i, iend;
        iend = mObjectsByName.end();
        for (i = mObjectsByName.begin(); i != iend; ++i)
        {
            if (i->second == obj)
            {
                mObjectsByName.erase(i);
                break;
            }
        }

        if (obj->GetParentNode() == this)
        {
            obj->NotifyAttached((DiCullNode*)0);
        }

        NeedUpdate();
    }
Beispiel #8
0
    void DiCullNode::DetachObject(DiTransUnitPtr obj)
    {
        bool found = false;
        for (auto i = mObjects.begin(); i != mObjects.end(); ++i)
        {
            if (*i == obj)
            {
                mObjects.erase(i);
                found = true;
                break;
            }
        }
        
        if (!found)
            return;

        if (obj->GetParentNode() == this)
        {
            obj->NotifyAttached(nullptr);
        }

        NeedUpdate();
    }
Beispiel #9
0
    DiTransUnitPtr DiCullNode::DetachObject( uint32 index )
    {
        if (index < mObjects.size())
        {
            DiTransUnitPtr ret = mObjects[index];
            if (ret->GetParentNode() == this)
            {
                ret->NotifyAttached((DiCullNode*)0);
            }
            
            ObjectMap::iterator i = mObjects.begin() + index;
            mObjects.erase(i);

            NeedUpdate();

            return ret;

        }
        else
        {
            DI_WARNING("Cannot detach object, invalid index");
            return nullptr;
        }
    }