Browse Source

Math cleanup, rename and remove some functions

- Math::AbsoluteValue to Math::Absolute.
- Math::Round(Up/Down)Float to Math::Round(Up/Down).
- Math::IsZero to Math::IsCloseToZero.
- Remove Math::RealToInteger.
- Remove clamps which are identical to min/max.
- Remove unnecessary zero checks in Vector::Magnitude.
Michael Ragazzon 2 years ago
parent
commit
a9657acee7
35 changed files with 92 additions and 136 deletions
  1. 8 30
      Include/RmlUi/Core/Math.h
  2. 5 9
      Include/RmlUi/Core/Vector2.inl
  3. 2 6
      Include/RmlUi/Core/Vector3.inl
  4. 2 6
      Include/RmlUi/Core/Vector4.inl
  5. 3 3
      Samples/invaders/src/DecoratorInstancerStarfield.cpp
  6. 2 2
      Samples/invaders/src/DecoratorStarfield.cpp
  7. 2 2
      Samples/invaders/src/Invader.cpp
  8. 3 3
      Samples/luainvaders/src/DecoratorInstancerStarfield.cpp
  9. 2 2
      Samples/luainvaders/src/DecoratorStarfield.cpp
  10. 2 2
      Samples/luainvaders/src/Invader.cpp
  11. 1 1
      Source/Core/DataTypeRegister.cpp
  12. 1 1
      Source/Core/DecoratorTiled.cpp
  13. 2 2
      Source/Core/DecoratorTiledHorizontal.cpp
  14. 2 2
      Source/Core/DecoratorTiledVertical.cpp
  15. 2 2
      Source/Core/Element.cpp
  16. 3 3
      Source/Core/ElementHandle.cpp
  17. 1 1
      Source/Core/Elements/ElementProgress.cpp
  18. 1 1
      Source/Core/Elements/WidgetSlider.cpp
  19. 2 2
      Source/Core/Elements/WidgetTextInput.cpp
  20. 1 1
      Source/Core/FontEffectBlur.cpp
  21. 1 1
      Source/Core/FontEffectOutline.cpp
  22. 2 2
      Source/Core/FontEffectShadow.cpp
  23. 1 1
      Source/Core/FontEngineDefault/FontFamily.cpp
  24. 2 2
      Source/Core/FontEngineDefault/FontProvider.cpp
  25. 5 5
      Source/Core/GeometryBackgroundBorder.cpp
  26. 3 3
      Source/Core/Layout/FlexFormattingContext.cpp
  27. 1 1
      Source/Core/Layout/InlineContainer.cpp
  28. 1 1
      Source/Core/Layout/LineBox.cpp
  29. 15 25
      Source/Core/Math.cpp
  30. 1 1
      Source/Core/PropertyParserColour.cpp
  31. 5 5
      Source/Core/ScrollController.cpp
  32. 4 4
      Source/Core/StreamMemory.cpp
  33. 1 1
      Source/Core/StyleSheetParser.cpp
  34. 1 1
      Source/Core/TextureLayoutTexture.cpp
  35. 2 2
      Source/Core/TransformUtilities.cpp

+ 8 - 30
Include/RmlUi/Core/Math.h

@@ -59,18 +59,6 @@ namespace Math {
 		return (a < b) ? a : b;
 		return (a < b) ? a : b;
 	}
 	}
 
 
-	template <typename Type>
-	Type ClampLower(Type value, Type min)
-	{
-		return (value < min) ? min : value;
-	}
-
-	template <typename Type>
-	Type ClampUpper(Type value, Type max)
-	{
-		return (value > max) ? max : value;
-	}
-
 	template <typename Type>
 	template <typename Type>
 	Type Clamp(Type value, Type min, Type max)
 	Type Clamp(Type value, Type min, Type max)
 	{
 	{
@@ -106,26 +94,20 @@ namespace Math {
 	/// Evaluates if a number is, or close to, zero.
 	/// Evaluates if a number is, or close to, zero.
 	/// @param[in] value The number to compare to zero.
 	/// @param[in] value The number to compare to zero.
 	/// @return True if the number if zero or close to it, false otherwise.
 	/// @return True if the number if zero or close to it, false otherwise.
-	RMLUICORE_API bool IsZero(float value);
-	/// Evaluates if two floating-point numbers are equal, or so similar that they could be considered
-	/// so.
-	/// @param[in] value_0 The first number to compare.
-	/// @param[in] value_1 The second number to compare.
-	/// @return True if the numbers are similar or equal.
-	RMLUICORE_API bool AreEqual(float value_0, float value_1);
+	RMLUICORE_API bool IsCloseToZero(float value);
 
 
 	/// Calculates the absolute value of a number.
 	/// Calculates the absolute value of a number.
 	/// @param[in] value The number of get the absolute value of.
 	/// @param[in] value The number of get the absolute value of.
 	/// @return The absolute value of the number.
 	/// @return The absolute value of the number.
-	RMLUICORE_API float AbsoluteValue(float value);
+	RMLUICORE_API float Absolute(float value);
 	/// Calculates the absolute value of a number.
 	/// Calculates the absolute value of a number.
 	/// @param[in] value The number of get the absolute value of.
 	/// @param[in] value The number of get the absolute value of.
 	/// @return The absolute value of the number.
 	/// @return The absolute value of the number.
-	RMLUICORE_API int AbsoluteValue(int value);
+	RMLUICORE_API int Absolute(int value);
 	/// Calculates the component-wise absolute value of a vector.
 	/// Calculates the component-wise absolute value of a vector.
 	/// @param[in] value The vector of get the absolute value of.
 	/// @param[in] value The vector of get the absolute value of.
 	/// @return The absolute value of the vector.
 	/// @return The absolute value of the vector.
-	RMLUICORE_API Vector2f AbsoluteValue(Vector2f value);
+	RMLUICORE_API Vector2f Absolute(Vector2f value);
 
 
 	/// Calculates the cosine of an angle.
 	/// Calculates the cosine of an angle.
 	/// @param[in] angle The angle to calculate the cosine of, in radians.
 	/// @param[in] angle The angle to calculate the cosine of, in radians.
@@ -182,19 +164,19 @@ namespace Math {
 	/// Rounds a floating-point value to the nearest integer.
 	/// Rounds a floating-point value to the nearest integer.
 	/// @param[in] value The value to round.
 	/// @param[in] value The value to round.
 	/// @return The rounded integer as float.
 	/// @return The rounded integer as float.
-	RMLUICORE_API float RoundFloat(float value);
+	RMLUICORE_API float Round(float value);
 	/// Rounds a floating-point value to the nearest integer.
 	/// Rounds a floating-point value to the nearest integer.
 	/// @param[in] value The value to round.
 	/// @param[in] value The value to round.
 	/// @return The rounded integer as double.
 	/// @return The rounded integer as double.
-	RMLUICORE_API double RoundFloat(double value);
+	RMLUICORE_API double Round(double value);
 	/// Rounds a floating-point value up to the nearest integer.
 	/// Rounds a floating-point value up to the nearest integer.
 	/// @param[in] value The value to round.
 	/// @param[in] value The value to round.
 	/// @return The rounded integer as float.
 	/// @return The rounded integer as float.
-	RMLUICORE_API float RoundUpFloat(float value);
+	RMLUICORE_API float RoundUp(float value);
 	/// Rounds a floating-point value down to the nearest integer.
 	/// Rounds a floating-point value down to the nearest integer.
 	/// @param[in] value The value to round.
 	/// @param[in] value The value to round.
 	/// @return The rounded integer as float.
 	/// @return The rounded integer as float.
-	RMLUICORE_API float RoundDownFloat(float value);
+	RMLUICORE_API float RoundDown(float value);
 	/// Rounds a floating-point value to the nearest integer.
 	/// Rounds a floating-point value to the nearest integer.
 	/// @param[in] value The value to round.
 	/// @param[in] value The value to round.
 	/// @return The rounded integer.
 	/// @return The rounded integer.
@@ -213,10 +195,6 @@ namespace Math {
 	/// @param[out] integral The integral part of the value.
 	/// @param[out] integral The integral part of the value.
 	/// @return The fractional part of the value.
 	/// @return The fractional part of the value.
 	RMLUICORE_API float DecomposeFractionalIntegral(float value, float* integral);
 	RMLUICORE_API float DecomposeFractionalIntegral(float value, float* integral);
-	/// Efficiently truncates a floating-point value into an integer.
-	/// @param[in] value The value to truncate.
-	/// @return The truncated value as a signed integer.
-	RMLUICORE_API int RealToInteger(float value);
 
 
 	/// Round the position and width of a line segment to the pixel grid while minimizing movement of the edges.
 	/// Round the position and width of a line segment to the pixel grid while minimizing movement of the edges.
 	/// @param[inout] x The position, which will use normal rounding.
 	/// @param[inout] x The position, which will use normal rounding.

+ 5 - 9
Include/RmlUi/Core/Vector2.inl

@@ -43,11 +43,7 @@ Vector2<Type>::Vector2(Type x, Type y) : x(x), y(y)
 template <typename Type>
 template <typename Type>
 float Vector2<Type>::Magnitude() const
 float Vector2<Type>::Magnitude() const
 {
 {
-	float squared_magnitude = (float)SquaredMagnitude();
-	if (Math::IsZero(squared_magnitude))
-		return 0;
-
-	return Math::SquareRoot(squared_magnitude);
+	return Math::SquareRoot(static_cast<float>(SquaredMagnitude()));
 }
 }
 
 
 template <typename Type>
 template <typename Type>
@@ -66,8 +62,8 @@ inline Vector2<Type> Vector2<Type>::Normalise() const
 template <>
 template <>
 inline Vector2<float> Vector2<float>::Normalise() const
 inline Vector2<float> Vector2<float>::Normalise() const
 {
 {
-	float magnitude = Magnitude();
-	if (Math::IsZero(magnitude))
+	const float magnitude = Magnitude();
+	if (Math::IsCloseToZero(magnitude))
 		return *this;
 		return *this;
 
 
 	return *this / magnitude;
 	return *this / magnitude;
@@ -77,8 +73,8 @@ template <>
 inline Vector2<float> Vector2<float>::Round() const
 inline Vector2<float> Vector2<float>::Round() const
 {
 {
 	Vector2<float> result;
 	Vector2<float> result;
-	result.x = Math::RoundFloat(x);
-	result.y = Math::RoundFloat(y);
+	result.x = Math::Round(x);
+	result.y = Math::Round(y);
 	return result;
 	return result;
 }
 }
 
 

+ 2 - 6
Include/RmlUi/Core/Vector3.inl

@@ -45,11 +45,7 @@ Vector3<Type>::Vector3(Type x, Type y, Type z) : x(x), y(y), z(z)
 template <typename Type>
 template <typename Type>
 float Vector3<Type>::Magnitude() const
 float Vector3<Type>::Magnitude() const
 {
 {
-	float squared_magnitude = (float)SquaredMagnitude();
-	if (Math::IsZero(squared_magnitude))
-		return 0;
-
-	return Math::SquareRoot(squared_magnitude);
+	return Math::SquareRoot(static_cast<float>(SquaredMagnitude()));
 }
 }
 
 
 template <typename Type>
 template <typename Type>
@@ -69,7 +65,7 @@ template <>
 inline Vector3<float> Vector3<float>::Normalise() const
 inline Vector3<float> Vector3<float>::Normalise() const
 {
 {
 	const float magnitude = Magnitude();
 	const float magnitude = Magnitude();
-	if (Math::IsZero(magnitude))
+	if (Math::IsCloseToZero(magnitude))
 		return *this;
 		return *this;
 
 
 	return *this / magnitude;
 	return *this / magnitude;

+ 2 - 6
Include/RmlUi/Core/Vector4.inl

@@ -49,11 +49,7 @@ Vector4<Type>::Vector4(Vector3<Type> const& v, Type w) : x(v.x), y(v.y), z(v.z),
 template <typename Type>
 template <typename Type>
 float Vector4<Type>::Magnitude() const
 float Vector4<Type>::Magnitude() const
 {
 {
-	float squared_magnitude = (float)SquaredMagnitude();
-	if (Math::IsZero(squared_magnitude))
-		return 0;
-
-	return Math::SquareRoot(squared_magnitude);
+	return Math::SquareRoot(static_cast<float>(SquaredMagnitude()));
 }
 }
 
 
 template <typename Type>
 template <typename Type>
@@ -73,7 +69,7 @@ template <>
 inline Vector4<float> Vector4<float>::Normalise() const
 inline Vector4<float> Vector4<float>::Normalise() const
 {
 {
 	const float magnitude = Magnitude();
 	const float magnitude = Magnitude();
-	if (Math::IsZero(magnitude))
+	if (Math::IsCloseToZero(magnitude))
 		return *this;
 		return *this;
 
 
 	return *this / magnitude;
 	return *this / magnitude;

+ 3 - 3
Samples/invaders/src/DecoratorInstancerStarfield.cpp

@@ -47,13 +47,13 @@ DecoratorInstancerStarfield::~DecoratorInstancerStarfield() {}
 Rml::SharedPtr<Rml::Decorator> DecoratorInstancerStarfield::InstanceDecorator(const Rml::String& /*name*/, const Rml::PropertyDictionary& properties,
 Rml::SharedPtr<Rml::Decorator> DecoratorInstancerStarfield::InstanceDecorator(const Rml::String& /*name*/, const Rml::PropertyDictionary& properties,
 	const Rml::DecoratorInstancerInterface& /*instancer_interface*/)
 	const Rml::DecoratorInstancerInterface& /*instancer_interface*/)
 {
 {
-	int num_layers = Rml::Math::RealToInteger(properties.GetProperty(id_num_layers)->Get<float>());
+	int num_layers = properties.GetProperty(id_num_layers)->Get<int>();
 	Rml::Colourb top_colour = properties.GetProperty(id_top_colour)->Get<Rml::Colourb>();
 	Rml::Colourb top_colour = properties.GetProperty(id_top_colour)->Get<Rml::Colourb>();
 	Rml::Colourb bottom_colour = properties.GetProperty(id_bottom_colour)->Get<Rml::Colourb>();
 	Rml::Colourb bottom_colour = properties.GetProperty(id_bottom_colour)->Get<Rml::Colourb>();
 	float top_speed = properties.GetProperty(id_top_speed)->Get<float>();
 	float top_speed = properties.GetProperty(id_top_speed)->Get<float>();
 	float bottom_speed = properties.GetProperty(id_bottom_speed)->Get<float>();
 	float bottom_speed = properties.GetProperty(id_bottom_speed)->Get<float>();
-	int top_density = Rml::Math::RealToInteger(properties.GetProperty(id_top_density)->Get<float>());
-	int bottom_density = Rml::Math::RealToInteger(properties.GetProperty(id_bottom_density)->Get<float>());
+	int top_density = properties.GetProperty(id_top_density)->Get<int>();
+	int bottom_density = properties.GetProperty(id_bottom_density)->Get<int>();
 
 
 	auto decorator = Rml::MakeShared<DecoratorStarfield>();
 	auto decorator = Rml::MakeShared<DecoratorStarfield>();
 	if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density))
 	if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density))

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

@@ -65,7 +65,7 @@ Rml::DecoratorDataHandle DecoratorStarfield::GenerateElementData(Rml::Element* e
 	{
 	{
 		float layer_depth = i / (float)num_layers;
 		float layer_depth = i / (float)num_layers;
 
 
-		int density = Rml::Math::RealToInteger((top_density * layer_depth) + (bottom_density * (1.0f - layer_depth)));
+		int density = int((top_density * layer_depth) + (bottom_density * (1.0f - layer_depth)));
 		star_field->star_layers[i].stars.resize(density);
 		star_field->star_layers[i].stars.resize(density);
 
 
 		Rml::Colourb colour = (top_colour * layer_depth) + (bottom_colour * (1.0f - layer_depth));
 		Rml::Colourb colour = (top_colour * layer_depth) + (bottom_colour * (1.0f - layer_depth));
@@ -104,7 +104,7 @@ void DecoratorStarfield::RenderElement(Rml::Element* element, Rml::DecoratorData
 	star_field->Update(t);
 	star_field->Update(t);
 
 
 	const float dp_ratio = Rml::ElementUtilities::GetDensityIndependentPixelRatio(element);
 	const float dp_ratio = Rml::ElementUtilities::GetDensityIndependentPixelRatio(element);
-	const float point_size = Rml::Math::RoundUpFloat(2.f * dp_ratio);
+	const float point_size = Rml::Math::RoundUp(2.f * dp_ratio);
 
 
 	Rml::RenderInterface* render_interface = element->GetRenderInterface();
 	Rml::RenderInterface* render_interface = element->GetRenderInterface();
 	if (!render_interface)
 	if (!render_interface)

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

@@ -179,7 +179,7 @@ void Invader::Render(float dp_ratio, Rml::TextureHandle texture)
 		color = MOTHERSHIP_COLOUR;
 		color = MOTHERSHIP_COLOUR;
 
 
 	int sprite_index = GetSpriteIndex();
 	int sprite_index = GetSpriteIndex();
-	int sprite_offset = Rml::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2);
+	int sprite_offset = int((invader_sprites[sprite_index].dimensions.x - 48) / 2);
 
 
 	if (state != DEAD)
 	if (state != DEAD)
 		invader_sprites[sprite_index].Render(Rml::Vector2f(position.x - sprite_offset, position.y), dp_ratio, color, texture);
 		invader_sprites[sprite_index].Render(Rml::Vector2f(position.x - sprite_offset, position.y), dp_ratio, color, texture);
@@ -197,7 +197,7 @@ bool Invader::CheckHit(double t, const Rml::Vector2f& check_position)
 {
 {
 	// Get the sprite index we're currently using for collision detection
 	// Get the sprite index we're currently using for collision detection
 	int sprite_index = GetSpriteIndex();
 	int sprite_index = GetSpriteIndex();
-	int sprite_offset = Rml::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2);
+	int sprite_offset = int((invader_sprites[sprite_index].dimensions.x - 48) / 2);
 	float sprite_width = invader_sprites[sprite_index].dimensions.x;
 	float sprite_width = invader_sprites[sprite_index].dimensions.x;
 	float sprite_height = invader_sprites[sprite_index].dimensions.y;
 	float sprite_height = invader_sprites[sprite_index].dimensions.y;
 
 

+ 3 - 3
Samples/luainvaders/src/DecoratorInstancerStarfield.cpp

@@ -47,13 +47,13 @@ DecoratorInstancerStarfield::~DecoratorInstancerStarfield() {}
 Rml::SharedPtr<Rml::Decorator> DecoratorInstancerStarfield::InstanceDecorator(const Rml::String& /*name*/, const Rml::PropertyDictionary& properties,
 Rml::SharedPtr<Rml::Decorator> DecoratorInstancerStarfield::InstanceDecorator(const Rml::String& /*name*/, const Rml::PropertyDictionary& properties,
 	const Rml::DecoratorInstancerInterface& /*instancer_interface*/)
 	const Rml::DecoratorInstancerInterface& /*instancer_interface*/)
 {
 {
-	int num_layers = Rml::Math::RealToInteger(properties.GetProperty(id_num_layers)->Get<float>());
+	int num_layers = properties.GetProperty(id_num_layers)->Get<int>();
 	Rml::Colourb top_colour = properties.GetProperty(id_top_colour)->Get<Rml::Colourb>();
 	Rml::Colourb top_colour = properties.GetProperty(id_top_colour)->Get<Rml::Colourb>();
 	Rml::Colourb bottom_colour = properties.GetProperty(id_bottom_colour)->Get<Rml::Colourb>();
 	Rml::Colourb bottom_colour = properties.GetProperty(id_bottom_colour)->Get<Rml::Colourb>();
 	float top_speed = properties.GetProperty(id_top_speed)->Get<float>();
 	float top_speed = properties.GetProperty(id_top_speed)->Get<float>();
 	float bottom_speed = properties.GetProperty(id_bottom_speed)->Get<float>();
 	float bottom_speed = properties.GetProperty(id_bottom_speed)->Get<float>();
-	int top_density = Rml::Math::RealToInteger(properties.GetProperty(id_top_density)->Get<float>());
-	int bottom_density = Rml::Math::RealToInteger(properties.GetProperty(id_bottom_density)->Get<float>());
+	int top_density = properties.GetProperty(id_top_density)->Get<int>();
+	int bottom_density = properties.GetProperty(id_bottom_density)->Get<int>();
 
 
 	auto decorator = Rml::MakeShared<DecoratorStarfield>();
 	auto decorator = Rml::MakeShared<DecoratorStarfield>();
 	if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density))
 	if (decorator->Initialise(num_layers, top_colour, bottom_colour, top_speed, bottom_speed, top_density, bottom_density))

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

@@ -65,7 +65,7 @@ Rml::DecoratorDataHandle DecoratorStarfield::GenerateElementData(Rml::Element* e
 	{
 	{
 		float layer_depth = i / (float)num_layers;
 		float layer_depth = i / (float)num_layers;
 
 
-		int density = Rml::Math::RealToInteger((top_density * layer_depth) + (bottom_density * (1.0f - layer_depth)));
+		int density = int((top_density * layer_depth) + (bottom_density * (1.0f - layer_depth)));
 		star_field->star_layers[i].stars.resize(density);
 		star_field->star_layers[i].stars.resize(density);
 
 
 		Rml::Colourb colour = (top_colour * layer_depth) + (bottom_colour * (1.0f - layer_depth));
 		Rml::Colourb colour = (top_colour * layer_depth) + (bottom_colour * (1.0f - layer_depth));
@@ -104,7 +104,7 @@ void DecoratorStarfield::RenderElement(Rml::Element* element, Rml::DecoratorData
 	star_field->Update(t);
 	star_field->Update(t);
 
 
 	const float dp_ratio = Rml::ElementUtilities::GetDensityIndependentPixelRatio(element);
 	const float dp_ratio = Rml::ElementUtilities::GetDensityIndependentPixelRatio(element);
-	const float point_size = Rml::Math::RoundUpFloat(2.f * dp_ratio);
+	const float point_size = Rml::Math::RoundUp(2.f * dp_ratio);
 
 
 	Rml::RenderInterface* render_interface = element->GetRenderInterface();
 	Rml::RenderInterface* render_interface = element->GetRenderInterface();
 	if (!render_interface)
 	if (!render_interface)

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

@@ -179,7 +179,7 @@ void Invader::Render(float dp_ratio, Rml::TextureHandle texture)
 		color = MOTHERSHIP_COLOUR;
 		color = MOTHERSHIP_COLOUR;
 
 
 	int sprite_index = GetSpriteIndex();
 	int sprite_index = GetSpriteIndex();
-	int sprite_offset = Rml::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2);
+	int sprite_offset = int((invader_sprites[sprite_index].dimensions.x - 48) / 2);
 
 
 	if (state != DEAD)
 	if (state != DEAD)
 		invader_sprites[sprite_index].Render(Rml::Vector2f(position.x - sprite_offset, position.y), dp_ratio, color, texture);
 		invader_sprites[sprite_index].Render(Rml::Vector2f(position.x - sprite_offset, position.y), dp_ratio, color, texture);
@@ -197,7 +197,7 @@ bool Invader::CheckHit(double t, const Rml::Vector2f& check_position)
 {
 {
 	// Get the sprite index we're currently using for collision detection
 	// Get the sprite index we're currently using for collision detection
 	int sprite_index = GetSpriteIndex();
 	int sprite_index = GetSpriteIndex();
-	int sprite_offset = Rml::Math::RealToInteger((invader_sprites[sprite_index].dimensions.x - 48) / 2);
+	int sprite_offset = int((invader_sprites[sprite_index].dimensions.x - 48) / 2);
 	float sprite_width = invader_sprites[sprite_index].dimensions.x;
 	float sprite_width = invader_sprites[sprite_index].dimensions.x;
 	float sprite_height = invader_sprites[sprite_index].dimensions.y;
 	float sprite_height = invader_sprites[sprite_index].dimensions.y;
 
 

+ 1 - 1
Source/Core/DataTypeRegister.cpp

@@ -98,7 +98,7 @@ DataTypeRegister::DataTypeRegister()
 		double value;
 		double value;
 		if (!arguments[0].GetInto(value))
 		if (!arguments[0].GetInto(value))
 			return {};
 			return {};
-		return Variant(Math::RoundFloat(value));
+		return Variant(Math::Round(value));
 	});
 	});
 }
 }
 
 

+ 1 - 1
Source/Core/DecoratorTiled.cpp

@@ -78,7 +78,7 @@ void DecoratorTiled::Tile::CalculateDimensions(Element* element, const Texture&
 
 
 			const Vector2f size_relative = new_data.size / texture_dimensions;
 			const Vector2f size_relative = new_data.size / texture_dimensions;
 
 
-			new_data.size = Vector2f(Math::AbsoluteValue(new_data.size.x), Math::AbsoluteValue(new_data.size.y));
+			new_data.size = Vector2f(Math::Absolute(new_data.size.x), Math::Absolute(new_data.size.y));
 
 
 			new_data.texcoords[0] = position / texture_dimensions;
 			new_data.texcoords[0] = position / texture_dimensions;
 			new_data.texcoords[1] = size_relative + new_data.texcoords[0];
 			new_data.texcoords[1] = size_relative + new_data.texcoords[0];

+ 2 - 2
Source/Core/DecoratorTiledHorizontal.cpp

@@ -101,8 +101,8 @@ DecoratorDataHandle DecoratorTiledHorizontal::GenerateElementData(Element* eleme
 	ScaleTileDimensions(centre_dimensions, padded_size.y, Axis::Vertical);
 	ScaleTileDimensions(centre_dimensions, padded_size.y, Axis::Vertical);
 
 
 	// Round the outer tile widths now so that we don't get gaps when rounding again in GenerateGeometry.
 	// Round the outer tile widths now so that we don't get gaps when rounding again in GenerateGeometry.
-	left_dimensions.x = Math::RoundFloat(left_dimensions.x);
-	right_dimensions.x = Math::RoundFloat(right_dimensions.x);
+	left_dimensions.x = Math::Round(left_dimensions.x);
+	right_dimensions.x = Math::Round(right_dimensions.x);
 
 
 	// Shrink the x-sizes on the left and right tiles if necessary.
 	// Shrink the x-sizes on the left and right tiles if necessary.
 	if (padded_size.x < left_dimensions.x + right_dimensions.x)
 	if (padded_size.x < left_dimensions.x + right_dimensions.x)

+ 2 - 2
Source/Core/DecoratorTiledVertical.cpp

@@ -102,8 +102,8 @@ DecoratorDataHandle DecoratorTiledVertical::GenerateElementData(Element* element
 	ScaleTileDimensions(centre_dimensions, padded_size.x, Axis::Horizontal);
 	ScaleTileDimensions(centre_dimensions, padded_size.x, Axis::Horizontal);
 
 
 	// Round the outer tile heights now so that we don't get gaps when rounding again in GenerateGeometry.
 	// Round the outer tile heights now so that we don't get gaps when rounding again in GenerateGeometry.
-	top_dimensions.y = Math::RoundFloat(top_dimensions.y);
-	bottom_dimensions.y = Math::RoundFloat(bottom_dimensions.y);
+	top_dimensions.y = Math::Round(top_dimensions.y);
+	bottom_dimensions.y = Math::Round(bottom_dimensions.y);
 
 
 	// Shrink the y-sizes on the left and right tiles if necessary.
 	// Shrink the y-sizes on the left and right tiles if necessary.
 	if (padded_size.y < top_dimensions.y + bottom_dimensions.y)
 	if (padded_size.y < top_dimensions.y + bottom_dimensions.y)

+ 2 - 2
Source/Core/Element.cpp

@@ -912,7 +912,7 @@ float Element::GetScrollLeft()
 
 
 void Element::SetScrollLeft(float scroll_left)
 void Element::SetScrollLeft(float scroll_left)
 {
 {
-	const float new_offset = Math::Clamp(Math::RoundFloat(scroll_left), 0.0f, GetScrollWidth() - GetClientWidth());
+	const float new_offset = Math::Clamp(Math::Round(scroll_left), 0.0f, GetScrollWidth() - GetClientWidth());
 	if (new_offset != scroll_offset.x)
 	if (new_offset != scroll_offset.x)
 	{
 	{
 		scroll_offset.x = new_offset;
 		scroll_offset.x = new_offset;
@@ -930,7 +930,7 @@ float Element::GetScrollTop()
 
 
 void Element::SetScrollTop(float scroll_top)
 void Element::SetScrollTop(float scroll_top)
 {
 {
-	const float new_offset = Math::Clamp(Math::RoundFloat(scroll_top), 0.0f, GetScrollHeight() - GetClientHeight());
+	const float new_offset = Math::Clamp(Math::Round(scroll_top), 0.0f, GetScrollHeight() - GetClientHeight());
 	if (new_offset != scroll_offset.y)
 	if (new_offset != scroll_offset.y)
 	{
 	{
 		scroll_offset.y = new_offset;
 		scroll_offset.y = new_offset;

+ 3 - 3
Source/Core/ElementHandle.cpp

@@ -87,7 +87,7 @@ void ElementHandle::ProcessDefaultAction(Event& event)
 		// Set any auto margins to their current value, since auto-margins may affect the size and position of an element.
 		// Set any auto margins to their current value, since auto-margins may affect the size and position of an element.
 		auto SetDefiniteMargins = [](Element* element, const ComputedValues& computed) {
 		auto SetDefiniteMargins = [](Element* element, const ComputedValues& computed) {
 			auto SetDefiniteMargin = [](Element* element, PropertyId margin_id, Box::Edge edge) {
 			auto SetDefiniteMargin = [](Element* element, PropertyId margin_id, Box::Edge edge) {
-				element->SetProperty(margin_id, Property(Math::RoundFloat(element->GetBox().GetEdge(Box::MARGIN, edge)), Property::PX));
+				element->SetProperty(margin_id, Property(Math::Round(element->GetBox().GetEdge(Box::MARGIN, edge)), Property::PX));
 			};
 			};
 			using Style::Margin;
 			using Style::Margin;
 			if (computed.margin_top().type == Margin::Auto)
 			if (computed.margin_top().type == Margin::Auto)
@@ -118,9 +118,9 @@ void ElementHandle::ProcessDefaultAction(Event& event)
 
 
 				// Check if we have auto-size together with definite right/bottom; if so, the size needs to be fixed to the current size.
 				// Check if we have auto-size together with definite right/bottom; if so, the size needs to be fixed to the current size.
 				if (computed.width().type == Width::Auto && computed.right().type != Right::Auto)
 				if (computed.width().type == Width::Auto && computed.right().type != Right::Auto)
-					move_target->SetProperty(PropertyId::Width, Property(Math::RoundFloat(GetSize(box, computed).x), Property::PX));
+					move_target->SetProperty(PropertyId::Width, Property(Math::Round(GetSize(box, computed).x), Property::PX));
 				if (computed.height().type == Height::Auto && computed.bottom().type != Bottom::Auto)
 				if (computed.height().type == Height::Auto && computed.bottom().type != Bottom::Auto)
-					move_target->SetProperty(PropertyId::Height, Property(Math::RoundFloat(GetSize(box, computed).y), Property::PX));
+					move_target->SetProperty(PropertyId::Height, Property(Math::Round(GetSize(box, computed).y), Property::PX));
 
 
 				SetDefiniteMargins(move_target, computed);
 				SetDefiniteMargins(move_target, computed);
 			}
 			}

+ 1 - 1
Source/Core/Elements/ElementProgress.cpp

@@ -302,7 +302,7 @@ void ElementProgress::GenerateGeometry()
 			const float angle = angle_offset + (cw ? 1.f : -1.f) * normalized_value * 2.f * RMLUI_PI;
 			const float angle = angle_offset + (cw ? 1.f : -1.f) * normalized_value * 2.f * RMLUI_PI;
 			Vector2f pos(Sin(angle), -Cos(angle));
 			Vector2f pos(Sin(angle), -Cos(angle));
 			// Project it from the circle towards the surrounding unit square.
 			// Project it from the circle towards the surrounding unit square.
-			pos = pos / Max(AbsoluteValue(pos.x), AbsoluteValue(pos.y));
+			pos = pos / Max(Absolute(pos.x), Absolute(pos.y));
 			vertices[num_octants].position = pos;
 			vertices[num_octants].position = pos;
 		}
 		}
 
 

+ 1 - 1
Source/Core/Elements/WidgetSlider.cpp

@@ -193,7 +193,7 @@ void WidgetSlider::GetDimensions(Vector2f& dimensions) const
 void WidgetSlider::SetValue(float target_value)
 void WidgetSlider::SetValue(float target_value)
 {
 {
 	float num_steps = (target_value - min_value) / step;
 	float num_steps = (target_value - min_value) / step;
-	float new_value = min_value + Math::RoundFloat(num_steps) * step;
+	float new_value = min_value + Math::Round(num_steps) * step;
 
 
 	if (new_value != value)
 	if (new_value != value)
 		SetBarPosition(SetValueInternal(new_value));
 		SetBarPosition(SetValueInternal(new_value));

+ 2 - 2
Source/Core/Elements/WidgetTextInput.cpp

@@ -904,7 +904,7 @@ void WidgetTextInput::SetCursorFromRelativeIndices(int cursor_line_index, int cu
 int WidgetTextInput::CalculateLineIndex(float position) const
 int WidgetTextInput::CalculateLineIndex(float position) const
 {
 {
 	float line_height = parent->GetLineHeight();
 	float line_height = parent->GetLineHeight();
-	int line_index = Math::RealToInteger(position / line_height);
+	int line_index = int(position / line_height);
 	return Math::Clamp(line_index, 0, (int)(lines.size() - 1));
 	return Math::Clamp(line_index, 0, (int)(lines.size() - 1));
 }
 }
 
 
@@ -1199,7 +1199,7 @@ void WidgetTextInput::GenerateCursor()
 	Vector<int>& indices = cursor_geometry.GetIndices();
 	Vector<int>& indices = cursor_geometry.GetIndices();
 	indices.resize(6);
 	indices.resize(6);
 
 
-	cursor_size.x = Math::RoundFloat(ElementUtilities::GetDensityIndependentPixelRatio(text_element));
+	cursor_size.x = Math::Round(ElementUtilities::GetDensityIndependentPixelRatio(text_element));
 	cursor_size.y = text_element->GetLineHeight() + 2.0f;
 	cursor_size.y = text_element->GetLineHeight() + 2.0f;
 
 
 	Colourb color = parent->GetComputedValues().color();
 	Colourb color = parent->GetComputedValues().color();

+ 1 - 1
Source/Core/FontEffectBlur.cpp

@@ -127,7 +127,7 @@ SharedPtr<FontEffect> FontEffectBlurInstancer::InstanceFontEffect(const String&
 	Colourb color = properties.GetProperty(id_color)->Get<Colourb>();
 	Colourb color = properties.GetProperty(id_color)->Get<Colourb>();
 
 
 	auto font_effect = MakeShared<FontEffectBlur>();
 	auto font_effect = MakeShared<FontEffectBlur>();
-	if (font_effect->Initialise(Math::RealToInteger(width)))
+	if (font_effect->Initialise(int(width)))
 	{
 	{
 		font_effect->SetColour(color);
 		font_effect->SetColour(color);
 		return font_effect;
 		return font_effect;

+ 1 - 1
Source/Core/FontEffectOutline.cpp

@@ -110,7 +110,7 @@ SharedPtr<FontEffect> FontEffectOutlineInstancer::InstanceFontEffect(const Strin
 	Colourb color = properties.GetProperty(id_color)->Get<Colourb>();
 	Colourb color = properties.GetProperty(id_color)->Get<Colourb>();
 
 
 	auto font_effect = MakeShared<FontEffectOutline>();
 	auto font_effect = MakeShared<FontEffectOutline>();
-	if (font_effect->Initialise(Math::RealToInteger(width)))
+	if (font_effect->Initialise(int(width)))
 	{
 	{
 		font_effect->SetColour(color);
 		font_effect->SetColour(color);
 		return font_effect;
 		return font_effect;

+ 2 - 2
Source/Core/FontEffectShadow.cpp

@@ -73,8 +73,8 @@ FontEffectShadowInstancer::~FontEffectShadowInstancer() {}
 SharedPtr<FontEffect> FontEffectShadowInstancer::InstanceFontEffect(const String& /*name*/, const PropertyDictionary& properties)
 SharedPtr<FontEffect> FontEffectShadowInstancer::InstanceFontEffect(const String& /*name*/, const PropertyDictionary& properties)
 {
 {
 	Vector2i offset;
 	Vector2i offset;
-	offset.x = Math::RealToInteger(properties.GetProperty(id_offset_x)->Get<float>());
-	offset.y = Math::RealToInteger(properties.GetProperty(id_offset_y)->Get<float>());
+	offset.x = properties.GetProperty(id_offset_x)->Get<int>();
+	offset.y = properties.GetProperty(id_offset_y)->Get<int>();
 	Colourb color = properties.GetProperty(id_color)->Get<Colourb>();
 	Colourb color = properties.GetProperty(id_color)->Get<Colourb>();
 
 
 	auto font_effect = MakeShared<FontEffectShadow>();
 	auto font_effect = MakeShared<FontEffectShadow>();

+ 1 - 1
Source/Core/FontEngineDefault/FontFamily.cpp

@@ -54,7 +54,7 @@ FontFaceHandleDefault* FontFamily::GetFaceHandle(Style::FontStyle style, Style::
 
 
 		if (face->GetStyle() == style)
 		if (face->GetStyle() == style)
 		{
 		{
-			const int dist = Math::AbsoluteValue((int)face->GetWeight() - (int)weight);
+			const int dist = Math::Absolute((int)face->GetWeight() - (int)weight);
 			if (dist == 0)
 			if (dist == 0)
 			{
 			{
 				// Direct match for weight, break the loop early.
 				// Direct match for weight, break the loop early.

+ 2 - 2
Source/Core/FontEngineDefault/FontProvider.cpp

@@ -176,7 +176,7 @@ bool FontProvider::LoadFontFace(const byte* data, int data_size, bool fallback_f
 			constexpr int search_width = 100;
 			constexpr int search_width = 100;
 			const FontWeight current_weight = it->weight;
 			const FontWeight current_weight = it->weight;
 
 
-			int best_width_distance = Math::AbsoluteValue((int)it->width - search_width);
+			int best_width_distance = Math::Absolute((int)it->width - search_width);
 			auto it_best_width = it;
 			auto it_best_width = it;
 
 
 			// Search forward to find the best 'width' with the same weight.
 			// Search forward to find the best 'width' with the same weight.
@@ -185,7 +185,7 @@ bool FontProvider::LoadFontFace(const byte* data, int data_size, bool fallback_f
 				if (it->weight != current_weight)
 				if (it->weight != current_weight)
 					break;
 					break;
 
 
-				const int width_distance = Math::AbsoluteValue((int)it->width - search_width);
+				const int width_distance = Math::Absolute((int)it->width - search_width);
 				if (width_distance < best_width_distance)
 				if (width_distance < best_width_distance)
 				{
 				{
 					best_width_distance = width_distance;
 					best_width_distance = width_distance;

+ 5 - 5
Source/Core/GeometryBackgroundBorder.cpp

@@ -42,10 +42,10 @@ void GeometryBackgroundBorder::Draw(Vector<Vertex>& vertices, Vector<int>& indic
 	using Edge = Box::Edge;
 	using Edge = Box::Edge;
 
 
 	EdgeSizes border_widths = {
 	EdgeSizes border_widths = {
-		Math::RoundFloat(box.GetEdge(Box::BORDER, Edge::TOP)),
-		Math::RoundFloat(box.GetEdge(Box::BORDER, Edge::RIGHT)),
-		Math::RoundFloat(box.GetEdge(Box::BORDER, Edge::BOTTOM)),
-		Math::RoundFloat(box.GetEdge(Box::BORDER, Edge::LEFT)),
+		Math::Round(box.GetEdge(Box::BORDER, Edge::TOP)),
+		Math::Round(box.GetEdge(Box::BORDER, Edge::RIGHT)),
+		Math::Round(box.GetEdge(Box::BORDER, Edge::BOTTOM)),
+		Math::Round(box.GetEdge(Box::BORDER, Edge::LEFT)),
 	};
 	};
 
 
 	int num_borders = 0;
 	int num_borders = 0;
@@ -113,7 +113,7 @@ void GeometryBackgroundBorder::Draw(Vector<Vertex>& vertices, Vector<int>& indic
 		scale_factor = Math::Min(1.0f, scale_factor);
 		scale_factor = Math::Min(1.0f, scale_factor);
 
 
 		for (float& radius : radii)
 		for (float& radius : radii)
-			radius = Math::RoundFloat(radius * scale_factor);
+			radius = Math::Round(radius * scale_factor);
 
 
 		// Place the circle/ellipse centers
 		// Place the circle/ellipse centers
 		positions_circle_center = {
 		positions_circle_center = {

+ 3 - 3
Source/Core/Layout/FlexFormattingContext.cpp

@@ -426,7 +426,7 @@ void FlexFormattingContext::Format(Vector2f& flex_resulting_content_size, Vector
 			if (flex_factor_sum < 1.f)
 			if (flex_factor_sum < 1.f)
 			{
 			{
 				const float scaled_initial_free_space = initial_free_space * flex_factor_sum;
 				const float scaled_initial_free_space = initial_free_space * flex_factor_sum;
-				if (Math::AbsoluteValue(scaled_initial_free_space) < Math::AbsoluteValue(remaining_free_space))
+				if (Math::Absolute(scaled_initial_free_space) < Math::Absolute(remaining_free_space))
 					remaining_free_space = scaled_initial_free_space;
 					remaining_free_space = scaled_initial_free_space;
 			}
 			}
 
 
@@ -458,7 +458,7 @@ void FlexFormattingContext::Format(Vector2f& flex_resulting_content_size, Vector
 						{
 						{
 							const float scaled_flex_shrink_factor = item.flex_shrink_factor * item.inner_flex_base_size;
 							const float scaled_flex_shrink_factor = item.flex_shrink_factor * item.inner_flex_base_size;
 							const float distribute_ratio = scaled_flex_shrink_factor / scaled_flex_shrink_factor_sum_nonzero;
 							const float distribute_ratio = scaled_flex_shrink_factor / scaled_flex_shrink_factor_sum_nonzero;
-							item.target_main_size = item.flex_base_size - distribute_ratio * Math::AbsoluteValue(remaining_free_space);
+							item.target_main_size = item.flex_base_size - distribute_ratio * Math::Absolute(remaining_free_space);
 						}
 						}
 					}
 					}
 				}
 				}
@@ -636,7 +636,7 @@ void FlexFormattingContext::Format(Vector2f& flex_resulting_content_size, Vector
 				})->hypothetical_cross_size;
 				})->hypothetical_cross_size;
 
 
 			// Currently, we don't handle the case where baseline alignment could extend the line's cross size, see CSS specs 9.4.8.
 			// Currently, we don't handle the case where baseline alignment could extend the line's cross size, see CSS specs 9.4.8.
-			line.cross_size = Math::Max(0.0f, Math::RoundFloat(largest_hypothetical_cross_size));
+			line.cross_size = Math::Max(0.0f, Math::Round(largest_hypothetical_cross_size));
 
 
 			if (flex_single_line)
 			if (flex_single_line)
 				line.cross_size = Math::Clamp(line.cross_size, cross_min_size, cross_max_size);
 				line.cross_size = Math::Clamp(line.cross_size, cross_min_size, cross_max_size);

+ 1 - 1
Source/Core/Layout/InlineContainer.cpp

@@ -162,7 +162,7 @@ void InlineContainer::Close(UniquePtr<LineBox>* out_open_line_box, Vector2f& out
 		visible_overflow_size.x = Math::Max(visible_overflow_size.x, line_box->GetPosition().x - position.x + line_box->GetExtentRight());
 		visible_overflow_size.x = Math::Max(visible_overflow_size.x, line_box->GetPosition().x - position.x + line_box->GetExtentRight());
 	}
 	}
 
 
-	visible_overflow_size.x = Math::RoundDownFloat(visible_overflow_size.x);
+	visible_overflow_size.x = Math::RoundDown(visible_overflow_size.x);
 	SetVisibleOverflowSize(visible_overflow_size);
 	SetVisibleOverflowSize(visible_overflow_size);
 
 
 	out_position = position;
 	out_position = position;

+ 1 - 1
Source/Core/Layout/LineBox.cpp

@@ -60,7 +60,7 @@ bool LineBox::AddBox(InlineLevelBox* box, InlineLayoutMode layout_mode, LayoutOv
 	float available_width = FLT_MAX;
 	float available_width = FLT_MAX;
 	if (layout_mode != InlineLayoutMode::Nowrap)
 	if (layout_mode != InlineLayoutMode::Nowrap)
 	{
 	{
-		available_width = Math::RoundUpFloat(line_width - box_placement_cursor);
+		available_width = Math::RoundUp(line_width - box_placement_cursor);
 		if (available_width < 0.f)
 		if (available_width < 0.f)
 		{
 		{
 			if (layout_mode == InlineLayoutMode::WrapAny)
 			if (layout_mode == InlineLayoutMode::WrapAny)

+ 15 - 25
Source/Core/Math.cpp

@@ -38,27 +38,22 @@ namespace Math {
 
 
 	static constexpr float FZERO = 0.0001f;
 	static constexpr float FZERO = 0.0001f;
 
 
-	RMLUICORE_API bool IsZero(float value)
+	RMLUICORE_API bool IsCloseToZero(float value)
 	{
 	{
-		return AbsoluteValue(value) < FZERO;
+		return Absolute(value) < FZERO;
 	}
 	}
 
 
-	RMLUICORE_API bool AreEqual(float value_0, float value_1)
-	{
-		return IsZero(value_1 - value_0);
-	}
-
-	RMLUICORE_API float AbsoluteValue(float value)
+	RMLUICORE_API float Absolute(float value)
 	{
 	{
 		return fabsf(value);
 		return fabsf(value);
 	}
 	}
 
 
-	RMLUICORE_API int AbsoluteValue(int value)
+	RMLUICORE_API int Absolute(int value)
 	{
 	{
 		return abs(value);
 		return abs(value);
 	}
 	}
 
 
-	RMLUICORE_API Vector2f AbsoluteValue(Vector2f value)
+	RMLUICORE_API Vector2f Absolute(Vector2f value)
 	{
 	{
 		return {fabsf(value.x), fabsf(value.y)};
 		return {fabsf(value.x), fabsf(value.y)};
 	}
 	}
@@ -129,22 +124,22 @@ namespace Math {
 		return sqrtf(value);
 		return sqrtf(value);
 	}
 	}
 
 
-	RMLUICORE_API float RoundFloat(float value)
+	RMLUICORE_API float Round(float value)
 	{
 	{
 		return roundf(value);
 		return roundf(value);
 	}
 	}
 
 
-	RMLUICORE_API double RoundFloat(double value)
+	RMLUICORE_API double Round(double value)
 	{
 	{
 		return round(value);
 		return round(value);
 	}
 	}
 
 
-	RMLUICORE_API float RoundUpFloat(float value)
+	RMLUICORE_API float RoundUp(float value)
 	{
 	{
 		return ceilf(value);
 		return ceilf(value);
 	}
 	}
 
 
-	RMLUICORE_API float RoundDownFloat(float value)
+	RMLUICORE_API float RoundDown(float value)
 	{
 	{
 		return floorf(value);
 		return floorf(value);
 	}
 	}
@@ -152,19 +147,19 @@ namespace Math {
 	RMLUICORE_API int RoundToInteger(float value)
 	RMLUICORE_API int RoundToInteger(float value)
 	{
 	{
 		if (value > 0.0f)
 		if (value > 0.0f)
-			return RealToInteger(value + 0.5f);
+			return int(value + 0.5f);
 
 
-		return RealToInteger(value - 0.5f);
+		return int(value - 0.5f);
 	}
 	}
 
 
 	RMLUICORE_API int RoundUpToInteger(float value)
 	RMLUICORE_API int RoundUpToInteger(float value)
 	{
 	{
-		return RealToInteger(ceilf(value));
+		return int(ceilf(value));
 	}
 	}
 
 
 	RMLUICORE_API int RoundDownToInteger(float value)
 	RMLUICORE_API int RoundDownToInteger(float value)
 	{
 	{
-		return RealToInteger(floorf(value));
+		return int(floorf(value));
 	}
 	}
 
 
 	RMLUICORE_API float DecomposeFractionalIntegral(float value, float* integral)
 	RMLUICORE_API float DecomposeFractionalIntegral(float value, float* integral)
@@ -172,16 +167,11 @@ namespace Math {
 		return modff(value, integral);
 		return modff(value, integral);
 	}
 	}
 
 
-	RMLUICORE_API int RealToInteger(float value)
-	{
-		return int(value);
-	}
-
 	RMLUICORE_API void SnapToPixelGrid(float& offset, float& width)
 	RMLUICORE_API void SnapToPixelGrid(float& offset, float& width)
 	{
 	{
 		const float right_edge = offset + width;
 		const float right_edge = offset + width;
-		offset = Math::RoundFloat(offset);
-		width = Math::RoundFloat(right_edge) - offset;
+		offset = Math::Round(offset);
+		width = Math::Round(right_edge) - offset;
 	}
 	}
 
 
 	RMLUICORE_API void SnapToPixelGrid(Vector2f& position, Vector2f& size)
 	RMLUICORE_API void SnapToPixelGrid(Vector2f& position, Vector2f& size)

+ 1 - 1
Source/Core/PropertyParserColour.cpp

@@ -137,7 +137,7 @@ bool PropertyParserColour::ParseValue(Property& property, const String& value, c
 
 
 			// We're parsing a percentage value.
 			// We're parsing a percentage value.
 			if (values[i].size() > 0 && values[i][values[i].size() - 1] == '%')
 			if (values[i].size() > 0 && values[i][values[i].size() - 1] == '%')
-				component = Math::RealToInteger((float)(atof(values[i].substr(0, values[i].size() - 1).c_str()) / 100.0f) * 255.0f);
+				component = int((float)atof(values[i].substr(0, values[i].size() - 1).c_str()) * (255.0f / 100.0f));
 			// We're parsing a 0 -> 255 integer value.
 			// We're parsing a 0 -> 255 integer value.
 			else
 			else
 				component = atoi(values[i].c_str());
 				component = atoi(values[i].c_str());

+ 5 - 5
Source/Core/ScrollController.cpp

@@ -50,21 +50,21 @@ static Vector2f CalculateAutoscrollVelocity(Vector2f target_delta, float dp_rati
 {
 {
 	target_delta = target_delta / dp_ratio;
 	target_delta = target_delta / dp_ratio;
 	target_delta = {
 	target_delta = {
-		Math::AbsoluteValue(target_delta.x) < AUTOSCROLL_DEADZONE ? 0.f : target_delta.x,
-		Math::AbsoluteValue(target_delta.y) < AUTOSCROLL_DEADZONE ? 0.f : target_delta.y,
+		Math::Absolute(target_delta.x) < AUTOSCROLL_DEADZONE ? 0.f : target_delta.x,
+		Math::Absolute(target_delta.y) < AUTOSCROLL_DEADZONE ? 0.f : target_delta.y,
 	};
 	};
 
 
 	// We use a signed square model for the velocity, which seems to work quite well. This is mostly about feeling and tuning.
 	// We use a signed square model for the velocity, which seems to work quite well. This is mostly about feeling and tuning.
-	return AUTOSCROLL_SPEED_FACTOR * target_delta * Math::AbsoluteValue(target_delta);
+	return AUTOSCROLL_SPEED_FACTOR * target_delta * Math::Absolute(target_delta);
 }
 }
 
 
 // Determines the smoothscroll velocity based on the distance to the target, and the distance scrolled so far. [px/s]
 // Determines the smoothscroll velocity based on the distance to the target, and the distance scrolled so far. [px/s]
 static Vector2f CalculateSmoothscrollVelocity(Vector2f target_delta, Vector2f scrolled_distance, float dp_ratio)
 static Vector2f CalculateSmoothscrollVelocity(Vector2f target_delta, Vector2f scrolled_distance, float dp_ratio)
 {
 {
-	scrolled_distance = Math::AbsoluteValue(scrolled_distance) / dp_ratio;
+	scrolled_distance = Math::Absolute(scrolled_distance) / dp_ratio;
 	target_delta = target_delta / dp_ratio;
 	target_delta = target_delta / dp_ratio;
 
 
-	const Vector2f target_delta_abs = Math::AbsoluteValue(target_delta);
+	const Vector2f target_delta_abs = Math::Absolute(target_delta);
 	Vector2f target_delta_signum = {
 	Vector2f target_delta_signum = {
 		target_delta.x > 0.f ? 1.f : (target_delta.x < 0.f ? -1.f : 0.f),
 		target_delta.x > 0.f ? 1.f : (target_delta.x < 0.f ? -1.f : 0.f),
 		target_delta.y > 0.f ? 1.f : (target_delta.y < 0.f ? -1.f : 0.f),
 		target_delta.y > 0.f ? 1.f : (target_delta.y < 0.f ? -1.f : 0.f),

+ 4 - 4
Source/Core/StreamMemory.cpp

@@ -92,7 +92,7 @@ size_t StreamMemory::Length() const
 
 
 size_t StreamMemory::Read(void* _buffer, size_t bytes) const
 size_t StreamMemory::Read(void* _buffer, size_t bytes) const
 {
 {
-	bytes = Math::ClampUpper(bytes, (size_t)(buffer + buffer_used - buffer_ptr));
+	bytes = Math::Min(bytes, (size_t)(buffer + buffer_used - buffer_ptr));
 
 
 	memcpy(_buffer, buffer_ptr, bytes);
 	memcpy(_buffer, buffer_ptr, bytes);
 
 
@@ -103,7 +103,7 @@ size_t StreamMemory::Read(void* _buffer, size_t bytes) const
 
 
 size_t StreamMemory::Peek(void* _buffer, size_t bytes) const
 size_t StreamMemory::Peek(void* _buffer, size_t bytes) const
 {
 {
-	bytes = Math::ClampUpper(bytes, (size_t)(buffer + buffer_used - buffer_ptr));
+	bytes = Math::Min(bytes, (size_t)(buffer + buffer_used - buffer_ptr));
 
 
 	memcpy(_buffer, buffer_ptr, bytes);
 	memcpy(_buffer, buffer_ptr, bytes);
 
 
@@ -172,7 +172,7 @@ size_t StreamMemory::PopFront(size_t bytes)
 {
 {
 	Erase(0, bytes);
 	Erase(0, bytes);
 	buffer_ptr -= bytes;
 	buffer_ptr -= bytes;
-	buffer_ptr = Math::ClampLower(buffer_ptr, buffer);
+	buffer_ptr = Math::Max(buffer_ptr, buffer);
 	return bytes;
 	return bytes;
 }
 }
 
 
@@ -183,7 +183,7 @@ const byte* StreamMemory::RawStream() const
 
 
 void StreamMemory::Erase(size_t offset, size_t bytes)
 void StreamMemory::Erase(size_t offset, size_t bytes)
 {
 {
-	bytes = Math::ClampUpper(bytes, buffer_used - offset);
+	bytes = Math::Min(bytes, buffer_used - offset);
 	memmove(&buffer[offset], &buffer[offset + bytes], buffer_used - offset - bytes);
 	memmove(&buffer[offset], &buffer[offset + bytes], buffer_used - offset - bytes);
 	buffer_used -= bytes;
 	buffer_used -= bytes;
 }
 }

+ 1 - 1
Source/Core/StyleSheetParser.cpp

@@ -307,7 +307,7 @@ bool StyleSheetParser::ParseKeyframeBlock(KeyframesMap& keyframes_map, const Str
 	for (float selector : rule_values)
 	for (float selector : rule_values)
 	{
 	{
 		auto it = std::find_if(keyframes.blocks.begin(), keyframes.blocks.end(),
 		auto it = std::find_if(keyframes.blocks.begin(), keyframes.blocks.end(),
-			[selector](const KeyframeBlock& keyframe_block) { return Math::AbsoluteValue(keyframe_block.normalized_time - selector) < 0.0001f; });
+			[selector](const KeyframeBlock& keyframe_block) { return Math::Absolute(keyframe_block.normalized_time - selector) < 0.0001f; });
 		if (it == keyframes.blocks.end())
 		if (it == keyframes.blocks.end())
 		{
 		{
 			keyframes.blocks.emplace_back(selector);
 			keyframes.blocks.emplace_back(selector);

+ 1 - 1
Source/Core/TextureLayoutTexture.cpp

@@ -66,7 +66,7 @@ int TextureLayoutTexture::Generate(TextureLayout& layout, int maximum_dimensions
 		}
 		}
 	}
 	}
 
 
-	int texture_width = Math::RealToInteger(Math::SquareRoot((float)square_pixels));
+	int texture_width = int(Math::SquareRoot((float)square_pixels));
 
 
 	dimensions.y = Math::ToPowerOfTwo(texture_width);
 	dimensions.y = Math::ToPowerOfTwo(texture_width);
 	dimensions.x = dimensions.y >> 1;
 	dimensions.x = dimensions.y >> 1;

+ 2 - 2
Source/Core/TransformUtilities.cpp

@@ -726,7 +726,7 @@ bool TransformUtilities::Decompose(Transforms::DecomposedMatrix4& d, const Matri
 
 
 	const float eps = 0.0005f;
 	const float eps = 0.0005f;
 
 
-	if (Math::AbsoluteValue(m[3][3]) < eps)
+	if (Math::Absolute(m[3][3]) < eps)
 		return false;
 		return false;
 
 
 	// Perspective matrix
 	// Perspective matrix
@@ -736,7 +736,7 @@ bool TransformUtilities::Decompose(Transforms::DecomposedMatrix4& d, const Matri
 		p[i][3] = 0;
 		p[i][3] = 0;
 	p[3][3] = 1;
 	p[3][3] = 1;
 
 
-	if (Math::AbsoluteValue(p.Determinant()) < eps)
+	if (Math::Absolute(p.Determinant()) < eps)
 		return false;
 		return false;
 
 
 	if (m[0][3] != 0 || m[1][3] != 0 || m[2][3] != 0)
 	if (m[0][3] != 0 || m[1][3] != 0 || m[2][3] != 0)