From 95f413463052b70c2559cfd1fcbee8b8e93fd5cd Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Thu, 31 Dec 2015 09:36:37 -0500 Subject: [PATCH] Refactor stereo3d classes to use TArray instead of std::vector. --- src/gl/scene/gl_scene.cpp | 12 ++++++------ src/gl/stereo3d/gl_anaglyph.cpp | 4 ++-- src/gl/stereo3d/gl_stereo3d.h | 15 ++++++--------- src/gl/stereo3d/gl_stereo_leftright.h | 4 ++-- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d94748f6d..518c35934 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -816,19 +816,19 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo float viewShift[3]; const s3d::Stereo3DMode& stereo3dMode = s3d::Stereo3DMode::getCurrentMode(); stereo3dMode.SetUp(); - s3d::Stereo3DMode::const_iterator eye; - for (eye = stereo3dMode.begin(); eye != stereo3dMode.end(); ++eye) + for (int eye_ix = 0; eye_ix < stereo3dMode.eye_count(); ++eye_ix) { - (*eye)->SetUp(); + const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix); + eye->SetUp(); // TODO: stereo specific viewport - needed when implementing side-by-side modes etc. SetViewport(bounds); mCurrentFoV = fov; // Stereo mode specific perspective projection - SetProjection( (*eye)->GetProjection(fov, ratio, fovratio) ); + SetProjection( eye->GetProjection(fov, ratio, fovratio) ); // SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper SetViewAngle(viewangle); // Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz - (*eye)->GetViewShift(GLRenderer->mAngles.Yaw, viewShift); + eye->GetViewShift(GLRenderer->mAngles.Yaw, viewShift); s3d::ScopedViewShifter viewShifter(viewShift); SetViewMatrix(viewx, viewy, viewz, false, false); gl_RenderState.ApplyMatrices(); @@ -839,7 +839,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo ProcessScene(toscreen); EndDrawScene(viewsector); - (*eye)->TearDown(); + eye->TearDown(); } stereo3dMode.TearDown(); diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp index ec0d049ec..4b3d4d00e 100644 --- a/src/gl/stereo3d/gl_anaglyph.cpp +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -40,8 +40,8 @@ namespace s3d { MaskAnaglyph::MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters) : leftEye(leftColorMask, ipdMeters), rightEye(leftColorMask.inverse(), ipdMeters) { - eye_ptrs.push_back(&leftEye); - eye_ptrs.push_back(&rightEye); + eye_ptrs.Push(&leftEye); + eye_ptrs.Push(&rightEye); } diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h index aca769734..48b6ef900 100644 --- a/src/gl/stereo3d/gl_stereo3d.h +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -36,8 +36,8 @@ #ifndef GL_STEREO3D_H_ #define GL_STEREO3D_H_ -#include #include // needed for memcpy on linux, which is needed by VSMatrix copy ctor +#include "tarray.h" #include "gl/data/gl_matrix.h" @@ -72,23 +72,20 @@ public: class Stereo3DMode { public: - /* const_iterator cycles through the various eye viewpoints */ - typedef std::vector::const_iterator const_iterator; - /* static methods for managing the selected stereoscopic view state */ static const Stereo3DMode& getCurrentMode(); Stereo3DMode(); virtual ~Stereo3DMode(); - /* const_iterator cycles through the various eye viewpoints */ - virtual const_iterator begin() const { return eye_ptrs.begin(); } - virtual const_iterator end() const { return eye_ptrs.end(); } + virtual int eye_count() const { return eye_ptrs.Size(); } + virtual const EyePose * getEyePose(int ix) const { return eye_ptrs(ix); } + /* hooks for setup and cleanup operations for each stereo mode */ virtual void SetUp() const {}; virtual void TearDown() const {}; protected: - std::vector eye_ptrs; + TArray eye_ptrs; private: static Stereo3DMode const * currentStereo3DMode; @@ -105,7 +102,7 @@ public: static const MonoView& getInstance(); protected: - MonoView() { eye_ptrs.push_back(¢ralEye); } + MonoView() { eye_ptrs.Push(¢ralEye); } EyePose centralEye; }; diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h index 24e026675..6bca9de90 100644 --- a/src/gl/stereo3d/gl_stereo_leftright.h +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -80,7 +80,7 @@ class LeftEyeView : public Stereo3DMode public: static const LeftEyeView& getInstance(FLOATTYPE ipd); - LeftEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } + LeftEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); } FLOATTYPE getIpd() const { return eye.getIpd(); } void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } protected: @@ -93,7 +93,7 @@ class RightEyeView : public Stereo3DMode public: static const RightEyeView& getInstance(FLOATTYPE ipd); - RightEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.push_back(&eye); } + RightEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); } FLOATTYPE getIpd() const { return eye.getIpd(); } void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } protected: