forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpStatFrameData.I
More file actions
206 lines (184 loc) · 4.5 KB
/
pStatFrameData.I
File metadata and controls
206 lines (184 loc) · 4.5 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file pStatFrameData.I
* @author drose
* @date 2000-07-10
*/
/**
* Returns true if there are no time events in the frame data, false
* otherwise.
*/
INLINE bool PStatFrameData::
is_time_empty() const {
return _time_data.empty();
}
/**
* Returns true if there are no levels indicated in the frame data, false
* otherwise.
*/
INLINE bool PStatFrameData::
is_level_empty() const {
return _level_data.empty();
}
/**
* Returns true if the FrameData has no time or level data.
*/
INLINE bool PStatFrameData::
is_empty() const {
return is_time_empty() && is_level_empty();
}
/**
* Removes all the data points from the frame data, in preparation for
* building up a new frame's worth.
*/
INLINE void PStatFrameData::
clear() {
_time_data.clear();
_level_data.clear();
}
/**
* Exchanges the data in this object with the data in the other.
*/
INLINE void PStatFrameData::
swap(PStatFrameData &other) {
_time_data.swap(other._time_data);
_level_data.swap(other._level_data);
}
/**
* Adds a 'start collector' data point to the frame data.
*/
INLINE void PStatFrameData::
add_start(int index, double time) {
#ifdef _DEBUG
nassertv((index & 0x7fff) == index);
#endif
DataPoint dp;
dp._index = index;
dp._value = time;
_time_data.push_back(dp);
}
/**
* Adds a 'stop collector' data point to the frame data.
*/
INLINE void PStatFrameData::
add_stop(int index, double time) {
#ifdef _DEBUG
nassertv((index & 0x7fff) == index);
#endif
DataPoint dp;
dp._index = index | 0x8000;
dp._value = time;
_time_data.push_back(dp);
}
/**
* Adds a particular level value associated with a given collector to the
* frame data.
*/
INLINE void PStatFrameData::
add_level(int index, double level) {
#ifdef _DEBUG
nassertv((index & 0xffff) == index);
#endif
DataPoint dp;
dp._index = index;
dp._value = level;
_level_data.push_back(dp);
}
/**
* Returns the time of the first data point in the frame data. This will
* generally be the time of the start of the frame.
*/
INLINE double PStatFrameData::
get_start() const {
if (is_empty()) {
return 0.0;
}
return _time_data.front()._value;
}
/**
* Returns the time of the last data point in the frame data. This will
* generally be the time of the end of the frame.
*/
INLINE double PStatFrameData::
get_end() const {
nassertr(!is_empty(), 0.0);
return _time_data.back()._value;
}
/**
* Returns the total time elapsed for the frame.
*/
INLINE double PStatFrameData::
get_net_time() const {
nassertr(!is_empty(), 0.0);
return _time_data.back()._value - _time_data.front()._value;
}
/**
* Returns the number of individual events stored in the FrameData.
*/
INLINE size_t PStatFrameData::
get_num_events() const {
return _time_data.size();
}
/**
* Returns the index of the collector associated with the nth event.
*/
INLINE int PStatFrameData::
get_time_collector(size_t n) const {
nassertr(n < _time_data.size(), 0);
return _time_data[n]._index & 0x7fff;
}
/**
* Returns true if the nth event represents a start event, or false if it
* represents a stop event.
*/
INLINE bool PStatFrameData::
is_start(size_t n) const {
nassertr(n < _time_data.size(), 0);
return (_time_data[n]._index & 0x8000) == 0;
}
/**
* Returns the timestamp of the nth event, in seconds elapsed since some
* undefined epoch (which is guaranteed to be shared among all events returned
* from a given client).
*/
INLINE double PStatFrameData::
get_time(size_t n) const {
nassertr(n < _time_data.size(), 0);
return _time_data[n]._value;
}
/**
* Returns the number of individual level values stored in the FrameData.
*/
INLINE size_t PStatFrameData::
get_num_levels() const {
return _level_data.size();
}
/**
* Returns the index of the collector associated with the nth level value.
*/
INLINE int PStatFrameData::
get_level_collector(size_t n) const {
nassertr(n < _level_data.size(), 0);
return _level_data[n]._index;
}
/**
* Returns the height of the nth level value.
*/
INLINE double PStatFrameData::
get_level(size_t n) const {
nassertr(n < _level_data.size(), 0);
return _level_data[n]._value;
}
/**
* Orders the data points by time.
*/
INLINE bool PStatFrameData::DataPoint::
operator < (const PStatFrameData::DataPoint &other) const {
return _value < other._value;
}