summaryrefslogtreecommitdiffstats
path: root/src/Authoring/QT3DSDM/Systems/Cores
diff options
context:
space:
mode:
authorJanne Koskinen <janne.p.koskinen@qt.io>2017-10-18 15:30:08 +0300
committerJanne Koskinen <janne.p.koskinen@qt.io>2017-10-30 11:16:00 +0000
commit66ca35d7d47ee42843d15f3d27ed852aec33b36b (patch)
treef4004464ea4e990a467585119de3620761293a32 /src/Authoring/QT3DSDM/Systems/Cores
parenta0c482a1b625631ec4e4c127a0e62b316261a4e0 (diff)
Remove Boost, part2
Remove Boost dependency Change-Id: I2e3f8323fb352d4197c3812c986c3841d57b92cc Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/QT3DSDM/Systems/Cores')
-rw-r--r--src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.cpp82
-rw-r--r--src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.h18
2 files changed, 54 insertions, 46 deletions
diff --git a/src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.cpp b/src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.cpp
index 05094bd2..38f08e11 100644
--- a/src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.cpp
+++ b/src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.cpp
@@ -43,10 +43,7 @@ typedef SPerfLogEvent TPerfLogMathEvent1;
#include "Qt3DSCubicRoots.h"
#include "Qt3DSCubicRootsImpl.h"
#include "Qt3DSBezierEval.h"
-#include <boost/unordered_map.hpp>
-#include <boost/iterator/transform_iterator.hpp>
using namespace std;
-using namespace boost;
namespace qt3dsdm {
@@ -386,38 +383,40 @@ float CSimpleAnimationCore::EvaluateAnimation(Qt3DSDMAnimationHandle inAnimation
TKeyframe theSearchKey(theKeyframe);
function<TKeyframe(int)> theIntToKeyframe(
std::bind(IntToKeyframe, std::placeholders::_1, std::ref(m_Objects)));
- typedef transform_iterator<function<TKeyframe(int)>, TKeyframeHandleList::const_iterator>
- TTransformIterator;
- TTransformIterator theBound =
- lower_bound(make_transform_iterator(theItem->m_Keyframes.begin(), theIntToKeyframe),
- make_transform_iterator(theItem->m_Keyframes.end(), theIntToKeyframe),
- theSearchKey, KeyframeValueTimeLessThan);
- if (theBound.base() == theItem->m_Keyframes.end())
+
+ TKeyframeHandleList::const_iterator theBound =
+ lower_bound(theItem->m_Keyframes.begin(), theItem->m_Keyframes.end(), theSearchKey,
+ [theIntToKeyframe](const Qt3DSDMKeyframeHandle &inLeft,
+ const TKeyframe &inRight)
+ {return KeyframeTime(theIntToKeyframe(inLeft)) < KeyframeTime(inRight);});
+
+ if (theBound == theItem->m_Keyframes.end())
return KeyframeValue(theItem->m_Keyframes.back(), m_Objects);
- if (theBound.base() == theItem->m_Keyframes.begin())
+ if (theBound == theItem->m_Keyframes.begin())
return KeyframeValue(*theItem->m_Keyframes.begin(), m_Objects);
- TTransformIterator theStartIter = theBound;
+
+ TKeyframeHandleList::const_iterator theStartIter = theBound;
--theStartIter;
// Both iterators must be valid at this point...
- TKeyframe theStart = *theStartIter;
- TKeyframe theFinish = *theBound;
+ Qt3DSDMKeyframeHandle theStart = *theStartIter;
+ Qt3DSDMKeyframeHandle theFinish = *theBound;
switch (theItem->m_AnimationType) {
default:
throw AnimationEvaluationError(L"");
case EAnimationTypeLinear: {
- SLinearKeyframe k1 = get<SLinearKeyframe>(theStart);
- SLinearKeyframe k2 = get<SLinearKeyframe>(theFinish);
+ SLinearKeyframe k1 = get<SLinearKeyframe>(theIntToKeyframe(theStart));
+ SLinearKeyframe k2 = get<SLinearKeyframe>(theIntToKeyframe(theFinish));
return EvaluateLinearKeyframe(k1, k2, inSeconds);
}
case EAnimationTypeBezier: {
- SBezierKeyframe k1 = get<SBezierKeyframe>(theStart);
- SBezierKeyframe k2 = get<SBezierKeyframe>(theFinish);
+ SBezierKeyframe k1 = get<SBezierKeyframe>(theIntToKeyframe(theStart));
+ SBezierKeyframe k2 = get<SBezierKeyframe>(theIntToKeyframe(theFinish));
return DoBezierEvaluation(inSeconds, k1, k2);
}
case EAnimationTypeEaseInOut: {
- SEaseInEaseOutKeyframe k1 = get<SEaseInEaseOutKeyframe>(theStart);
- SEaseInEaseOutKeyframe k2 = get<SEaseInEaseOutKeyframe>(theFinish);
+ SEaseInEaseOutKeyframe k1 = get<SEaseInEaseOutKeyframe>(theIntToKeyframe(theStart));
+ SEaseInEaseOutKeyframe k2 = get<SEaseInEaseOutKeyframe>(theIntToKeyframe(theFinish));
return DoBezierEvaluation(
inSeconds, CreateBezierKeyframeFromEaseInEaseOutKeyframe(NULL, k1, &k2.m_KeyframeValue),
CreateBezierKeyframeFromEaseInEaseOutKeyframe(&k1.m_KeyframeValue, k2, NULL));
@@ -572,45 +571,42 @@ void GetKeyframesAsBezier(Qt3DSDMAnimationHandle inAnimation, const IAnimationCo
TConvertFunc theDataConverter(
std::bind(GetEaseInEaseOutKeyframeData, std::placeholders::_1,
std::cref(inAnimationCore)));
- typedef boost::transform_iterator<TConvertFunc, TKeyframeHandleList::iterator>
- TTransformIterator;
- TTransformIterator thePreviousKeyframe(
- make_transform_iterator(theKeyframes.begin(), theDataConverter));
- TTransformIterator theCurrentKeyframe(make_transform_iterator(
- SafeIncrementIterator(thePreviousKeyframe.base(), theEndKeyframe), theDataConverter));
- TTransformIterator theNextKeyframe(make_transform_iterator(
- SafeIncrementIterator(theCurrentKeyframe.base(), theEndKeyframe), theDataConverter));
+
+ TKeyframeHandleList::iterator thePreviousKeyframe = theKeyframes.begin();
+
+ TKeyframeHandleList::iterator theCurrentKeyframe =
+ SafeIncrementIterator(thePreviousKeyframe, theEndKeyframe);
+
+ TKeyframeHandleList::iterator theNextKeyframe =
+ SafeIncrementIterator(theNextKeyframe, theEndKeyframe);
TBezierKeyframeList::iterator theResult(outKeyframes.begin());
- if (thePreviousKeyframe.base() != theEndKeyframe) {
+ if (thePreviousKeyframe != theEndKeyframe) {
float *theNextValuePtr = NULL;
float theNextValue;
- if (theCurrentKeyframe.base() != theEndKeyframe) {
- theNextValue = theCurrentKeyframe->m_KeyframeValue;
+ if (theCurrentKeyframe != theEndKeyframe) {
+ theNextValue = theDataConverter(*theCurrentKeyframe).m_KeyframeValue;
theNextValuePtr = &theNextValue;
}
- *theResult = CreateBezierKeyframeFromEaseInEaseOutKeyframe(NULL, *thePreviousKeyframe,
- theNextValuePtr);
+ *theResult = CreateBezierKeyframeFromEaseInEaseOutKeyframe(
+ NULL, theDataConverter(*thePreviousKeyframe), theNextValuePtr);
theResult = theResult + 1;
}
- for (; theCurrentKeyframe.base() != theEndKeyframe;
+ for (; theCurrentKeyframe != theEndKeyframe;
++thePreviousKeyframe,
- theCurrentKeyframe = make_transform_iterator(
- SafeIncrementIterator(theCurrentKeyframe.base(), theEndKeyframe),
- theDataConverter),
- theNextKeyframe = make_transform_iterator(
- SafeIncrementIterator(theNextKeyframe.base(), theEndKeyframe), theDataConverter),
+ theCurrentKeyframe = SafeIncrementIterator(theCurrentKeyframe, theEndKeyframe),
+ theNextKeyframe = SafeIncrementIterator(theNextKeyframe, theEndKeyframe),
++theResult) {
- float theLastValue(thePreviousKeyframe->m_KeyframeValue);
+ float theLastValue(theDataConverter(*thePreviousKeyframe).m_KeyframeValue);
float *theNextValuePtr = NULL;
float theNextValue;
- if (theNextKeyframe.base() != theEndKeyframe) {
- theNextValue = theNextKeyframe->m_KeyframeValue;
+ if (theNextKeyframe != theEndKeyframe) {
+ theNextValue = theDataConverter(*theNextKeyframe).m_KeyframeValue;
theNextValuePtr = &theNextValue;
}
*theResult = CreateBezierKeyframeFromEaseInEaseOutKeyframe(
- &theLastValue, *theCurrentKeyframe, theNextValuePtr);
+ &theLastValue, theDataConverter(*theCurrentKeyframe), theNextValuePtr);
}
} break;
}
diff --git a/src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.h b/src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.h
index 90f0e3fd..cb4c4154 100644
--- a/src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.h
+++ b/src/Authoring/QT3DSDM/Systems/Cores/SimpleAnimationCore.h
@@ -31,7 +31,19 @@
#define ANIMATIONCOREH
#include "Qt3DSDMAnimation.h"
#include "HandleSystemBase.h"
-#include <boost/unordered_map.hpp>
+#include <unordered_map>
+
+namespace {
+struct pair_hash {
+ template <class T1, class T2>
+ std::size_t operator () (const std::pair<T1, T2> &p) const {
+ auto h1 = std::hash<T1>{}(p.first);
+ auto h2 = std::hash<T2>{}(p.second);
+
+ return h1 ^ h2;
+ }
+ };
+}
namespace qt3dsdm {
struct SAnimationTrack : public CHandleObject
@@ -98,8 +110,8 @@ class CAnimationCoreProducer;
class CSimpleAnimationCore : public CHandleBase, public IAnimationCore
{
TStringTablePtr m_StringTable;
- typedef boost::unordered_multimap<std::pair<int, int>, std::shared_ptr<SAnimationTrack>>
- TStateInstanceAnimationMap;
+ typedef std::unordered_multimap<std::pair<int, int>,
+ std::shared_ptr<SAnimationTrack>, pair_hash> TStateInstanceAnimationMap;
// state,instance pair map to animation handle to speed up querying if a particular
// property is animated.
mutable TStateInstanceAnimationMap m_AnimationMatchesCache;