From 14072ce0261aa68ef1a37fe45ac143f94dae8de3 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Fri, 7 Apr 2023 09:47:45 +0200 Subject: [PATCH] add vFlip detection algorithm --- src/Utils.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/Utils.h | 19 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/Utils.cpp diff --git a/src/Utils.cpp b/src/Utils.cpp new file mode 100644 index 0000000..37fc210 --- /dev/null +++ b/src/Utils.cpp @@ -0,0 +1,45 @@ +#include "Utils.h" + +namespace ofxVariableLab { + +void getVFlip(const VFlipBehaviour & vFlipBehaviour, + const glm::mat4 & orientationMatrix, + VFlipState & vFlip){ + switch(vFlipBehaviour){ + + case V_FLIP_ONCE_AUTO: { + if(vFlip != V_FLIP_UNKNOWN){ + break; + } + } + + case V_FLIP_ALWAYS_AUTO: { + if(orientationMatrix == glm::mat4(1)){ + vFlip = V_FLIP_OFF; + }else{ + vFlip = V_FLIP_ON; + } + break; + } + + case V_FLIP_ALWAYS_ON: { + vFlip = V_FLIP_ON; + break; + } + + case V_FLIP_ALWAYS_OFF: { + vFlip = V_FLIP_OFF; + break; + } + } +} +//getVFlip(settings.vFlipBehaviour, +//ofGetCurrentOrientationMatrix(), +//vFlip); +//if(vFlip == V_FLIP_OFF){ +//ofTranslate(pl * magic, (pt * magic) + (-1 * h), 0); +////ofTranslate(pl * magic, -1 * pt * magic, 0); +//}else{ +//ofTranslate(pl * magic, -1 * pt * magic, 0); +//} +} diff --git a/src/Utils.h b/src/Utils.h index 017fe3b..fbaff93 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -1,6 +1,7 @@ #pragma once #include +#include namespace ofxVariableLab { @@ -21,5 +22,23 @@ inline void hash_combine(std::size_t & seed, const T & v){ std::hash hasher; seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } +enum VFlipState { + V_FLIP_UNKNOWN = 0, + V_FLIP_ON, + V_FLIP_OFF +}; +enum VFlipBehaviour { + /// probe view matrix every frame + V_FLIP_ALWAYS_AUTO = 0, + /// probe view matrix once and remember + V_FLIP_ONCE_AUTO, + /// never probe and force off + V_FLIP_ALWAYS_OFF, + /// never probe and force on + V_FLIP_ALWAYS_ON +}; +void getVFlip(const VFlipBehaviour & vFlipBehaviour, + const glm::mat4 & orientationMatrix, + VFlipState & vFlip); }