Example #1
0
 public IgnorableRayResultCallback(ref Vector3 rayFromWorld, ref Vector3 rayToWorld, List <object> ignore)
 {
     this.RayFromWorld = rayFromWorld;
     this.RayToWorld   = rayToWorld;
     this.ignoreList   = ignore;
     foreach (object obj in ignore)
     {
         if (obj is PhysicsEntity)
         {
             PhysicsEntity ent = obj as PhysicsEntity;
         }
     }
 }
Example #2
0
        public RayResult FindEntityOnRay(Ray ray, PhysicsEntity ignore = null)
        {
            RayResult result = new RayResult();

            if (collisionWorld != null)
            {
                BulletSharp.Math.Vector3 start = ray.Origin;
                BulletSharp.Math.Vector3 end   = ray.Origin + ray.Direction;

                ClosestRayResultCallback callback = new ClosestRayResultCallback(ref start, ref end);
                collisionWorld.RayTest(start, end, callback);

                if (callback.HasHit && callback.CollisionObject != ignore.Rigidbody)
                {
                    result.Position = callback.HitPointWorld;
                    result.Normal   = callback.HitNormalWorld;
                    //result.Hit = callback.CollisionObject;
                }
            }
            return(result);
        }