00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef NL_PS_ITERATOR_H
00028 #define NL_PS_ITERATOR_H
00029
00030 #include "nel/3d/animation_time.h"
00031
00032 namespace NL3D
00033 {
00034
00035 #ifdef NL_OS_WINDOWS
00036 #define GET_INLINE __forceinline
00037 #else
00038 #define GET_INLINE
00039 #endif
00040
00041
00042
00051 template <typename T, typename PT>
00052 struct CAdvance1Iterator
00053 {
00054 T It;
00055
00056 CAdvance1Iterator() {}
00058 CAdvance1Iterator(T it, uint32 index = 0)
00059 {
00060 It = it + index;
00061 }
00062 const PT &get() const { return *It; }
00063 void advance() { ++It; }
00064 void advance(uint numSteps)
00065 {
00066 It = It + numSteps;
00067 }
00068 CAdvance1Iterator &operator++() { advance(); return *this; }
00069 CAdvance1Iterator operator++(int) { CAdvance1Iterator tmp = this; advance(); return tmp; }
00070 const PT &operator * () const { return get(); }
00073
00074 bool operator==(const CAdvance1Iterator &other) const { return other.It == It; }
00075 bool operator!=(const CAdvance1Iterator &other) const { return !(*this == other); }
00076 CAdvance1Iterator operator+(sint quantity) { return CAdvance1Iterator(It + quantity); }
00077 CAdvance1Iterator &operator+=(sint quantity) { It = It + quantity; return *this; }
00078 };
00079
00080
00081
00089 template<typename T, typename PT>
00090 struct CAdvance1616Iterator
00091 {
00092 T It;
00093 uint32 CurrPos;
00094 uint32 Step;
00095 CAdvance1616Iterator() {}
00097 CAdvance1616Iterator(T it, uint32 index, uint32 step)
00098 {
00099 It = it;
00100 CurrPos = index * step;
00101 Step = step;
00102 }
00103
00104 const PT &get() const { return *(It + (CurrPos >> 16)); }
00105 void advance() { CurrPos += Step; }
00106 void advance(uint numSteps)
00107 {
00108 CurrPos = CurrPos + numSteps * Step;
00109 }
00110 const PT &operator * () const { return get(); }
00112 CAdvance1616Iterator &operator++() { advance(); return *this; }
00113 CAdvance1616Iterator operator++(int) { CAdvance1616Iterator tmp = this; advance(); return tmp; }
00114 bool operator==(const CAdvance1616Iterator &other) const
00115 {
00116 #ifdef _DEBUG
00117 nlassert(other.It == It);
00118 nlassert(other.Step == Step);
00119 #endif
00120 return other.CurrPos == CurrPos;
00121 }
00122 bool operator!=(const CAdvance1616Iterator &other) const { return !(*this == other); }
00123 CAdvance1616Iterator operator+(sint quantity)
00124 {
00125 CAdvance1616Iterator res;
00126 res.It = It;
00127 res.CurrPos = CurrPos + Step * quantity;
00128 res.Step = Step;
00129 return res;
00130 }
00131 CAdvance1616Iterator &operator+=(sint quantity)
00132 {
00133 CurrPos += quantity * Step;
00134 return *this;
00135 }
00136 };
00137
00138
00139
00142
00144 typedef CAdvance1Iterator<TPSAttribFloat::const_iterator, float> TIteratorFloatStep1;
00145 typedef CAdvance1Iterator<TPSAttribFloat::const_iterator, TAnimationTime> TIteratorFloatStep1;
00146 typedef CAdvance1Iterator<TPSAttribVector::const_iterator, NLMISC::CVector> TIteratorVectStep1;
00147 typedef CAdvance1616Iterator<TPSAttribFloat::const_iterator, float> TIteratorFloatStep1616;
00148 typedef CAdvance1616Iterator<TPSAttribFloat::const_iterator, TAnimationTime> TIteratorTimeStep1616;
00149 typedef CAdvance1616Iterator<TPSAttribVector::const_iterator, NLMISC::CVector> TIteratorVectStep1616;
00150
00151 }
00152
00153
00154 #endif