-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHistoryBuffer.h
44 lines (36 loc) · 1.14 KB
/
HistoryBuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*******************************************************************************
* *
* PrimeSense NiTE 2.0 - Hand Viewer Sample *
* Copyright (C) 2012 PrimeSense Ltd. *
* *
*******************************************************************************/
#ifndef _HISTORY_BUFFER_H_
#define _HISTORY_BUFFER_H_
template <int BufferSize>
class HistoryBuffer
{
public:
HistoryBuffer() : m_currentHead(-1), m_size(0)
{}
void AddPoint(const nite::Point3f& point)
{
++m_currentHead;
if (m_currentHead == BufferSize)
m_currentHead = 0;
m_points[m_currentHead] = point;
if (m_size < BufferSize)
++m_size;
}
int GetSize() {return m_size;}
const nite::Point3f& operator[](int index)
{
return m_points[(m_currentHead - index + BufferSize) % BufferSize];
}
private:
friend class Iterator;
static const int m_bufferSize = BufferSize;
nite::Point3f m_points[BufferSize];
int m_currentHead;
int m_size;
};
#endif