summaryrefslogtreecommitdiffstats
path: root/libdimensionxx
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-16 21:31:51 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-16 21:31:51 +0000
commitbbe317fb2bde1b2b88df66e5426c9ee78e40a0b6 (patch)
tree0406204d223c4a4ddd3a6aaa51c69db88114e3d5 /libdimensionxx
parent7e7ec10dea751540eda7898cf83f8471185aa063 (diff)
downloaddimension-bbe317fb2bde1b2b88df66e5426c9ee78e40a0b6.tar.xz
Have camera callbacks take canvas coordinates as doubles.
Diffstat (limited to 'libdimensionxx')
-rw-r--r--libdimensionxx/camera.cpp14
-rw-r--r--libdimensionxx/dimensionxx/camera.hpp4
2 files changed, 6 insertions, 12 deletions
diff --git a/libdimensionxx/camera.cpp b/libdimensionxx/camera.cpp
index 3536e54..d483ba3 100644
--- a/libdimensionxx/camera.cpp
+++ b/libdimensionxx/camera.cpp
@@ -32,9 +32,9 @@ namespace Dimension
// Return the result of the dmnsn_camera*'s ray callback
Line
- Camera::ray(const Canvas& canvas, unsigned int x, unsigned int y)
+ Camera::ray(double x, double y)
{
- return Line((*dmnsn()->ray_fn)(dmnsn(), canvas.dmnsn(), x, y));
+ return Line((*dmnsn()->ray_fn)(dmnsn(), x, y));
}
// Return the wrapped camera
@@ -91,16 +91,10 @@ namespace Dimension
// Custom camera callbacks
namespace {
dmnsn_line
- ray_fn(const dmnsn_camera *camera, const dmnsn_canvas *canvas,
- unsigned int x, unsigned int y)
+ ray_fn(const dmnsn_camera *camera, double x, double y)
{
Custom_Camera* ccamera = reinterpret_cast<Custom_Camera*>(camera->ptr);
- // Yes the const_cast is ugly, but there's no other way because C++
- // doesn't have `const' constructors. Luckily const Camera's treat their
- // dmnsn_camera* as a const dmnsn_camera*.
- return ccamera->ray(
- Canvas(const_cast<dmnsn_canvas*>(canvas)), x, y
- ).dmnsn();
+ return ccamera->ray(x, y).dmnsn();
}
}
diff --git a/libdimensionxx/dimensionxx/camera.hpp b/libdimensionxx/dimensionxx/camera.hpp
index 0f61435..81952d1 100644
--- a/libdimensionxx/dimensionxx/camera.hpp
+++ b/libdimensionxx/dimensionxx/camera.hpp
@@ -33,7 +33,7 @@ namespace Dimension
virtual ~Camera();
// Camera callback
- virtual Line ray(const Canvas& canvas, unsigned int x, unsigned int y);
+ virtual Line ray(double x, double y);
// Shallow-copy a derived camera
virtual Camera* copy() const = 0;
@@ -70,7 +70,7 @@ namespace Dimension
Custom_Camera();
virtual ~Custom_Camera();
- virtual Line ray(const Canvas& canvas, unsigned int x, unsigned int y) = 0;
+ virtual Line ray(double x, double y) = 0;
};
// Array_Element specialization