public static void TriggerDestruction(float destructionImpact, MyPhysicsBody body, Vector3D position, Vector3 normal, float maxDestructionRadius) { if (body.BreakableBody != null) { float collidingMass = body.Mass;// == 0 ? Mass : body.Mass; //fall on voxel float destructionRadius = Math.Min(destructionImpact / 8000, maxDestructionRadius); float destructionImpulse = MyDestructionConstants.STRENGTH + destructionImpact / 10000; float expandVelocity = Math.Min(destructionImpact / 10000, 3); MyPhysics.FractureImpactDetails destruction; HkdFractureImpactDetails details; details = HkdFractureImpactDetails.Create(); details.SetBreakingBody(body.RigidBody); details.SetContactPoint(body.WorldToCluster(position)); details.SetDestructionRadius(destructionRadius); details.SetBreakingImpulse(destructionImpulse); details.SetParticleExpandVelocity(expandVelocity); //details.SetParticleVelocity(contactVelocity); details.SetParticlePosition(body.WorldToCluster(position - normal * 0.25f)); details.SetParticleMass(10000000);//collidingMass); details.ZeroCollidingParticleVelocity(); details.Flag = details.Flag | HkdFractureImpactDetails.Flags.FLAG_DONT_RECURSE | HkdFractureImpactDetails.Flags.FLAG_TRIGGERED_DESTRUCTION; destruction = new MyPhysics.FractureImpactDetails(); destruction.Details = details; destruction.World = body.HavokWorld; destruction.ContactInWorld = position; destruction.Entity = (MyEntity)body.Entity; MyPhysics.EnqueueDestruction(destruction); } }
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); } }