diff --git a/panda/src/tform/driveInterface.I b/panda/src/tform/driveInterface.I index 790c7b44cd..dcdca94389 100644 --- a/panda/src/tform/driveInterface.I +++ b/panda/src/tform/driveInterface.I @@ -431,3 +431,30 @@ INLINE bool DriveInterface:: get_force_mouse() const { return _force_mouse; } + +//////////////////////////////////////////////////////////////////// +// Function: DriveInterface::set_stop_this_frame +// Access: Published +// Description: If stop_this_frame is true, the next time the frame +// is computed no motion will be allowed, and then the +// flag is reset to false. This can be used to prevent +// too much movement when we know a long time has +// artificially elapsed, for instance when we take a +// screenshot, without munging the clock for everything +// else. +//////////////////////////////////////////////////////////////////// +INLINE void DriveInterface:: +set_stop_this_frame(bool stop_this_frame) { + _stop_this_frame = stop_this_frame; +} + +//////////////////////////////////////////////////////////////////// +// Function: DriveInterface::get_stop_this_frame +// Access: Published +// Description: Returns the current setting of the stop_this_frame +// flag. See set_stop_this_frame(). +//////////////////////////////////////////////////////////////////// +INLINE bool DriveInterface:: +get_stop_this_frame() const { + return _stop_this_frame; +} diff --git a/panda/src/tform/driveInterface.cxx b/panda/src/tform/driveInterface.cxx index b4cac21913..017f72c7f8 100644 --- a/panda/src/tform/driveInterface.cxx +++ b/panda/src/tform/driveInterface.cxx @@ -139,6 +139,7 @@ DriveInterface(const string &name) : _ignore_mouse = false; _force_mouse = false; + _stop_this_frame = false; _mods.add_button(MouseButton::one()); _mods.add_button(MouseButton::two()); @@ -345,6 +346,11 @@ apply(double x, double y, bool any_button) { // Now how far did we move based on the amount of time elapsed? float distance = ClockObject::get_global_clock()->get_dt() * _speed; float rotation = ClockObject::get_global_clock()->get_dt() * _rot_speed; + if (_stop_this_frame) { + distance = 0.0f; + rotation = 0.0f; + _stop_this_frame = false; + } // Now apply the vectors. diff --git a/panda/src/tform/driveInterface.h b/panda/src/tform/driveInterface.h index ee80f20dd3..e397fd725f 100644 --- a/panda/src/tform/driveInterface.h +++ b/panda/src/tform/driveInterface.h @@ -97,6 +97,9 @@ PUBLISHED: INLINE void set_force_mouse(bool force_mouse); INLINE bool get_force_mouse() const; + INLINE void set_stop_this_frame(bool stop_this_frame); + INLINE bool get_stop_this_frame() const; + void set_mat(const LMatrix4f &mat); const LMatrix4f &get_mat(); @@ -128,6 +131,7 @@ private: LVector3f _vel; bool _ignore_mouse; bool _force_mouse; + bool _stop_this_frame; // This is only used to return a temporary value in get_mat(). LMatrix4f _mat;