From 76b9df0e537ddcd88747cc34c14c83c954ce6c68 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 14 Nov 2022 13:13:50 +0100 Subject: [PATCH] tform: Change `MouseWatcher::get_mouse()` to return copy of LPoint2 Instead of a reference, which is very unintuitive and a common stumbling block for comparisons --- panda/src/tform/mouseWatcher.I | 7 ++----- panda/src/tform/mouseWatcher.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/panda/src/tform/mouseWatcher.I b/panda/src/tform/mouseWatcher.I index 2b52834551..2a45ea5cf2 100644 --- a/panda/src/tform/mouseWatcher.I +++ b/panda/src/tform/mouseWatcher.I @@ -34,12 +34,9 @@ is_mouse_open() const { * It is only valid to call this if has_mouse() returns true. If so, this * returns the current position of the mouse within the window. */ -INLINE const LPoint2 &MouseWatcher:: +INLINE LPoint2 MouseWatcher:: get_mouse() const { -#ifndef NDEBUG - static LPoint2 bogus_mouse(0.0f, 0.0f); - nassertr(_has_mouse, bogus_mouse); -#endif + nassertr(_has_mouse, LPoint2(0, 0)); return _mouse; } diff --git a/panda/src/tform/mouseWatcher.h b/panda/src/tform/mouseWatcher.h index a1005d2a32..fa012e5780 100644 --- a/panda/src/tform/mouseWatcher.h +++ b/panda/src/tform/mouseWatcher.h @@ -67,7 +67,7 @@ PUBLISHED: INLINE bool has_mouse() const; INLINE bool is_mouse_open() const; - INLINE const LPoint2 &get_mouse() const; + INLINE LPoint2 get_mouse() const; INLINE PN_stdfloat get_mouse_x() const; INLINE PN_stdfloat get_mouse_y() const;