set_stop_this_frame

This commit is contained in:
David Rose 2002-12-03 18:19:24 +00:00
parent a40db65782
commit e6a55b9590
3 changed files with 37 additions and 0 deletions

View File

@ -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;
}

View File

@ -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.

View File

@ -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;