Browse Source

incorporate DisplayRegion scale fix from Douglas Warren

David Rose 20 years ago
parent
commit
c39ef34932
1 changed files with 12 additions and 2 deletions
  1. 12 2
      panda/src/tform/mouseWatcher.cxx

+ 12 - 2
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);