Exemple #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;
        }
    }
Exemple #2
0
    void DiCullNode::AttachSilently(DiTransUnitPtr obj)
    {
        DI_ASSERT(!mObjectsByName.contains(obj->GetName()));
        mObjectsByName.insert(ObjectMap::value_type(obj->GetName(), obj));

        NeedUpdate();
    }
Exemple #3
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();
 }
Exemple #4
0
 void DiCullNode::ProcessVisibleObjects(std::function<void(DiTransUnitPtr)> func)
 {
     auto mit = mObjectsByName.begin();
     while (mit != mObjectsByName.end())
     {
         DiTransUnitPtr mo = mit->second;
         if (mo->GetVisible())
             func(mo);
         ++mit;
     }
 }
Exemple #5
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();
    }
Exemple #6
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();
    }
Exemple #7
0
    void DiCullNode::UpdateBounds()
    {
        mWorldAABB.SetNull();
        mLocalAABB.SetNull();

        ObjectMap::iterator itr;
        DiTransUnitPtr ret;
        for ( itr = mObjectsByName.begin(); itr != mObjectsByName.end(); ++itr )
        {
            ret = itr->second;
            mWorldAABB.Merge(ret->GetWorldBoundingBox(true));
            mLocalAABB.Merge( ret->GetBoundingBox() );
        }

        if (!mWorldAABB.IsNull())
            mCreator->UpdateOctreeNode( this );
    }
Exemple #8
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();
    }
Exemple #9
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;
    }
Exemple #10
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();
    }
Exemple #11
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();
    }
Exemple #12
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;
        }
    }
Exemple #13
0
    void DiCullNode::ProcessBatchGroup( DiCamera* camera,DiRenderPipeline* pipeline, 
        bool onlyShadowCaster, DiVisibleObjectsBoundsInfo* visbleBounds)
    {
        auto mit = mObjectsByName.begin();
        while ( mit != mObjectsByName.end() )
        {
            DiTransUnitPtr mo = mit->second;

            if (mo->GetVisible())
            {
                DiRenderBatchGroup* gp = pipeline->GetBatchGroup(mo->GetBatchGroup());
                bool receiveShadows = gp->GetShadowEnable();

                if (!onlyShadowCaster || mo->GetShadowCastEnable())
                {
                    mo->NotifyCurrentCamera(camera);
                    mo->CullingUpdate(gp,camera);
                    if (visbleBounds)
                    {
                        visbleBounds->Merge(mo->GetWorldBoundingBox(true), 
                            mo->GetWorldBoundingSphere(this, true), camera, 
                            receiveShadows);
                    }
                }
                else if (onlyShadowCaster && !mo->GetShadowCastEnable() && 
                    receiveShadows)
                {
                    visbleBounds->MergeNonRenderedButInFrustum(mo->GetWorldBoundingBox(true), 
                        mo->GetWorldBoundingSphere(true), camera);
                }
            }
            ++mit;
        }
    }