public MyNavigationMesh(MyNavgroupLinks externalLinks, int trianglePrealloc = 16, Func <long> timestampFunction = null)
     : base(128, timestampFunction)
 {
     m_triPool       = new MyDynamicObjectPool <MyNavigationTriangle>(trianglePrealloc);
     m_mesh          = new MyWingedEdgeMesh();
     m_externalLinks = externalLinks;
 }
Пример #2
0
 public MyNavigationMesh(MyNavgroupLinks externalLinks, int trianglePrealloc = 0x10, Func <long> timestampFunction = null) : base(0x80, timestampFunction)
 {
     this.m_vertexList    = new List <Vector3>();
     this.m_triPool       = new MyDynamicObjectPool <MyNavigationTriangle>(trianglePrealloc);
     this.m_mesh          = new MyWingedEdgeMesh();
     this.m_externalLinks = externalLinks;
 }
Пример #3
0
 public MyRBIslandNSolver()
 {
     m_Island = null;
     m_SolverConstraints = new List<MyRBSolverConstraint>(m_defaultMaxCollidingElements);
     //m_SolverConstaintPool = new MyObjectsPool<MyRBSolverConstraint>(m_defaultMaxCollidingElements);
     m_SolverConstaintPool = new MyDynamicObjectPool<MyRBSolverConstraint>(m_defaultMaxCollidingElements);
     m_SolverBodies = new Dictionary<MyRigidBody, MyRBSolverBody>(m_defaultMaxCollidingElements);
     //m_SolverBodiesPool = new MyObjectsPool<MyRBSolverBody>(m_defaultMaxCollidingElements);
     m_SolverBodiesPool = new MyDynamicObjectPool<MyRBSolverBody>(m_defaultMaxCollidingElements);
 }
Пример #4
0
 public MyRBIslandNSolver()
 {
     m_Island            = null;
     m_SolverConstraints = new List <MyRBSolverConstraint>(m_defaultMaxCollidingElements);
     //m_SolverConstaintPool = new MyObjectsPool<MyRBSolverConstraint>(m_defaultMaxCollidingElements);
     m_SolverConstaintPool = new MyDynamicObjectPool <MyRBSolverConstraint>(m_defaultMaxCollidingElements);
     m_SolverBodies        = new Dictionary <MyRigidBody, MyRBSolverBody>(m_defaultMaxCollidingElements);
     //m_SolverBodiesPool = new MyObjectsPool<MyRBSolverBody>(m_defaultMaxCollidingElements);
     m_SolverBodiesPool = new MyDynamicObjectPool <MyRBSolverBody>(m_defaultMaxCollidingElements);
 }
Пример #5
0
        public void SpawnFlora(Vector3D pos)
        {
            if (m_planetEnvironmentSectors == null)
            {
                m_planetEnvironmentSectors = new Dictionary <Vector3I, MyPlanetEnvironmentSector>(500);
            }

            Vector3D gravity       = GetWorldGravityNormalized(ref pos);
            Vector3D perpedincular = MyUtils.GetRandomPerpendicularVector(ref gravity);
            Vector3D third         = Vector3D.Cross(gravity, perpedincular);

            perpedincular += third;

            Vector3I min = new Vector3I(-ENVIROMENT_EXTEND);
            Vector3I max = new Vector3I(ENVIROMENT_EXTEND);

            Vector3 offset = new Vector3(-MyPlanetEnvironmentSector.SECTOR_SIZE_METERS);

            for (var it = new Vector3I.RangeIterator(ref min, ref max); it.IsValid(); it.MoveNext())
            {
                Vector3D currentPos = pos + it.Current * offset * perpedincular;
                currentPos = PlaceToOrbit(currentPos, ref gravity);

                if (false == ChekPosition(currentPos))
                {
                    Vector3I newSector = Vector3I.Floor(currentPos / MyPlanetEnvironmentSector.SECTOR_SIZE_METERS);
                    if (m_planetSectorsPool == null)
                    {
                        m_planetSectorsPool = new MyDynamicObjectPool <MyPlanetEnvironmentSector>(400);
                    }


                    MyPlanetEnvironmentSector sector = m_planetSectorsPool.Allocate();

                    sector.Init(ref newSector, this);
                    m_planetEnvironmentSectors[newSector] = sector;
                    sector.PlaceItems();
                }
            }

            Vector3I sectorCoords = Vector3I.Floor(PlaceToOrbit(pos, ref gravity) / MyPlanetEnvironmentSector.SECTOR_SIZE_METERS);

            Vector3I keepMin = sectorCoords + new Vector3I(-ENVIROMENT_EXTEND_KEEP);
            Vector3I keepMax = sectorCoords + new Vector3I(ENVIROMENT_EXTEND_KEEP);

            foreach (var enviromentSector in m_planetEnvironmentSectors)
            {
                if (enviromentSector.Key.IsInsideInclusive(keepMin, keepMax))
                {
                    m_sectorsToKeep.Add(enviromentSector.Key);
                }
            }
        }
Пример #6
0
        public override void LoadData()
        {
            m_instance = this;

            if (Environment.ProcessorCount <= 2)
            { // throttle down precalc on worker threads when it could hurt Update and Render thread.
                MyFakes.MAX_PRECALC_TIME_IN_MILLIS = 6f;
            }
            else
            {
                MyFakes.MAX_PRECALC_TIME_IN_MILLIS = 14f;
            }

            m_workPool = new MyDynamicObjectPool <Work>(Parallel.Scheduler.ThreadCount);
        }
Пример #7
0
        public void SpawnFlora(Vector3D pos)
        {
            if (m_planetEnvironmentSectors == null)
            {
                m_planetEnvironmentSectors = new Dictionary<Vector3I, MyPlanetEnvironmentSector>(500);
            }

            Vector3D gravity = GetWorldGravityNormalized(ref pos);
            Vector3D perpedincular = MyUtils.GetRandomPerpendicularVector(ref gravity);
            Vector3D third = Vector3D.Cross(gravity, perpedincular);

            perpedincular += third;

            Vector3I min = new Vector3I(-ENVIROMENT_EXTEND);
            Vector3I max = new Vector3I(ENVIROMENT_EXTEND);

            Vector3 offset = new Vector3(-MyPlanetEnvironmentSector.SECTOR_SIZE_METERS);

            for (var it = new Vector3I.RangeIterator(ref min, ref max); it.IsValid(); it.MoveNext())
            {
                Vector3D currentPos = pos + it.Current * offset * perpedincular;
                currentPos = PlaceToOrbit(currentPos, ref gravity);

                if (false == ChekPosition(currentPos))
                {
                    Vector3I newSector = Vector3I.Floor(currentPos / MyPlanetEnvironmentSector.SECTOR_SIZE_METERS);
                    if (m_planetSectorsPool == null)
                    {
                        m_planetSectorsPool = new MyDynamicObjectPool<MyPlanetEnvironmentSector>(400);
                    }
                   

                    MyPlanetEnvironmentSector sector = m_planetSectorsPool.Allocate();

                    sector.Init(ref newSector, this);
                    m_planetEnvironmentSectors[newSector] = sector;
                    sector.PlaceItems();
                }
            }

            Vector3I sectorCoords = Vector3I.Floor(PlaceToOrbit(pos, ref gravity) / MyPlanetEnvironmentSector.SECTOR_SIZE_METERS);

            Vector3I keepMin = sectorCoords + new Vector3I(-ENVIROMENT_EXTEND_KEEP);
            Vector3I keepMax = sectorCoords + new Vector3I(ENVIROMENT_EXTEND_KEEP);

            foreach (var enviromentSector in m_planetEnvironmentSectors)
            {
                if (enviromentSector.Key.IsInsideInclusive(keepMin, keepMax))
                {
                    m_sectorsToKeep.Add(enviromentSector.Key);
                }
            }
        }
 /// <summary>
 /// Gets rid of the vertex and edge preallocation pools. You MUST NOT add any more triangles or edges after calling this method.
 /// It is here only to save memory when the mesh won't be modified any more.
 /// </summary>
 public void ErasePools()
 {
     m_triPool = null;
 }
Пример #9
0
 public void ErasePools()
 {
     this.m_triPool = null;
 }