Sfoglia il codice sorgente

[ue4] Remove SpineWidget Scale property in favor of full support for the widget transform properties. Closes #1496.

badlogic 6 anni fa
parent
commit
3c6feff577

+ 3 - 0
CHANGELOG.md

@@ -18,12 +18,15 @@
 * **Breaking Changes**
 
 * **Additions**
+* Removed dependency on STL throughout the code base, cutting down on the LOC that need parsing by 66%.
 
 ### Cocos2d-x
 
 ### SFML
 
 ### UE4
+* `SpineWidget` now supports the full widget transform, including rendering scale/shear.
+* **Breaking changes**: `SpineWidget` no longer has the `Scale` property. Instead the size x/y properties can be used.
 
 ## C# ##
 * **Breaking changes**

+ 4 - 3
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SSpineWidget.cpp

@@ -171,12 +171,12 @@ void SSpineWidget::Flush(int32 LayerId, FSlateWindowElementList& OutDrawElements
 	if (Vertices.Num() == 0) return;
 	SSpineWidget* self = (SSpineWidget*)this;
 
-	const FVector2D widgetSize = AllottedGeometry.GetDrawSize();
+	const FVector2D widgetSize = AllottedGeometry.GetLocalSize();
 	const FVector2D sizeScale = widgetSize / FVector2D(boundsSize.X, boundsSize.Y);
 	const float setupScale = sizeScale.GetMin();
 
 	for (int i = 0; i < Vertices.Num(); i++) {
-		Vertices[i] = (Vertices[i] + FVector(-boundsMin.X - boundsSize.X / 2, boundsMin.Y + boundsSize.Y / 2, 0)) * setupScale * widget->Scale + FVector(widgetSize.X / 2, widgetSize.Y / 2, 0);
+		Vertices[i] = (Vertices[i] + FVector(-boundsMin.X - boundsSize.X / 2, boundsMin.Y + boundsSize.Y / 2, 0)) * setupScale + FVector(widgetSize.X / 2, widgetSize.Y / 2, 0);
 	}
 
 	self->renderData.IndexData.SetNumUninitialized(Indices.Num());
@@ -189,9 +189,10 @@ void SSpineWidget::Flush(int32 LayerId, FSlateWindowElementList& OutDrawElements
 	FSlateVertex* vertexData = (FSlateVertex*)renderData.VertexData.GetData();
 	FVector2D offset = AllottedGeometry.AbsolutePosition;
 	FColor white = FColor(0xffffffff);
+	const FSlateRenderTransform& Transform = AllottedGeometry.GetAccumulatedRenderTransform();
 
 	for (size_t i = 0; i < (size_t)Vertices.Num(); i++) {
-		setVertex(&vertexData[i], Vertices[i].X, Vertices[i].Y, Uvs[i].X, Uvs[i].Y, Colors[i], offset);
+		setVertex(&vertexData[i], 0, 0, Uvs[i].X, Uvs[i].Y, Colors[i], Transform.TransformPoint(FVector2D(Vertices[i])));
 	}
 
 	brush = &widget->Brush;

+ 0 - 2
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineWidget.h

@@ -51,8 +51,6 @@ public:
 #if WITH_EDITOR
 	virtual const FText GetPaletteCategory() override;
 #endif
-	UPROPERTY(Category = Spine, EditAnywhere, BlueprintReadWrite)
-	float Scale = 1;
 
 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Spine)
 	USpineAtlasAsset* Atlas;