mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
more avg fixes
This commit is contained in:
parent
4454566aa1
commit
0740440edc
@ -386,7 +386,7 @@ record_new_frame(int thread_index, int frame_number,
|
|||||||
void PStatClientData::
|
void PStatClientData::
|
||||||
slot_collector(int collector_index) {
|
slot_collector(int collector_index) {
|
||||||
// A sanity check on the index number.
|
// A sanity check on the index number.
|
||||||
nassertv(collector_index < 1000);
|
nassertv(collector_index < 10000);
|
||||||
|
|
||||||
while ((int)_collectors.size() <= collector_index) {
|
while ((int)_collectors.size() <= collector_index) {
|
||||||
Collector collector;
|
Collector collector;
|
||||||
|
@ -227,16 +227,21 @@ get_collector_under_pixel(int xpoint, int ypoint) {
|
|||||||
|
|
||||||
// Now use that time to determine the frame.
|
// Now use that time to determine the frame.
|
||||||
const PStatThreadData *thread_data = _view.get_thread_data();
|
const PStatThreadData *thread_data = _view.get_thread_data();
|
||||||
int frame_number = thread_data->get_frame_number_at_time(time);
|
|
||||||
|
|
||||||
// And now we can determine which collector within the frame,
|
// And now we can determine which collector within the frame,
|
||||||
// based on the value height.
|
// based on the value height.
|
||||||
const FrameData &frame = get_frame_data(frame_number);
|
if (_average_mode) {
|
||||||
|
float start_time = pixel_to_timestamp(xpoint);
|
||||||
|
int then_i = thread_data->get_frame_number_at_time(start_time - pstats_average_time);
|
||||||
|
int now_i = thread_data->get_frame_number_at_time(start_time, then_i);
|
||||||
|
|
||||||
|
FrameData fdata;
|
||||||
|
compute_average_pixel_data(fdata, then_i, now_i, start_time);
|
||||||
float overall_value = 0.0;
|
float overall_value = 0.0;
|
||||||
int y = get_ysize();
|
int y = get_ysize();
|
||||||
|
|
||||||
FrameData::const_iterator fi;
|
FrameData::const_iterator fi;
|
||||||
for (fi = frame.begin(); fi != frame.end(); ++fi) {
|
for (fi = fdata.begin(); fi != fdata.end(); ++fi) {
|
||||||
const ColorData &cd = (*fi);
|
const ColorData &cd = (*fi);
|
||||||
overall_value += cd._net_value;
|
overall_value += cd._net_value;
|
||||||
y = height_to_pixel(overall_value);
|
y = height_to_pixel(overall_value);
|
||||||
@ -245,6 +250,23 @@ get_collector_under_pixel(int xpoint, int ypoint) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
int frame_number = thread_data->get_frame_number_at_time(time);
|
||||||
|
const FrameData &fdata = get_frame_data(frame_number);
|
||||||
|
float overall_value = 0.0;
|
||||||
|
int y = get_ysize();
|
||||||
|
|
||||||
|
FrameData::const_iterator fi;
|
||||||
|
for (fi = fdata.begin(); fi != fdata.end(); ++fi) {
|
||||||
|
const ColorData &cd = (*fi);
|
||||||
|
overall_value += cd._net_value;
|
||||||
|
y = height_to_pixel(overall_value);
|
||||||
|
if (y <= ypoint) {
|
||||||
|
return cd._collector_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,15 +370,16 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (ai != fdata.end() && bi != additional.end()) {
|
while (ai != fdata.end() && bi != additional.end()) {
|
||||||
if ((*ai)._collector_index < (*bi)._collector_index) {
|
if ((*ai)._i < (*bi)._i) {
|
||||||
// Here's a data value that's in data, but not in additional.
|
// Here's a data value that's in data, but not in additional.
|
||||||
result.push_back(*ai);
|
result.push_back(*ai);
|
||||||
++ai;
|
++ai;
|
||||||
|
|
||||||
} else if ((*bi)._collector_index < (*ai)._collector_index) {
|
} else if ((*bi)._i < (*ai)._i) {
|
||||||
// Here's a data value that's in additional, but not in data.
|
// Here's a data value that's in additional, but not in data.
|
||||||
ColorData scaled;
|
ColorData scaled;
|
||||||
scaled._collector_index = (*bi)._collector_index;
|
scaled._collector_index = (*bi)._collector_index;
|
||||||
|
scaled._i = (*bi)._i;
|
||||||
scaled._net_value = (*bi)._net_value * weight;
|
scaled._net_value = (*bi)._net_value * weight;
|
||||||
result.push_back(scaled);
|
result.push_back(scaled);
|
||||||
++bi;
|
++bi;
|
||||||
@ -365,6 +388,7 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional,
|
|||||||
// Here's a data value that's in both.
|
// Here's a data value that's in both.
|
||||||
ColorData combined;
|
ColorData combined;
|
||||||
combined._collector_index = (*ai)._collector_index;
|
combined._collector_index = (*ai)._collector_index;
|
||||||
|
combined._i = (*bi)._i;
|
||||||
combined._net_value = (*ai)._net_value + (*bi)._net_value * weight;
|
combined._net_value = (*ai)._net_value + (*bi)._net_value * weight;
|
||||||
result.push_back(combined);
|
result.push_back(combined);
|
||||||
++ai;
|
++ai;
|
||||||
@ -382,6 +406,7 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional,
|
|||||||
// Here's a data value that's in additional, but not in data.
|
// Here's a data value that's in additional, but not in data.
|
||||||
ColorData scaled;
|
ColorData scaled;
|
||||||
scaled._collector_index = (*bi)._collector_index;
|
scaled._collector_index = (*bi)._collector_index;
|
||||||
|
scaled._i = (*bi)._i;
|
||||||
scaled._net_value = (*bi)._net_value * weight;
|
scaled._net_value = (*bi)._net_value * weight;
|
||||||
result.push_back(scaled);
|
result.push_back(scaled);
|
||||||
++bi;
|
++bi;
|
||||||
@ -431,7 +456,8 @@ get_frame_data(int frame_number) {
|
|||||||
for (int i = 0; i < num_children; i++) {
|
for (int i = 0; i < num_children; i++) {
|
||||||
const PStatViewLevel *child = level->get_child(i);
|
const PStatViewLevel *child = level->get_child(i);
|
||||||
ColorData cd;
|
ColorData cd;
|
||||||
cd._collector_index = child->get_collector();
|
cd._collector_index = (unsigned short)child->get_collector();
|
||||||
|
cd._i = (unsigned short)i;
|
||||||
cd._net_value = child->get_net_value();
|
cd._net_value = child->get_net_value();
|
||||||
if (cd._net_value != 0.0) {
|
if (cd._net_value != 0.0) {
|
||||||
data.push_back(cd);
|
data.push_back(cd);
|
||||||
@ -441,7 +467,8 @@ get_frame_data(int frame_number) {
|
|||||||
// Also, there might be some value in the overall Collector that
|
// Also, there might be some value in the overall Collector that
|
||||||
// wasn't included in all of the children.
|
// wasn't included in all of the children.
|
||||||
ColorData cd;
|
ColorData cd;
|
||||||
cd._collector_index = level->get_collector();
|
cd._collector_index = (unsigned short)level->get_collector();
|
||||||
|
cd._i = (unsigned short)num_children;
|
||||||
cd._net_value = level->get_value_alone();
|
cd._net_value = level->get_value_alone();
|
||||||
if (cd._net_value != 0.0) {
|
if (cd._net_value != 0.0) {
|
||||||
data.push_back(cd);
|
data.push_back(cd);
|
||||||
|
@ -82,7 +82,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
class ColorData {
|
class ColorData {
|
||||||
public:
|
public:
|
||||||
int _collector_index;
|
unsigned short _collector_index;
|
||||||
|
unsigned short _i;
|
||||||
float _net_value;
|
float _net_value;
|
||||||
};
|
};
|
||||||
typedef pvector<ColorData> FrameData;
|
typedef pvector<ColorData> FrameData;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user