summaryrefslogtreecommitdiffstats
path: root/libdimensionxx/cameras.cpp
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-07 04:23:05 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-07 04:23:05 +0000
commit81c84a38992ce8e38106d86ce85ac3e88ed91a31 (patch)
tree08fb5913e141b7e208737b799b45921d477d45cc /libdimensionxx/cameras.cpp
parentd7b7b4b3391cf99ca63d8311eac3957df7a862ed (diff)
downloaddimension-81c84a38992ce8e38106d86ce85ac3e88ed91a31.tar.xz
Add shallow copy semantics to Camera's, Object's, and Scene's.
Diffstat (limited to 'libdimensionxx/cameras.cpp')
-rw-r--r--libdimensionxx/cameras.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/libdimensionxx/cameras.cpp b/libdimensionxx/cameras.cpp
index a7a8255..ea0bca9 100644
--- a/libdimensionxx/cameras.cpp
+++ b/libdimensionxx/cameras.cpp
@@ -26,7 +26,7 @@ namespace Dimension
Perspective_Camera::Perspective_Camera(const Matrix& trans)
: Camera(dmnsn_new_perspective_camera(trans.dmnsn()))
{
- if (!m_camera) {
+ if (!dmnsn()) {
throw Dimension_Error("Failed to allocate perspective camera.");
}
}
@@ -34,18 +34,30 @@ namespace Dimension
// Delete a perspective camera
Perspective_Camera::~Perspective_Camera()
{
- dmnsn_delete_perspective_camera(m_camera);
+ if (unique()) {
+ dmnsn_delete_perspective_camera(dmnsn());
+ }
}
Matrix
Perspective_Camera::trans()
{
- return Matrix(dmnsn_get_perspective_camera_trans(m_camera));
+ return Matrix(dmnsn_get_perspective_camera_trans(dmnsn()));
}
void
Perspective_Camera::trans(const Matrix& trans)
{
- dmnsn_set_perspective_camera_trans(m_camera, trans.dmnsn());
+ dmnsn_set_perspective_camera_trans(dmnsn(), trans.dmnsn());
}
+
+ Camera*
+ Perspective_Camera::copy() const
+ {
+ return new Perspective_Camera(*this);
+ }
+
+ Perspective_Camera::Perspective_Camera(const Perspective_Camera& camera)
+ : Camera(camera)
+ { }
}