private void CreateWaterPlaneSplash(Ray ray) { if (ray.Direction.Z >= 0) return; foreach (WaterPlane waterPlane in WaterPlane.Instances) { //check by plane Plane plane = new Plane(Vec3.ZAxis, waterPlane.Position.Z); float scale; if (!plane.LineIntersection(ray.Origin, ray.Origin + ray.Direction, out scale)) continue; Vec3 pos = ray.GetPointOnRay(scale); //check by bounds Rect bounds2 = new Rect(waterPlane.Position.ToVec2()); bounds2.Expand(waterPlane.Size * .5f); if (!bounds2.IsContainsPoint(pos.ToVec2())) continue; //create splash waterPlane.CreateSplash(WaterPlaneType.SplashTypes.Bullet, pos); } }
void CreateWaterPlaneSplash() { float influenceRadius = Type.Radius * .75f; foreach( WaterPlane waterPlane in WaterPlane.Instances ) { //check by height if( Position.Z + influenceRadius < waterPlane.Position.Z ) continue; if( Position.Z - influenceRadius > waterPlane.Position.Z ) continue; //check by bounds Rect bounds2 = new Rect( waterPlane.Position.ToVec2() ); bounds2.Expand( waterPlane.Size * .5f ); if( !bounds2.IsContainsPoint( Position.ToVec2() ) ) continue; //check by physics float height = Position.Z + .01f; float waterHeight = waterPlane.Position.Z; Ray ray = new Ray( new Vec3( Position.X, Position.Y, height ), new Vec3( 0, 0, waterHeight - height ) ); if( ray.Direction.Z != 0 ) { RayCastResult result = PhysicsWorld.Instance.RayCast( ray, (int)ContactGroup.CastOnlyContact ); if( result.Shape != null ) continue; } //create splash waterPlane.CreateSplash( WaterPlaneType.SplashTypes.Explosion, new Vec3( Position.X, Position.Y, waterPlane.Position.Z ) ); } }