* DataHistory::ValueAt() now interpolates between two values in case the time
doesn't match exactly one data item (before, it would have returned the value of the closest but earlier value). * This almost removes the effect that the older values seem to change with every refresh (because the time did not always match exactly)). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26429 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -172,9 +172,14 @@ DataHistory::ValueAt(bigtime_t time)
|
|||||||
// search in left part
|
// search in left part
|
||||||
right = index - 1;
|
right = index - 1;
|
||||||
} else {
|
} else {
|
||||||
if (index + 1 >= fBuffer.CountItems()
|
data_item* nextItem = fBuffer.ItemAt(index + 1);
|
||||||
|| fBuffer.ItemAt(index + 1)->time > time) {
|
if (nextItem == NULL)
|
||||||
|
return item->value;
|
||||||
|
if (nextItem->time > time) {
|
||||||
// found item
|
// found item
|
||||||
|
int64 value = item->value;
|
||||||
|
value += int64(double(nextItem->value - value)
|
||||||
|
/ (nextItem->time - item->time) * (time - item->time));
|
||||||
return item->value;
|
return item->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user