コード例 #1
0
 protected override void UpdateContainedPairs()
 {
     RigidTransform rt = mesh.WorldTransform;
     QuickList<Vector3i> overlaps = new QuickList<Vector3i>(BufferPools<Vector3i>.Thread);
     mesh.ChunkShape.GetOverlaps(ref rt, convex.BoundingBox, ref overlaps);
     for (int i = 0; i < overlaps.Count; i++)
     {
         Vector3i pos = overlaps.Elements[i];
         Vector3 offs;
         ReusableGenericCollidable<ConvexShape> colBox = new ReusableGenericCollidable<ConvexShape>(mesh.ChunkShape.ShapeAt(pos.X, pos.Y, pos.Z, out offs));
         colBox.SetEntity(mesh.Entity);
         Vector3 input = new Vector3(pos.X + offs.X, pos.Y + offs.Y, pos.Z + offs.Z);
         Vector3 transfd = Quaternion.Transform(input, rt.Orientation);
         RigidTransform outp = new RigidTransform(transfd + rt.Position, rt.Orientation);
         colBox.WorldTransform = outp;
         TryToAdd(colBox, convex, mesh.Entity != null ? mesh.Entity.Material : null, convex.Entity != null ? convex.Entity.Material : null);
     }
     overlaps.Dispose();
 }
コード例 #2
0
 private GeneralConvexPairTester GetPair(ref Vector3i position)
 {
     // TODO: Efficiency!
     GeneralConvexPairTester pair = testerPool.Take();
     Vector3 offs;
     ReusableGenericCollidable<ConvexShape> boxCollidable = new ReusableGenericCollidable<ConvexShape>((ConvexShape)mesh.ChunkShape.ShapeAt(position.X, position.Y, position.Z, out offs));
     pair.Initialize(convex, boxCollidable);
     boxCollidable.WorldTransform = new RigidTransform(new Vector3(
         mesh.Position.X + position.X + offs.X,
         mesh.Position.Y + position.Y + offs.Y,
         mesh.Position.Z + position.Z + offs.Z));
     return pair;
 }
コード例 #3
0
ファイル: MCCFCOPairHander.cs プロジェクト: Morphan1/Voxalia
 protected override void UpdateContainedPairs()
 {
     RigidTransform rtMesh = mesh.WorldTransform;
     RigidTransform rtMobile = mobile.WorldTransform;
     QuickList<Vector3i> overlaps = new QuickList<Vector3i>(BufferPools<Vector3i>.Thread);
     mesh.ChunkShape.GetOverlaps(ref rtMesh, mobile.BoundingBox, ref overlaps);
     for (int i = 0; i < overlaps.Count; i++)
     {
         Vector3i pos = overlaps.Elements[i];
         Vector3 offs;
         ReusableGenericCollidable<ConvexShape> colBox = new ReusableGenericCollidable<ConvexShape>(mesh.ChunkShape.ShapeAt(pos.X, pos.Y, pos.Z, out offs));
         Vector3 input = new Vector3(pos.X + offs.X, pos.Y + offs.Y, pos.Z + offs.Z);
         Vector3 transfd = Quaternion.Transform(input, rtMesh.Orientation);
         RigidTransform outp = new RigidTransform(transfd + rtMesh.Position, rtMesh.Orientation);
         colBox.WorldTransform = outp;
         colBox.UpdateBoundingBoxForTransform(ref outp);
         QuickList<Vector3i> overlaps2 = new QuickList<Vector3i>(BufferPools<Vector3i>.Thread);
         mobile.ChunkShape.GetOverlaps(ref rtMobile, colBox.BoundingBox, ref overlaps2);
         for (int x = 0; x < overlaps2.Count; x++)
         {
             Vector3i pos2 = overlaps2.Elements[x];
             Vector3 offs2;
             ReusableGenericCollidable<ConvexShape> colBox2 = new ReusableGenericCollidable<ConvexShape>(mobile.ChunkShape.ShapeAt(pos2.X, pos2.Y, pos2.Z, out offs2));
             colBox2.SetEntity(mobile.Entity);
             Vector3 input2 = new Vector3(pos2.X + offs2.X, pos2.Y + offs2.Y, pos2.Z + offs2.Z);
             Vector3 transfd2 = Quaternion.Transform(input2, rtMobile.Orientation);
             RigidTransform outp2 = new RigidTransform(transfd2 + rtMobile.Position, rtMobile.Orientation);
             colBox2.WorldTransform = outp2;
             TryToAdd(colBox, colBox2, mesh.Entity != null ? mesh.Entity.Material : null, mobile.Entity != null ? mobile.Entity.Material : null);
         }
         overlaps2.Dispose();
     }
     overlaps.Dispose();
 }