Przeglądaj źródła

Fix 1px gap in TiledHorizontal and TiledVertical decorators, such as in invaders sample.

Michael Ragazzon 6 lat temu
rodzic
commit
ce5d60d96d

+ 1 - 1
Samples/invaders/data/game.rml

@@ -24,7 +24,7 @@
 			div
 			{
 				height: 47px;
-				padding: 9px 0px 0px 65px;
+				padding: 8px 0px 0px 65px;
 				margin: 0px 20px;
 
 				font-size: 20px;

+ 1 - 1
Samples/luainvaders/data/game.rml

@@ -23,7 +23,7 @@
 			div
 			{
 				height: 47px;
-				padding: 9px 0px 0px 65px;
+				padding: 8px 0px 0px 65px;
 				margin: 0px 20px;
 
 				font-size: 20px;

+ 4 - 0
Source/Core/DecoratorTiledHorizontal.cpp

@@ -110,6 +110,10 @@ DecoratorDataHandle DecoratorTiledHorizontal::GenerateElementData(Element* eleme
 	ScaleTileDimensions(right_dimensions, padded_size.y, 1);
 	ScaleTileDimensions(centre_dimensions, padded_size.y, 1);
 
+	// 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);
+
 	// Shrink the x-sizes on the left and right tiles if necessary.
 	if (padded_size.x < left_dimensions.x + right_dimensions.x)
 	{

+ 6 - 2
Source/Core/DecoratorTiledVertical.cpp

@@ -111,6 +111,10 @@ DecoratorDataHandle DecoratorTiledVertical::GenerateElementData(Element* element
 	ScaleTileDimensions(bottom_dimensions, padded_size.x, 0);
 	ScaleTileDimensions(centre_dimensions, padded_size.x, 0);
 
+	// 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);
+
 	// Shrink the y-sizes on the left and right tiles if necessary.
 	if (padded_size.y < top_dimensions.y + bottom_dimensions.y)
 	{
@@ -144,11 +148,11 @@ void DecoratorTiledVertical::ReleaseElementData(DecoratorDataHandle element_data
 // Called to render the decorator on an element.
 void DecoratorTiledVertical::RenderElement(Element* element, DecoratorDataHandle element_data) const
 {
-	Vector2f translation = element->GetAbsoluteOffset(Box::PADDING);
+	Vector2f translation = element->GetAbsoluteOffset(Box::PADDING).Round();
 	DecoratorTiledVerticalData* data = reinterpret_cast< DecoratorTiledVerticalData* >(element_data);
 
 	for (int i = 0; i < 3; i++)
-		data->geometry[i]->Render(translation.Round());
+		data->geometry[i]->Render(translation);
 }
 
 }