Skip to content

Commit c9ae393

Browse files
committed
Skip the geometric median calculation if there is only a one position in the buffer.
1 parent 294039f commit c9ae393

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

TabletDriverService/TabletFilterNoiseReduction.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ bool TabletFilterNoiseReduction::GetPosition(Vector2D *outputVector) {
5858

5959
// Update
6060
void TabletFilterNoiseReduction::Update() {
61+
62+
// One position in the buffer?
63+
if(bufferPositionCount == 1) {
64+
position.x = buffer[0].x;
65+
position.y = buffer[0].y;
66+
return;
67+
}
68+
69+
// Calculate geometric median from the buffer positions
6170
GetGeometricMedianVector(&position, iterations);
6271

6372
// Reset the buffer when distance to last target position is larger than the threshold
@@ -72,6 +81,9 @@ void TabletFilterNoiseReduction::Update() {
7281

7382

7483

84+
//
85+
// Reset buffer
86+
//
7587
void TabletFilterNoiseReduction::ResetBuffer() {
7688
bufferPositionCount = 0;
7789
bufferCurrentIndex = 0;

0 commit comments

Comments
 (0)