slope to the target. We use the average of the beam slope and the slope of the starting point of the beam from the center of the starting cell.
This picks better beams for points close to the player - (2,1) for instance than my first attempt.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1515 c06c8d41-db1a-0410-9941-cceddc491573
3SQQ7NFTRSYDTYI4A6NWKUMOD65JJ5YPSJJIME6JDAAAN7IF6KGQC
GVCGKTH5IJ4VSQEIN4CRC7ZFVZW26JPIYNCPTO7GY66CSZZEW3ZQC
VD4KDTGHVKCN35AWREYB4TEOUMCTW7SAUPAMTMF5ABC7VBHVKP4AC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
77H4BWWPPGLM3PLZH4QTAJRXIZTSDVNCOKZE223I437FN2UJ34RQC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
}
static const double VERTICAL_SLOPE = 10000.0;
static double calc_slope(double x, double y)
{
if (double_is_zero(x))
return (VERTICAL_SLOPE);
const double slope = y / x;
return (slope > VERTICAL_SLOPE? VERTICAL_SLOPE : slope);
}
static double slope_factor(const ray_def &ray)
{
double xdiff = fabs(ray.accx - 0.5), ydiff = fabs(ray.accy - 0.5);
if (double_is_zero(xdiff) && double_is_zero(ydiff))
return ray.slope;
const double slope = calc_slope(ydiff, xdiff);
return (slope + ray.slope) / 2.0;
static bool superior_ray(int shortest, int imbalance,
int raylen, int rayimbalance,
double slope_diff, double ray_slope_diff)
{
if (shortest != raylen)
return (shortest > raylen);
if (imbalance != rayimbalance)
return (imbalance > rayimbalance);
return (slope_diff > ray_slope_diff);
}