summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/beam.cc2
-rw-r--r--crawl-ref/source/geom2d.cc14
-rw-r--r--crawl-ref/source/geom2d.h2
-rw-r--r--crawl-ref/source/ray.cc11
-rw-r--r--crawl-ref/source/ray.h4
5 files changed, 31 insertions, 2 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 457a21917f..c876bc8b41 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -1379,7 +1379,6 @@ static beam_type _chaos_beam_flavour()
static void _munge_bounced_bolt(bolt &old_bolt, bolt &new_bolt,
ray_def &old_ray, ray_def &new_ray)
{
-#if 0
if (new_bolt.real_flavour != BEAM_CHAOS)
return;
@@ -1428,7 +1427,6 @@ static void _munge_bounced_bolt(bolt &old_bolt, bolt &new_bolt,
// ping-pong balls on caffeine.
int range_spent = new_bolt.range_used - old_bolt.range_used;
new_bolt.range += range_spent;
-#endif
}
bool bolt::invisible() const
diff --git a/crawl-ref/source/geom2d.cc b/crawl-ref/source/geom2d.cc
index 720f334226..3fba76e2d3 100644
--- a/crawl-ref/source/geom2d.cc
+++ b/crawl-ref/source/geom2d.cc
@@ -154,5 +154,19 @@ double form::operator()(const vector& v) const
return (a*v.x + b*v.y);
}
+double degrees(const vector &v)
+{
+ if (v.x == 0)
+ return (v.y > 0 ? 90.0 : -90.0);
+ double rad = v.x > 0 ? atan(v.y/v.x) : M_PI + atan(v.y/v.x);
+ return (180.0 / M_PI * rad);
+}
+
+vector degree_to_vector(double d)
+{
+ double rad = d / 180.0 * M_PI;
+ return (vector(cos(rad), sin(rad)));
+}
+
}
diff --git a/crawl-ref/source/geom2d.h b/crawl-ref/source/geom2d.h
index 11d68551f7..b52d417638 100644
--- a/crawl-ref/source/geom2d.h
+++ b/crawl-ref/source/geom2d.h
@@ -91,6 +91,8 @@ double nextintersect(const ray &r, const lineseq &ls);
bool parallel(const vector& v, const form &f);
vector reflect(const vector& v, const form &f);
+vector degree_to_vector(const double d);
+double degrees(const vector &v);
}
#endif
diff --git a/crawl-ref/source/ray.cc b/crawl-ref/source/ray.cc
index 536a6f3fd1..cc30f3dfe5 100644
--- a/crawl-ref/source/ray.cc
+++ b/crawl-ref/source/ray.cc
@@ -469,3 +469,14 @@ void ray_def::bounce(const reflect_grid &rg)
ASSERT(_valid());
ASSERT(!rg(pos() - old_pos + rg_o));
}
+
+double ray_def::get_degrees() const
+{
+ return (geom::degrees(r.dir));
+}
+
+void ray_def::set_degrees(double d)
+{
+ r.dir = geom::degree_to_vector(d);
+}
+
diff --git a/crawl-ref/source/ray.h b/crawl-ref/source/ray.h
index d2bcb0c1e1..ad77e730d4 100644
--- a/crawl-ref/source/ray.h
+++ b/crawl-ref/source/ray.h
@@ -27,6 +27,10 @@ struct ray_def
void bounce(const reflect_grid &rg);
void regress();
+ // Get and set the direction.
+ double get_degrees() const;
+ void set_degrees(double d);
+
bool _valid() const;
};