From c39ef34932540cbf4e9acdca3333b8fe61fd14f1 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 22 Dec 2005 17:33:57 +0000 Subject: [PATCH] incorporate DisplayRegion scale fix from Douglas Warren --- panda/src/tform/mouseWatcher.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 026b0ee540..112678f71d 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -1040,8 +1040,18 @@ do_transmit_data(const DataNodeTransmit &input, DataNodeTransmit &output) { float left, right, bottom, top; _display_region->get_dimensions(left, right, bottom, top); - LVecBase2f new_f((f[0] - left) / (right - left), - (f[1] - bottom) / (top - bottom)); + // Need to translate this into DisplayRegion [0, 1] space + float x = (f[0] + 1.0f) / 2.0f; + // Scale in DR space + float xp = (x - left) / (right - left); + // Translate back into [-1, 1] space + float xpp = (xp * 2.0f) - 1.0f; + + float y = (f[1] + 1.0f) / 2.0f; + float yp = (y - bottom) / (top - bottom); + float ypp = (yp * 2.0f) - 1.0f; + + LVecBase2f new_f(xpp, ypp); LVecBase2f new_p(p[0] - xo, p[1] - xo); set_mouse(new_f, new_p);