Exemple #1
0
    public void OnEndUpdateNodeData(ILODNodeData ndata)
    {
        Block45LODNodeData cdata = ndata as Block45LODNodeData;

        if (cdata.LOD == 0 && cdata.IsAllOctNodeReady())
        {
            EDependChunkType type = cdata.IsEmpty   ? EDependChunkType.ChunkBlkEmp
                                                                                                        : EDependChunkType.ChunkBlkCol;
            SceneChunkDependence.Instance.ValidListAdd(cdata.ChunkPosLod, type);
        }
    }
Exemple #2
0
    void UpdateToActive()
    {
        int n = _lstToActive.Count;

        //Profiler.BeginSample ("UpdateToActive:"+n);
        for (int i = n - 1; i >= 0; i--)
        {
            ISceneObjAgent obj = _lstToActive[i];
            if (!IntoActive(obj))
            {
                _lstToActive.RemoveAt(i);
                _lstInactive.Add(obj);
                _dirtyLstInactive = true;
            }
            else                // Test collider and Activate it
            {
                bool             allDp = true;
                EDependChunkType type  = 0;
                int nDp = _lstActDependences.Count;
                for (int iDp = 0; iDp < nDp; iDp++)
                {
                    ISceneObjActivationDependence dp = _lstActDependences[iDp];
                    if (!dp.IsDependableForAgent(obj, ref type))
                    {
                        allDp = false;
                        break;
                    }
                }
                if (allDp)
                {
                    //if((type&EDependChunkType.ChunkColMask) == 0 || null != DependenceHitTst(obj))
                    {
                        _lstToActive.RemoveAt(i);
                        _toActivate.Add(obj);
                        _lstIsActive.Add(obj);
                    }
                }
            }
        }
        n = _toActivate.Count;
        if (n > 0)
        {
            for (int i = n - 1; i >= 0; i--)
            {
                _toActivate[i].OnActivate();
            }
            _toActivate.Clear();
        }
        //_dirtyLstToActive = false;
        //Profiler.EndSample ();
    }
Exemple #3
0
    void UpdateIsActive()
    {
        int n = _lstIsActive.Count;

        //Profiler.BeginSample ("UpdateIsActive:"+n);
        for (int i = n - 1; i >= 0; i--)
        {
            ISceneObjAgent obj = _lstIsActive[i];
            if (ExitActive(obj))
            {
                _lstIsActive.RemoveAt(i);
                _toDeactivate.Add(obj);
                _lstInactive.Add(obj);
                _dirtyLstInactive = true;
            }
            else if (_dirtyLstIsActive)
            {
                bool             allDp = true;
                EDependChunkType type  = 0;
                int nDp = _lstActDependences.Count;
                for (int iDp = 0; iDp < nDp; iDp++)
                {
                    ISceneObjActivationDependence dp = _lstActDependences[iDp];
                    if (!dp.IsDependableForAgent(obj, ref type))
                    {
                        allDp = false;
                        break;
                    }
                }
                if (!allDp)
                {
                    _lstIsActive.RemoveAt(i);
                    _toDeactivate.Add(obj);
                    _lstInactive.Add(obj);
                    _dirtyLstInactive = true;
                }
            }
        }
        n = _toDeactivate.Count;
        if (n > 0)
        {
            for (int i = n - 1; i >= 0; i--)
            {
                _toDeactivate[i].OnDeactivate();
            }
            _toDeactivate.Clear();
        }
        _dirtyLstIsActive = false;
        //Profiler.EndSample ();
    }
Exemple #4
0
    public bool IsDependableForAgent(ISceneObjAgent agent, ref EDependChunkType type)
    {
        int n = _sceneObjs.Count;

        if (Time.frameCount != _nLastFrame)
        {
            _nLastFrame = Time.frameCount;

            _posToCheck.Clear();
            _boundsToCheck.Clear();
            for (int i = 0; i < n; i++)
            {
                ISceneObjAgent dp = _sceneObjs [i];
                if (dp != null && !dp.NeedToActivate && dp.Go == null)
                {
                    if (dp.Bound != null)
                    {
                        _boundsToCheck.Add(dp.Bound);
                    }
                    else
                    {
                        _posToCheck.Add(dp.Pos);
                    }
                }
            }
        }

        n = _posToCheck.Count;
        for (int i = 0; i < n; i++)
        {
            if (Vector3.SqrMagnitude(_posToCheck[i] - agent.Pos) < 64)                  //8m
            {
                return(false);
            }
        }

        n = _boundsToCheck.Count;
        for (int i = 0; i < n; i++)
        {
            if (_boundsToCheck[i].Contains(agent.Pos, agent.TstYOnActivate))
            {
                return(false);
            }
        }
        return(true);
    }
Exemple #5
0
    void SetDependChunkType(IntVector4 cposlod, EDependChunkType type, bool bAdd)
    {
        lock (_lstValidChunks) {
            EDependChunkType val = 0;
            _lstValidChunks.TryGetValue(cposlod, out val);
            if (bAdd)
            {
                val |= type;
            }
            else
            {
                val &= ~type;
            }

            if (val == 0)
            {
                _lstValidChunks.Remove(cposlod);
            }
            else
            {
                _lstValidChunks[new IntVector4(cposlod)] = val;
            }
        }
    }
Exemple #6
0
    public bool IsDependableForAgent(ISceneObjAgent agent, ref EDependChunkType type)
    {
        lock (_lstValidChunks)
        {
            Vector3          pos = agent.Pos;
            int              x   = ((int)pos.x) >> LODOctreeMan.Lod0NodeShift;
            int              z   = ((int)pos.z) >> LODOctreeMan.Lod0NodeShift;
            EDependChunkType v   = 0;
            _tmpPos.x = x;
            _tmpPos.z = z;
            _tmpPos.w = 0;
            if (agent.TstYOnActivate)
            {
                int y = ((int)pos.y) >> LODOctreeMan.Lod0NodeShift;
                _tmpPos.y = y;
                GetDependChunkType(_tmpPos, out v);
                if ((v & EDependChunkType.ChunkBlkMask) != 0 &&
                    //(v&EDependChunkType.ChunkWatMask) != 0 &&
                    (v & EDependChunkType.ChunkTerMask) != 0)
                {
                    type |= v;
                    return(true);
                }
                return(false);
            }
            else
            {
                // Note: here may be buggy on ChunkTerCol
                int y = ((int)SceneMan.LastRefreshPos.y) >> LODOctreeMan.Lod0NodeShift;
                _tmpPos.y = y;
                GetDependChunkType(_tmpPos, out v);
                if ((v & EDependChunkType.ChunkBlkMask) != 0 &&
                    //(v&EDependChunkType.ChunkWatCol) != 0 &&
                    (v & EDependChunkType.ChunkTerCol) != 0)
                {
                    type |= v;
                    return(true);
                }

                int ofs = 1;
                while (ofs <= 8)
                {
                    _tmpPos.y = y - ofs;
                    GetDependChunkType(_tmpPos, out v);
                    if ((v & EDependChunkType.ChunkBlkMask) != 0 &&
                        //(v&EDependChunkType.ChunkWatCol) != 0 &&
                        (v & EDependChunkType.ChunkTerCol) != 0)
                    {
                        type |= v;
                        return(true);
                    }
                    _tmpPos.y = y + ofs;
                    GetDependChunkType(_tmpPos, out v);
                    if ((v & EDependChunkType.ChunkBlkMask) != 0 &&
                        //(v&EDependChunkType.ChunkWatCol) != 0 &&
                        (v & EDependChunkType.ChunkTerCol) != 0)
                    {
                        type |= v;
                        return(true);
                    }
                    ofs++;
                }
                return(false);
            }
        }
    }
Exemple #7
0
 public void ValidListRemove(IntVector4 cposlod, EDependChunkType type)
 {
     SetDependChunkType(cposlod, type, false);
     SceneMan.OnActivationDependenceDirty(false);
 }
Exemple #8
0
 public void ValidListAdd(IntVector4 cposlod, EDependChunkType type)
 {
     SetDependChunkType(cposlod, type, true);
     SceneMan.OnActivationDependenceDirty(true);
 }
Exemple #9
0
 void GetDependChunkType(IntVector4 cposlod, out EDependChunkType val)
 {
     lock (_lstValidChunks) {
         _lstValidChunks.TryGetValue(cposlod, out val);
     }
 }