Browse Source

Use double for absolute time

Michael 7 years ago
parent
commit
5db7d68e7e
37 changed files with 86 additions and 75 deletions
  1. 1 1
      Include/Rocket/Core/Context.h
  2. 1 1
      Include/Rocket/Core/SystemInterface.h
  3. 3 1
      Include/Rocket/Core/TypeConverter.inl
  4. 3 3
      Samples/basic/animation/src/main.cpp
  5. 1 1
      Samples/basic/customlog/src/SystemInterface.cpp
  6. 1 1
      Samples/basic/customlog/src/SystemInterface.h
  7. 1 1
      Samples/basic/sfml2/src/SystemInterfaceSFML.cpp
  8. 1 1
      Samples/basic/sfml2/src/SystemInterfaceSFML.h
  9. 1 1
      Samples/basic/transform/src/main.cpp
  10. 2 2
      Samples/invaders/src/DecoratorStarfield.cpp
  11. 1 1
      Samples/invaders/src/DecoratorStarfield.h
  12. 7 4
      Samples/invaders/src/Defender.cpp
  13. 2 2
      Samples/invaders/src/Defender.h
  14. 2 2
      Samples/invaders/src/Invader.cpp
  15. 2 2
      Samples/invaders/src/Invader.h
  16. 1 1
      Samples/invaders/src/Mothership.h
  17. 1 1
      Samples/shell/include/Shell.h
  18. 1 1
      Samples/shell/include/ShellSystemInterface.h
  19. 1 1
      Samples/shell/src/ShellSystemInterface.cpp
  20. 2 2
      Samples/shell/src/macosx/ShellMacOSX.cpp
  21. 2 2
      Samples/shell/src/win32/ShellWin32.cpp
  22. 2 2
      Samples/shell/src/x11/ShellX11.cpp
  23. 9 8
      Source/Controls/ElementDataGridRow.cpp
  24. 7 6
      Source/Controls/WidgetSlider.cpp
  25. 1 1
      Source/Controls/WidgetSlider.h
  26. 6 3
      Source/Controls/WidgetTextInput.cpp
  27. 1 1
      Source/Controls/WidgetTextInput.h
  28. 1 1
      Source/Core/Clock.cpp
  29. 1 1
      Source/Core/Clock.h
  30. 2 2
      Source/Core/Context.cpp
  31. 3 3
      Source/Core/Element.cpp
  32. 6 5
      Source/Core/ElementAnimation.cpp
  33. 3 3
      Source/Core/ElementAnimation.h
  34. 4 4
      Source/Core/WidgetSlider.cpp
  35. 1 1
      Source/Core/WidgetSlider.h
  36. 1 1
      Source/Debugger/SystemInterface.cpp
  37. 1 1
      Source/Debugger/SystemInterface.h

+ 1 - 1
Include/Rocket/Core/Context.h

@@ -279,7 +279,7 @@ private:
 	// The element that was clicked on last.
 	Element* last_click_element;
 	// The time the last click occured.
-	float last_click_time;
+	double last_click_time;
 
 	typedef std::map< String, ElementDocument* > CursorMap;
 	CursorMap cursors;

+ 1 - 1
Include/Rocket/Core/SystemInterface.h

@@ -59,7 +59,7 @@ public:
 
 	/// Get the number of seconds elapsed since the start of the application.
 	/// @return Elapsed time, in seconds.
-	virtual float GetElapsedTime() = 0;
+	virtual double GetElapsedTime() = 0;
 
 	/// Translate the input string into the translated string.
 	/// @param[out] translated Translated string ready for display.

+ 3 - 1
Include/Rocket/Core/TypeConverter.inl

@@ -25,7 +25,8 @@
  *
  */
 
-namespace Rocket::Core {
+namespace Rocket {
+namespace Core {
 
 template <typename SourceType, typename DestType>
 bool TypeConverter<SourceType, DestType>::Convert(const SourceType& /*src*/, DestType& /*dest*/)
@@ -462,3 +463,4 @@ VECTOR_STRING_CONVERTER(Colourb, byte, 4);
 #undef VECTOR_STRING_CONVERTER
 
 }
+}

+ 3 - 3
Samples/basic/animation/src/main.cpp

@@ -167,9 +167,9 @@ void GameLoop()
 		single_loop = false;
 	}
 
-	static float t_prev = 0.0f;
-	float t = Shell::GetElapsedTime();
-	float dt = t - t_prev;
+	static double t_prev = 0.0f;
+	double t = Shell::GetElapsedTime();
+	float dt = float(t - t_prev);
 	static int count_frames = 0;
 	count_frames += 1;
 	//t_prev = t;

+ 1 - 1
Samples/basic/customlog/src/SystemInterface.cpp

@@ -45,7 +45,7 @@ SystemInterface::~SystemInterface()
 }
 
 // Get the number of seconds elapsed since the start of the application.
-float SystemInterface::GetElapsedTime()
+double SystemInterface::GetElapsedTime()
 {
 	return Shell::GetElapsedTime();
 }

+ 1 - 1
Samples/basic/customlog/src/SystemInterface.h

@@ -43,7 +43,7 @@ public:
 
 	/// Get the number of seconds elapsed since the start of the application.
 	/// @return Elapsed time, in seconds.
-	virtual float GetElapsedTime();
+	virtual double GetElapsedTime();
 
 	/// Log the specified message.
 	/// @param[in] type Type of log message, ERROR, WARNING, etc.

+ 1 - 1
Samples/basic/sfml2/src/SystemInterfaceSFML.cpp

@@ -304,7 +304,7 @@ Rocket::Core::Input::KeyIdentifier RocketSFMLSystemInterface::TranslateKey(sf::K
 	return Rocket::Core::Input::KI_UNKNOWN;
 };
 
-float RocketSFMLSystemInterface::GetElapsedTime()
+double RocketSFMLSystemInterface::GetElapsedTime()
 {
 	return timer.getElapsedTime().asSeconds();
 };

+ 1 - 1
Samples/basic/sfml2/src/SystemInterfaceSFML.h

@@ -37,7 +37,7 @@ public:
 
 	Rocket::Core::Input::KeyIdentifier TranslateKey(sf::Keyboard::Key Key);
 	int GetKeyModifiers(sf::Window *Window);
-	float GetElapsedTime();
+	double GetElapsedTime();
 	bool LogMessage(Rocket::Core::Log::Type type, const Rocket::Core::String& message);
 
 private:

+ 1 - 1
Samples/basic/transform/src/main.cpp

@@ -107,7 +107,7 @@ void GameLoop()
 
 	static float deg = 0;
 	Rocket::Core::SystemInterface* system_interface = Rocket::Core::GetSystemInterface();
-	deg = std::fmod(system_interface->GetElapsedTime() * 30.0f, 360.0f);
+	deg = (float)std::fmod(system_interface->GetElapsedTime() * 30.0, 360.0);
 	if (window_1)
 	{
 		window_1->SetRotation(deg);

+ 2 - 2
Samples/invaders/src/DecoratorStarfield.cpp

@@ -123,8 +123,8 @@ void DecoratorStarfield::RenderElement(Rocket::Core::Element* ROCKET_UNUSED_PARA
 
 void DecoratorStarfield::StarField::Update()
 {
-	float time = Shell::GetElapsedTime();
-	float delta_time = time - last_update;
+	double time = Shell::GetElapsedTime();
+	float delta_time = float(time - last_update);
 	last_update = time;
 
 	if (!GameDetails::GetPaused())

+ 1 - 1
Samples/invaders/src/DecoratorStarfield.h

@@ -71,7 +71,7 @@ private:
 	struct StarField
 	{
 		void Update();
-		float last_update;
+		double last_update;
 		Rocket::Core::Vector2f dimensions;
 
 		typedef std::vector< StarLayer > StarLayerList;

+ 7 - 4
Samples/invaders/src/Defender.cpp

@@ -36,7 +36,7 @@
 #include "Sprite.h"
 
 const float UPDATE_FREQ = 0.01f;
-const float MOVEMENT_SPEED = 15;
+const float MOVEMENT_SPEED = 300;
 const float BULLET_SPEED = 15;
 const int SPRITE_WIDTH = 64;
 const float RESPAWN_TIME = 1.0f;
@@ -63,12 +63,15 @@ Defender::~Defender()
 
 void Defender::Update()
 {
-	if (Shell::GetElapsedTime() - defender_frame_start < UPDATE_FREQ)
+	float dt = float(Shell::GetElapsedTime() - defender_frame_start);
+	if (dt < UPDATE_FREQ)
 		return;
 	
+	dt = Rocket::Core::Math::Min(dt, 0.1f);
+
 	defender_frame_start = Shell::GetElapsedTime();	
 
-	position.x += (move_direction * MOVEMENT_SPEED);
+	position.x += (move_direction * dt * MOVEMENT_SPEED);
 
 	if (position.x < 5)
 		position.x = 5;
@@ -90,7 +93,7 @@ void Defender::Update()
 		render = !render;
 
 		// Check if we should switch back to our alive state
-		if (Shell::GetElapsedTime() - respawn_start > RESPAWN_TIME)
+		if (float(Shell::GetElapsedTime() - respawn_start) > RESPAWN_TIME)
 		{
 			state = ALIVE;
 			render = true;

+ 2 - 2
Samples/invaders/src/Defender.h

@@ -68,8 +68,8 @@ private:
 	bool bullet_in_flight;
 	Rocket::Core::Vector2f bullet_position;
 
-	float defender_frame_start;
-	float respawn_start;
+	double defender_frame_start;
+	double respawn_start;
 
 	bool render;
 

+ 2 - 2
Samples/invaders/src/Invader.cpp

@@ -106,7 +106,7 @@ const Rocket::Core::Vector2f& Invader::GetPosition() const
 void Invader::Update()
 {
 	// Update the bombs
-	if (Shell::GetElapsedTime() - bomb_frame_start > BOMB_UPDATE_FREQ)
+	if (float(Shell::GetElapsedTime() - bomb_frame_start) > BOMB_UPDATE_FREQ)
 	{	
 
 		// Update the bomb position if its in flight, or check if we should drop one
@@ -162,7 +162,7 @@ void Invader::Update()
 		bomb_frame_start = Shell::GetElapsedTime();
 	}
 
-	if (state == EXPLODING && Shell::GetElapsedTime() > death_time)
+	if (state == EXPLODING && Shell::GetElapsedTime() - death_time > 0.0)
 		state = DEAD;
 }
 

+ 2 - 2
Samples/invaders/src/Invader.h

@@ -99,14 +99,14 @@ protected:
 	// The animation frame the bomb is on
 	int bomb_animation_frame;
 	// When the last bomb update occured
-	float bomb_frame_start;
+	double bomb_frame_start;
 	// Probability of us dropping a bomb - this is calculated
 	// at construction time and based on our rank and the game
 	// difficulty level
 	float bomb_probability;
 
 	// Time when we should die - 0, until we're hit
-	float death_time;	
+	double death_time;	
 
 	int GetSpriteIndex() const;
 };

+ 1 - 1
Samples/invaders/src/Mothership.h

@@ -44,7 +44,7 @@ public:
 
 private:
 	// Time of the last update
-	float update_frame_start;
+	double update_frame_start;
 
 	// Direction mothership is flying in
 	float direction;

+ 1 - 1
Samples/shell/include/Shell.h

@@ -80,7 +80,7 @@ public:
 	static void Log(const char* fmt, ...);
 
 	/// Get the number of seconds that have passed since shell startup.
-	static float GetElapsedTime();
+	static double GetElapsedTime();
 	
 	/// Sets the context to send window resized events to.
 	/// @param[in] context The context to send  events to.

+ 1 - 1
Samples/shell/include/ShellSystemInterface.h

@@ -40,7 +40,7 @@ class ShellSystemInterface : public Rocket::Core::SystemInterface
 public:
 	/// Get the number of seconds elapsed since the start of the application
 	/// @returns Seconds elapsed
-	virtual float GetElapsedTime();
+	virtual double GetElapsedTime();
 };
 
 #endif

+ 1 - 1
Samples/shell/src/ShellSystemInterface.cpp

@@ -29,7 +29,7 @@
 #include <Shell.h>
 
 // Get the number of seconds elapsed since the start of the application
-float ShellSystemInterface::GetElapsedTime()
+double ShellSystemInterface::GetElapsedTime()
 {
 	return Shell::GetElapsedTime();
 }

+ 2 - 2
Samples/shell/src/macosx/ShellMacOSX.cpp

@@ -228,7 +228,7 @@ void Shell::Log(const char* fmt, ...)
 	printf("%s", buffer);
 }
 
-float Shell::GetElapsedTime() 
+double Shell::GetElapsedTime() 
 {
 	struct timeval now;
 
@@ -238,7 +238,7 @@ float Shell::GetElapsedTime()
 	double usec = now.tv_usec;
 	double result = sec + (usec / 1000000.0);
 
-	return (float) result;
+	return result;
 }
 
 static void IdleTimerCallback(EventLoopTimerRef timer, EventLoopIdleTimerMessage inState, void* p)

+ 2 - 2
Samples/shell/src/win32/ShellWin32.cpp

@@ -242,12 +242,12 @@ void Shell::Log(const char* fmt, ...)
 	OutputDebugString(buffer);
 }
 
-float Shell::GetElapsedTime() 
+double Shell::GetElapsedTime() 
 {
 	LARGE_INTEGER counter;
 	QueryPerformanceCounter(&counter);
 
-	return (float)((counter.QuadPart - time_startup.QuadPart) * time_frequency);
+	return double(counter.QuadPart - time_startup.QuadPart) * time_frequency;
 }
 
 static LRESULT CALLBACK WindowProcedure(HWND window_handle, UINT message, WPARAM w_param, LPARAM l_param)

+ 2 - 2
Samples/shell/src/x11/ShellX11.cpp

@@ -286,7 +286,7 @@ void Shell::Log(const char* fmt, ...)
 }
 
 // Returns the seconds that have elapsed since program startup.
-float Shell::GetElapsedTime() 
+double Shell::GetElapsedTime() 
 {
 	struct timeval now;
 
@@ -296,5 +296,5 @@ float Shell::GetElapsedTime()
 	double usec = now.tv_usec - start_time.tv_usec;
 	double result = sec + (usec / 1000000.0);
 
-	return (float)result;
+	return result;
 }

+ 9 - 8
Source/Controls/ElementDataGridRow.cpp

@@ -31,11 +31,12 @@
 #include "../../Include/Rocket/Controls/DataFormatter.h"
 #include "../../Include/Rocket/Controls/ElementDataGrid.h"
 #include "../../Include/Rocket/Controls/ElementDataGridCell.h"
+#include "../Core/Clock.h"
 
 namespace Rocket {
 namespace Controls {
 
-const float MAX_UPDATE_TIME = 0.01f;
+static const float MAX_UPDATE_TIME = 0.01f;
 
 ElementDataGridRow::ElementDataGridRow(const Rocket::Core::String& tag) : Core::Element(tag)
 {
@@ -127,7 +128,7 @@ bool ElementDataGridRow::UpdateChildren()
 {
 	if (dirty_children)
 	{
-		float start_time = Core::GetSystemInterface()->GetElapsedTime();
+		double start_time = Core::Clock::GetElapsedTime();
 		
 		RowQueue dirty_rows;
 		dirty_rows.push(this);
@@ -137,7 +138,7 @@ bool ElementDataGridRow::UpdateChildren()
 			ElementDataGridRow* dirty_row = dirty_rows.front();
 			dirty_rows.pop();
 			
-			float time_slice = MAX_UPDATE_TIME - (Core::GetSystemInterface()->GetElapsedTime() - start_time);
+			float time_slice = MAX_UPDATE_TIME - float(Core::Clock::GetElapsedTime() - start_time);
 			if (time_slice <= 0.0f)
 				break;
 
@@ -554,7 +555,7 @@ void ElementDataGridRow::Load(const DataQuery& row_information)
 // Instantiates the children that haven't been fully loaded yet.
 void ElementDataGridRow::LoadChildren(float time_slice)
 {
-	float start_time = Core::GetSystemInterface()->GetElapsedTime();
+	double start_time = Core::Clock::GetElapsedTime();
 
 	int data_query_offset = -1;
 	int data_query_limit = -1;
@@ -570,7 +571,7 @@ void ElementDataGridRow::LoadChildren(float time_slice)
 	//    In either case, we check if we have a hole that's unfilled, and if
 	//    so, we fill it.
 	bool any_dirty_children = false;
-	for (size_t i = 0; i < children.size() && (Core::GetSystemInterface()->GetElapsedTime() - start_time) < time_slice; i++)
+	for (size_t i = 0; i < children.size() && float(Core::Clock::GetElapsedTime() - start_time) < time_slice; i++)
 	{
 		if (children[i]->dirty_cells)
 		{
@@ -607,7 +608,7 @@ void ElementDataGridRow::LoadChildren(float time_slice)
 		// end of the list or the end of the hole, fill the hole.
 		else if (unfilled_hole && (end_of_list || end_of_hole_found))
 		{
-			float load_time_slice = time_slice - (Core::GetSystemInterface()->GetElapsedTime() - start_time);
+			float load_time_slice = time_slice - float(Core::Clock::GetElapsedTime() - start_time);
 			LoadChildren(data_query_offset, data_query_limit, load_time_slice);
 			data_query_offset =  -1;
 			data_query_limit = -1;
@@ -622,7 +623,7 @@ void ElementDataGridRow::LoadChildren(float time_slice)
 
 void ElementDataGridRow::LoadChildren(int first_row_to_load, int num_rows_to_load, Rocket::Core::Time time_slice)
 {
-	float start_time = Core::GetSystemInterface()->GetElapsedTime();
+	double start_time = Core::Clock::GetElapsedTime();
 
 	// Now fetch these new children from the data source, pass them
 	// through each column's data formatter, and add them as our new
@@ -642,7 +643,7 @@ void ElementDataGridRow::LoadChildren(int first_row_to_load, int num_rows_to_loa
 		// Now load the child with the row in the query.
 		children[index]->Load(query);
 
-		if (Core::GetSystemInterface()->GetElapsedTime() - start_time > time_slice)
+		if (float(Core::Clock::GetElapsedTime() - start_time) > time_slice)
 		{
 			break;
 		}

+ 7 - 6
Source/Controls/WidgetSlider.cpp

@@ -28,12 +28,13 @@
 #include "WidgetSlider.h"
 #include "../../Include/Rocket/Core.h"
 #include "../../Include/Rocket/Controls/ElementFormControl.h"
+#include "../Core/Clock.h"
 
 namespace Rocket {
 namespace Controls {
 
-const float DEFAULT_REPEAT_DELAY = 0.5f;
-const float DEFAULT_REPEAT_PERIOD = 0.1f;
+static const float DEFAULT_REPEAT_DELAY = 0.5f;
+static const float DEFAULT_REPEAT_PERIOD = 0.1f;
 
 WidgetSlider::WidgetSlider(ElementFormControl* _parent)
 {
@@ -169,8 +170,8 @@ void WidgetSlider::Update()
 		{
 			if (!updated_time)
 			{
-				float current_time = Core::GetSystemInterface()->GetElapsedTime();
-				delta_time = current_time - last_update_time;
+				double current_time = Core::Clock::GetElapsedTime();
+				delta_time = float(current_time - last_update_time);
 				last_update_time = current_time;
 			}
 
@@ -468,13 +469,13 @@ void WidgetSlider::ProcessEvent(Core::Event& event)
 		if (event.GetTargetElement() == arrows[0])
 		{
 			arrow_timers[0] = DEFAULT_REPEAT_DELAY;
-			last_update_time = Core::GetSystemInterface()->GetElapsedTime();
+			last_update_time = Core::Clock::GetElapsedTime();
 			SetBarPosition(OnLineDecrement());
 		}
 		else if (event.GetTargetElement() == arrows[1])
 		{
 			arrow_timers[1] = DEFAULT_REPEAT_DELAY;
-			last_update_time = Core::GetSystemInterface()->GetElapsedTime();
+			last_update_time = Core::Clock::GetElapsedTime();
 			SetBarPosition(OnLineIncrement());
 		}
 	}

+ 1 - 1
Source/Controls/WidgetSlider.h

@@ -137,7 +137,7 @@ private:
 
 	// Set to the auto-repeat timer if either of the arrow buttons have been pressed, -1 if they haven't.
 	float arrow_timers[2];
-	float last_update_time;
+	double last_update_time;
 };
 
 }

+ 6 - 3
Source/Controls/WidgetTextInput.cpp

@@ -31,11 +31,12 @@
 #include "../../Include/Rocket/Controls/ElementFormControl.h"
 #include "../../Include/Rocket/Controls/Clipboard.h"
 #include "../../Include/Rocket/Core/SystemInterface.h"
+#include "../Core/Clock.h"
 
 namespace Rocket {
 namespace Controls {
 
-const float CURSOR_BLINK_TIME = 0.7f;
+static const float CURSOR_BLINK_TIME = 0.7f;
 
 WidgetTextInput::WidgetTextInput(ElementFormControl* _parent) : internal_dimensions(0, 0), scroll_offset(0, 0), selection_geometry(_parent), cursor_position(0, 0), cursor_size(0, 0), cursor_geometry(_parent)
 {
@@ -91,6 +92,8 @@ WidgetTextInput::WidgetTextInput(ElementFormControl* _parent) : internal_dimensi
 	selection_begin_index = 0;
 	selection_length = 0;
 
+	last_update_time = 0;
+
 	ShowCursor(false);
 }
 
@@ -180,8 +183,8 @@ void WidgetTextInput::OnUpdate()
 {
 	if (cursor_timer > 0)
 	{
-		float current_time = Core::GetSystemInterface()->GetElapsedTime();
-		cursor_timer -= (current_time - last_update_time);
+		double current_time = Core::Clock::GetElapsedTime();
+		cursor_timer -= float(current_time - last_update_time);
 		last_update_time = current_time;
 
 		while (cursor_timer <= 0)

+ 1 - 1
Source/Controls/WidgetTextInput.h

@@ -219,7 +219,7 @@ private:
 	/// @param[in] active True if need activate keyboard, false if need deactivate.
 	void SetKeyboardActive(bool active);
 
-	float last_update_time;
+	double last_update_time;
 
 	// The cursor geometry.
 	float ideal_cursor_position;

+ 1 - 1
Source/Core/Clock.cpp

@@ -32,7 +32,7 @@
 namespace Rocket {
 namespace Core {
 
-float Clock::GetElapsedTime()
+double Clock::GetElapsedTime()
 {
 	SystemInterface* system_interface = GetSystemInterface();
 	if (system_interface != NULL)

+ 1 - 1
Source/Core/Clock.h

@@ -41,7 +41,7 @@ class Clock
 public:
 	/// Get the elapsed time since application startup
 	/// @return Seconds elapsed since application startup.
-	static float GetElapsedTime();
+	static double GetElapsedTime();
 };
 
 }

+ 2 - 2
Source/Core/Context.cpp

@@ -730,9 +730,9 @@ void Context::ProcessMouseButtonDown(int button_index, int key_modifier_state)
 		{
 			// Check for a double-click on an element; if one has occured, we send the 'dblclick' event to the hover
 			// element. If not, we'll start a timer to catch the next one.
-			float click_time = GetSystemInterface()->GetElapsedTime();
+			double click_time = GetSystemInterface()->GetElapsedTime();
 			if (active == last_click_element &&
-				click_time - last_click_time < DOUBLE_CLICK_TIME)
+				float(click_time - last_click_time) < DOUBLE_CLICK_TIME)
 			{
 				if (hover)
 					propogate = hover->DispatchEvent(DBLCLICK, parameters, true);

+ 3 - 3
Source/Core/Element.cpp

@@ -2335,7 +2335,7 @@ ElementAnimationList::iterator Element::StartAnimation(const String & property_n
 
 	if (start_value && start_value->definition)
 	{
-		float start_time = Clock::GetElapsedTime() + delay;
+		double start_time = Clock::GetElapsedTime() + (double)delay;
 		*it = ElementAnimation{ property_name, *start_value, start_time, 0.0f, num_iterations, alternate_direction, false };
 	}
 	else
@@ -2379,7 +2379,7 @@ bool Element::StartTransition(const Transition & transition, const Property& sta
 		return false;
 
 	float duration = transition.duration;
-	float start_time = Clock::GetElapsedTime() + transition.delay;
+	double start_time = Clock::GetElapsedTime() + (double)transition.delay;
 
 	if (it == animations.end())
 	{
@@ -2466,7 +2466,7 @@ void Element::AdvanceAnimations()
 {
 	if (!animations.empty())
 	{
-		float time = Clock::GetElapsedTime();
+		double time = Clock::GetElapsedTime();
 
 		for (auto& animation : animations)
 		{

+ 6 - 5
Source/Core/ElementAnimation.cpp

@@ -358,7 +358,7 @@ static bool PrepareTransforms(std::vector<AnimationKey>& keys, Element& element,
 }
 
 
-ElementAnimation::ElementAnimation(const String& property_name, const Property& current_value, float start_world_time, float duration, int num_iterations, bool alternate_direction, bool is_transition)
+ElementAnimation::ElementAnimation(const String& property_name, const Property& current_value, double start_world_time, float duration, int num_iterations, bool alternate_direction, bool is_transition)
 	: property_name(property_name), duration(duration), num_iterations(num_iterations), alternate_direction(alternate_direction),
 	keys({ AnimationKey{0.0f, current_value, Tween{}} }),
 	last_update_world_time(start_world_time), time_since_iteration_start(0.0f), current_iteration(0), reverse_direction(false), animation_complete(false), is_transition(is_transition)
@@ -461,12 +461,13 @@ float ElementAnimation::GetInterpolationFactorAndKeys(int* out_key0, int* out_ke
 
 
 
-Property ElementAnimation::UpdateAndGetProperty(float world_time, Element& element)
+Property ElementAnimation::UpdateAndGetProperty(double world_time, Element& element)
 {
-	if (animation_complete || world_time - last_update_world_time <= 0.0f)
+	float dt = float(world_time - last_update_world_time);
+	if (animation_complete || dt <= 0.0f)
 		return Property{};
 
-	const float dt = Math::Min(world_time - last_update_world_time, 0.1f);
+	dt = Math::Min(dt, 0.1f);
 
 	last_update_world_time = world_time;
 	time_since_iteration_start += dt;
@@ -476,7 +477,7 @@ Property ElementAnimation::UpdateAndGetProperty(float world_time, Element& eleme
 		// Next iteration
 		current_iteration += 1;
 
-		if (num_iterations == -1 || (current_iteration >= 0 && current_iteration < num_iterations) )
+		if (num_iterations == -1 || (current_iteration >= 0 && current_iteration < num_iterations))
 		{
 			time_since_iteration_start -= duration;
 

+ 3 - 3
Source/Core/ElementAnimation.h

@@ -55,7 +55,7 @@ private:
 
 	std::vector<AnimationKey> keys;
 
-	float last_update_world_time;
+	double last_update_world_time;
 	float time_since_iteration_start;
 	int current_iteration;
 	bool reverse_direction;
@@ -66,11 +66,11 @@ private:
 	float GetInterpolationFactorAndKeys(int* out_key0, int* out_key1) const;
 public:
 	ElementAnimation() {}
-	ElementAnimation(const String& property_name, const Property& current_value, float start_world_time, float duration, int num_iterations, bool alternate_direction, bool is_transition);
+	ElementAnimation(const String& property_name, const Property& current_value, double start_world_time, float duration, int num_iterations, bool alternate_direction, bool is_transition);
 
 	bool AddKey(float target_time, const Property & property, Element & element, Tween tween, bool extend_duration);
 
-	Property UpdateAndGetProperty(float time, Element& element);
+	Property UpdateAndGetProperty(double time, Element& element);
 
 	const String& GetPropertyName() const { return property_name; }
 	float GetDuration() const { return duration; }

+ 4 - 4
Source/Core/WidgetSlider.cpp

@@ -37,8 +37,8 @@
 namespace Rocket {
 namespace Core {
 
-const float DEFAULT_REPEAT_DELAY = 0.5f;
-const float DEFAULT_REPEAT_PERIOD = 0.1f;
+static const float DEFAULT_REPEAT_DELAY = 0.5f;
+static const float DEFAULT_REPEAT_PERIOD = 0.1f;
 
 WidgetSlider::WidgetSlider(Element* _parent)
 {
@@ -170,8 +170,8 @@ void WidgetSlider::Update()
 		{
 			if (!updated_time)
 			{
-				float current_time = Clock::GetElapsedTime();
-				delta_time = current_time - last_update_time;
+				double current_time = Clock::GetElapsedTime();
+				delta_time = float(current_time - last_update_time);
 				last_update_time = current_time;
 			}
 

+ 1 - 1
Source/Core/WidgetSlider.h

@@ -136,7 +136,7 @@ private:
 
 	// Set to the auto-repeat timer if either of the arrow buttons have been pressed, -1 if they haven't.
 	float arrow_timers[2];
-	float last_update_time;
+	double last_update_time;
 };
 
 }

+ 1 - 1
Source/Debugger/SystemInterface.cpp

@@ -47,7 +47,7 @@ SystemInterface::~SystemInterface()
 }
 
 // Get the number of seconds elapsed since the start of the application.
-float SystemInterface::GetElapsedTime()
+double SystemInterface::GetElapsedTime()
 {
 	return application_interface->GetElapsedTime();
 }

+ 1 - 1
Source/Debugger/SystemInterface.h

@@ -52,7 +52,7 @@ public:
 
 	/// Get the number of seconds elapsed since the start of the application.
 	/// @return Elapsed time, in seconds.
-	virtual float GetElapsedTime();
+	virtual double GetElapsedTime();
 
 	/// Translate the input string into the translated string.
 	/// @param[out] translated Translated string ready for display.