static void PreallocateObjects() { if (m_objectPool == null) { m_objectPool = new MyObjectsPool <MyExplosionDebrisModel>(MyExplosionsConstants.MAX_EXPLOSION_DEBRIS_OBJECTS); } m_objectPool.DeallocateAll(); List <MyRBElementDesc> collisionPrimitives = new List <MyRBElementDesc>(); MyPhysicsObjects physobj = MyPhysics.physicsSystem.GetPhysicsObjects(); MyRBSphereElementDesc sphereDesc = physobj.GetRBSphereElementDesc(); sphereDesc.SetToDefault(); sphereDesc.m_RBMaterial = MyMaterialsConstants.GetMaterialProperties(MODEL_DEBRIS_MATERIAL_TYPE).PhysicsMaterial; collisionPrimitives.Add(sphereDesc); int counter = 0; foreach (var item in m_objectPool.GetPreallocatedItemsArray()) { MyModelsEnum modelEnum = (MyModelsEnum)((int)MyModelsEnum.Debris1 + counter % 31); MyModel model = MyModels.GetModelOnlyData(modelEnum); BoundingSphere boundingSphere = model.BoundingSphere; sphereDesc.m_Radius = boundingSphere.Radius; sphereDesc.m_Matrix.Translation = boundingSphere.Center; item.Value.Init(collisionPrimitives, modelEnum); counter++; } }
static void PreallocateObjects() { if (m_objectPool == null) { m_objectPool = new MyObjectsPool <MyExplosionDebrisVoxel>(MyExplosionsConstants.MAX_EXPLOSION_DEBRIS_OBJECTS); } m_objectPool.DeallocateAll(); // This collision primitive is used by every instance of this class MyModel model = MyModels.GetModelOnlyData(VOXEL_DEBRIS_MODEL_ENUM); BoundingSphere boundingSphere = model.BoundingSphere; List <MyRBElementDesc> collisionPrimitives = new List <MyRBElementDesc>(); MyPhysicsObjects physobj = MyPhysics.physicsSystem.GetPhysicsObjects(); MyRBSphereElementDesc sphereDesc = physobj.GetRBSphereElementDesc(); MyMaterialType materialType = MyMaterialType.ROCK; sphereDesc.SetToDefault(); sphereDesc.m_RBMaterial = MyMaterialsConstants.GetMaterialProperties(materialType).PhysicsMaterial; sphereDesc.m_Radius = boundingSphere.Radius; sphereDesc.m_Matrix.Translation = model.BoundingSphere.Center; collisionPrimitives.Add(sphereDesc); int counter = 0; foreach (LinkedListNode <MyExplosionDebrisVoxel> item in m_objectPool.GetPreallocatedItemsArray()) { item.Value.Init(collisionPrimitives); counter++; } }
public static void LoadData() { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMissiles.LoadData"); MyMwcLog.WriteLine("MyMissiles.LoadContent() - START"); MyMwcLog.IncreaseIndent(); if (m_missiles == null) { m_missiles = new MyObjectsPool <MyMissile>(MyMissileConstants.MAX_MISSILES_COUNT); } m_missiles.DeallocateAll(); foreach (LinkedListNode <MyMissile> item in m_missiles.GetPreallocatedItemsArray()) { item.Value.Init(); } MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyMissiles.LoadContent() - END"); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
public static void LoadData() { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyHologramShips.LoadData"); MyMwcLog.WriteLine("MyHologramShips.LoadContent() - START"); MyMwcLog.IncreaseIndent(); if (m_hologramShips == null) { m_hologramShips = new MyObjectsPool <MySmallShip>(MyUniversalLauncherConstants.MAX_HOLOGRAMS_COUNT * MyMultiplayerGameplay.MaxPlayers); } m_hologramShips.DeallocateAll(); foreach (var item in m_hologramShips.GetPreallocatedItemsArray()) { // TODO simon - do we need something here? //item.Value.Init(); } MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyHologramShips.LoadContent() - END"); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }