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++; } }