Ejemplo n.º 1
0
 public static unsafe void TriggerDestruction(float destructionImpact, MyPhysicsBody body, Vector3D position, Vector3 normal, float maxDestructionRadius)
 {
     if (body.BreakableBody != null)
     {
         float mass = body.Mass;
         HkdFractureImpactDetails details2 = HkdFractureImpactDetails.Create();
         details2.SetBreakingBody(body.RigidBody);
         details2.SetContactPoint((Vector3)body.WorldToCluster(position));
         details2.SetDestructionRadius(Math.Min(destructionImpact / 8000f, maxDestructionRadius));
         details2.SetBreakingImpulse(MyDestructionConstants.STRENGTH + (destructionImpact / 10000f));
         details2.SetParticleExpandVelocity(Math.Min((float)(destructionImpact / 10000f), (float)3f));
         details2.SetParticlePosition((Vector3)body.WorldToCluster(position - (normal * 0.25f)));
         details2.SetParticleMass(1E+07f);
         details2.ZeroCollidingParticleVelocity();
         HkdFractureImpactDetails *detailsPtr1 = (HkdFractureImpactDetails *)ref details2;
         detailsPtr1.Flag = (details2.Flag | HkdFractureImpactDetails.Flags.FLAG_DONT_RECURSE) | HkdFractureImpactDetails.Flags.FLAG_TRIGGERED_DESTRUCTION;
         MyPhysics.FractureImpactDetails details = new MyPhysics.FractureImpactDetails {
             Details        = details2,
             World          = body.HavokWorld,
             ContactInWorld = position,
             Entity         = (VRage.Game.Entity.MyEntity)body.Entity
         };
         MyPhysics.EnqueueDestruction(details);
     }
 }