GetCollidableInstance() public method

Retrieves an instance of an EntityCollidable that uses this EntityShape. Mainly used by compound bodies.
public GetCollidableInstance ( ) : EntityCollidable
return BEPUphysics.BroadPhaseEntries.MobileCollidables.EntityCollidable
Beispiel #1
0
 public override void SpawnBody()
 {
     PreHandleSpawn();
     base.SpawnBody();
     if (mode == ModelCollisionMode.PRECISE)
     {
         Offset = InternalOffset;
     }
     BEPUutilities.Vector3 offs = Offset.ToBVector();
     transform = Matrix4d.CreateTranslation(ClientUtilities.ConvertD(Offset));
     List<BEPUutilities.Vector3> tvecs = TheClient.Models.Handler.GetVertices(model.Original);
     if (tvecs.Count == 0)
     {
         ModelMin = new BEPUutilities.Vector3(0, 0, 0);
         ModelMax = new BEPUutilities.Vector3(0, 0, 0);
     }
     else
     {
         ModelMin = tvecs[0];
         ModelMax = tvecs[0];
         foreach (BEPUutilities.Vector3 vec in tvecs)
         {
             BEPUutilities.Vector3 tvec = vec + offs;
             if (tvec.X < ModelMin.X) { ModelMin.X = tvec.X; }
             if (tvec.Y < ModelMin.Y) { ModelMin.Y = tvec.Y; }
             if (tvec.Z < ModelMin.Z) { ModelMin.Z = tvec.Z; }
             if (tvec.X > ModelMax.X) { ModelMax.X = tvec.X; }
             if (tvec.Y > ModelMax.Y) { ModelMax.Y = tvec.Y; }
             if (tvec.Z > ModelMax.Z) { ModelMax.Z = tvec.Z; }
         }
     }
     if (GenBlockShadows)
     {
         double tx = ModelMax.X - ModelMin.X;
         double ty = ModelMax.Y - ModelMin.Y;
         BoxShape bs = new BoxShape(tx, ty, ModelMax.Z - ModelMin.Z);
         EntityCollidable tempCast = bs.GetCollidableInstance();
         tempCast.LocalPosition = (ModelMax + ModelMin) * 0.5f + Body.Position;
         RigidTransform def = RigidTransform.Identity;
         tempCast.UpdateBoundingBoxForTransform(ref def);
         ShadowCastShape = tempCast.BoundingBox;
         BEPUutilities.Vector3 size = ShadowCastShape.Max - ShadowCastShape.Min;
         ShadowRadiusSquaredXY = size.X * size.X + size.Y * size.Y;
     }
 }