Kaynağa Gözat

Merge branch '3.8-beta' of https://github.com/esotericsoftware/spine-runtimes into 3.8-beta

badlogic 6 yıl önce
ebeveyn
işleme
9531cb0b7d

+ 1 - 1
spine-csharp/src/SkeletonClipping.cs

@@ -270,7 +270,7 @@ namespace Spine {
 			return clipped;
 		}
 
-		static void MakeClockwise (ExposedList<float> polygon) {
+		public static void MakeClockwise (ExposedList<float> polygon) {
 			float[] vertices = polygon.Items;
 			int verticeslength = polygon.Count;
 

+ 1 - 1
spine-csharp/src/Triangulator.cs

@@ -31,7 +31,7 @@
 using System;
 
 namespace Spine {
-	internal class Triangulator {
+	public class Triangulator {
 		private readonly ExposedList<ExposedList<float>> convexPolygons = new ExposedList<ExposedList<float>>();
 		private readonly ExposedList<ExposedList<int>> convexPolygonsIndices = new ExposedList<ExposedList<int>>();
 

+ 2 - 0
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java

@@ -175,6 +175,8 @@ public class SkeletonBinary {
 			if (skeletonData.hash.isEmpty()) skeletonData.hash = null;
 			skeletonData.version = input.readString();
 			if (skeletonData.version.isEmpty()) skeletonData.version = null;
+			skeletonData.x = input.readFloat();
+			skeletonData.y = input.readFloat();
 			skeletonData.width = input.readFloat();
 			skeletonData.height = input.readFloat();
 

+ 19 - 1
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonData.java

@@ -47,7 +47,7 @@ public class SkeletonData {
 	final Array<IkConstraintData> ikConstraints = new Array();
 	final Array<TransformConstraintData> transformConstraints = new Array();
 	final Array<PathConstraintData> pathConstraints = new Array();
-	float width, height;
+	float x, y, width, height;
 	String version, hash;
 
 	// Nonessential.
@@ -234,6 +234,24 @@ public class SkeletonData {
 		this.name = name;
 	}
 
+	/** The X coordinate of the skeleton's axis aligned bounding box in the setup pose. */
+	public float getX () {
+		return x;
+	}
+
+	public void setX (float x) {
+		this.x = x;
+	}
+
+	/** The Y coordinate of the skeleton's axis aligned bounding box in the setup pose. */
+	public float getY () {
+		return y;
+	}
+
+	public void setY (float y) {
+		this.y = y;
+	}
+
 	/** The width of the skeleton's axis aligned bounding box in the setup pose. */
 	public float getWidth () {
 		return width;

+ 2 - 0
spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java

@@ -122,6 +122,8 @@ public class SkeletonJson {
 		if (skeletonMap != null) {
 			skeletonData.hash = skeletonMap.getString("hash", null);
 			skeletonData.version = skeletonMap.getString("spine", null);
+			skeletonData.x = skeletonMap.getFloat("x", 0);
+			skeletonData.y = skeletonMap.getFloat("y", 0);
 			skeletonData.width = skeletonMap.getFloat("width", 0);
 			skeletonData.height = skeletonMap.getFloat("height", 0);
 			skeletonData.fps = skeletonMap.getFloat("fps", 30);

+ 7 - 6
spine-monogame/example/ExampleGame.cs

@@ -65,9 +65,9 @@ namespace Spine {
 
 			// String name = "spineboy-ess";
 			// String name = "goblins-pro";
-			// String name = "raptor-pro";
+			String name = "raptor-pro";
 			// String name = "tank-pro";
-			String name = "coin-pro";
+			// String name = "coin-pro";
 			String atlasName = name.Replace("-pro", "").Replace("-ess", "");
 			bool binaryData = false;
 
@@ -109,17 +109,17 @@ namespace Spine {
 				state.Complete += Complete;
 				state.Event += Event;
 
-				state.SetAnimation(0, "test", false);
+				state.SetAnimation(0, "run", false);
 				TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
 				entry.End += End; // Event handling for queued animations.
 				state.AddAnimation(0, "run", true, 0);
 			}
 			else if (name == "raptor-pro") {
 				state.SetAnimation(0, "walk", true);
-				state.AddAnimation(1, "gungrab", false, 2);
+				state.AddAnimation(1, "gun-grab", false, 2);
 			}
 			else if (name == "coin-pro") {
-				state.SetAnimation(0, "rotate", true);
+				state.SetAnimation(0, "animation", true);
 			}
 			else if (name == "tank-pro") {
 				state.SetAnimation(0, "drive", true);
@@ -127,9 +127,10 @@ namespace Spine {
 			else {
 				state.SetAnimation(0, "walk", true);
 			}
-
+           
 			skeleton.X = 400 + (name == "tank-pro" ? 300 : 0);
 			skeleton.Y = GraphicsDevice.Viewport.Height;
+            skeleton.ScaleY = -1;
 			skeleton.UpdateWorldTransform();
 
 			headSlot = skeleton.FindSlot("head");

+ 9 - 0
spine-monogame/example/spine-monogame-example.csproj

@@ -42,6 +42,15 @@
     <ApplicationManifest>app.manifest</ApplicationManifest>
   </PropertyGroup>
   <ItemGroup>
+    <Compile Include="..\..\spine-xna\src\ShapeRenderer.cs">
+      <Link>spine-xna\ShapeRenderer.cs</Link>
+    </Compile>
+    <Compile Include="..\..\spine-xna\src\SkeletonDebugRenderer.cs">
+      <Link>spine-xna\SkeletonDebugRenderer.cs</Link>
+    </Compile>
+    <Compile Include="..\..\spine-xna\src\VertexEffect.cs">
+      <Link>spine-xna\VertexEffect.cs</Link>
+    </Compile>    
     <Compile Include="..\..\spine-xna\src\MeshBatcher.cs">
       <Link>spine-xna\MeshBatcher.cs</Link>
     </Compile>

+ 11 - 12
spine-ue4/Config/DefaultEngine.ini

@@ -7,9 +7,15 @@ DefaultGraphicsPerformance=Maximum
 AppliedDefaultGraphicsPerformance=Maximum
 
 [/Script/EngineSettings.GameMapsSettings]
-GameDefaultMap=/Game/Test/Test.Test
+GameDefaultMap=/Game/Test/NewWorld.NewWorld
 GlobalDefaultGameMode=/Game/Test/Blueprints/TouchClick.TouchClick_C
 
+[/Script/IOSRuntimeSettings.IOSRuntimeSettings]
+bSupportsPortraitOrientation=False
+bSupportsUpsideDownOrientation=False
+bSupportsLandscapeLeftOrientation=True
+PreferredLandscapeOrientation=LandscapeLeft
+
 [/Script/Engine.PhysicsSettings]
 DefaultGravityZ=-980.000000
 DefaultTerminalVelocity=4000.000000
@@ -17,12 +23,12 @@ DefaultFluidFriction=0.300000
 SimulateScratchMemorySize=262144
 RagdollAggregateThreshold=4
 TriangleMeshTriangleMinAreaThreshold=5.000000
-bEnableAsyncScene=False
 bEnableShapeSharing=False
 bEnablePCM=True
 bEnableStabilization=False
 bWarnMissingLocks=True
 bEnable2DPhysics=False
+PhysicErrorCorrection=(PingExtrapolation=0.100000,PingLimit=100.000000,ErrorPerLinearDifference=1.000000,ErrorPerAngularDifference=1.000000,MaxRestoredStateError=1.000000,MaxLinearHardSnapDistance=400.000000,PositionLerp=0.000000,AngleLerp=0.400000,LinearVelocityCoefficient=100.000000,AngularVelocityCoefficient=10.000000,ErrorAccumulationSeconds=0.500000,ErrorAccumulationDistanceSq=15.000000,ErrorAccumulationSimilarity=100.000000)
 LockedAxis=Invalid
 DefaultDegreesOfFreedom=Full3D
 BounceThresholdVelocity=200.000000
@@ -39,6 +45,8 @@ bDefaultHasComplexCollision=True
 bSuppressFaceRemapTable=False
 bSupportUVFromHitResults=False
 bDisableActiveActors=False
+bDisableKinematicStaticPairs=False
+bDisableKinematicKinematicPairs=False
 bDisableCCD=False
 bEnableEnhancedDeterminism=False
 MaxPhysicsDeltaTime=0.033333
@@ -47,16 +55,7 @@ bSubsteppingAsync=False
 MaxSubstepDeltaTime=0.016667
 MaxSubsteps=6
 SyncSceneSmoothingFactor=0.000000
-AsyncSceneSmoothingFactor=0.990000
 InitialAverageFrameRate=0.016667
 PhysXTreeRebuildRate=10
-
-
-
-
-[/Script/IOSRuntimeSettings.IOSRuntimeSettings]
-bSupportsPortraitOrientation=False
-bSupportsUpsideDownOrientation=False
-bSupportsLandscapeLeftOrientation=True
-PreferredLandscapeOrientation=LandscapeLeft
+DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)
 

BIN
spine-ue4/Content/Test/NewWorld.umap


BIN
spine-ue4/Content/Test/raptor-widget.uasset


BIN
spine-ue4/Content/Test/widget.uasset


+ 1 - 1
spine-ue4/Plugins/SpinePlugin/Source/SpineEditorPlugin/Private/SpineEditorPlugin.cpp

@@ -37,7 +37,7 @@ class FSpineEditorPlugin: public ISpineEditorPlugin {
 	virtual void ShutdownModule() override;
 };
 
-IMPLEMENT_MODULE(FSpineEditorPlugin, ISpineEditorPlugin)
+IMPLEMENT_MODULE(FSpineEditorPlugin, SpineEditorPlugin)
 
 void FSpineEditorPlugin::StartupModule () {
 }

+ 14 - 28
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SSpineWidget.cpp

@@ -51,6 +51,13 @@ void SSpineWidget::Construct(const FArguments& args) {
 
 void SSpineWidget::SetData(USpineWidget* Widget) {
 	this->widget = Widget;
+	if (widget && widget->skeleton && widget->Atlas) {
+		Skeleton *skeleton = widget->skeleton;
+		skeleton->setToSetupPose();
+		skeleton->updateWorldTransform();
+		Vector<float> scratchBuffer;
+		skeleton->getBounds(this->boundsMin.X, this->boundsMin.Y, this->boundsSize.X, this->boundsSize.Y, scratchBuffer);
+	}
 }
 
 static void setVertex(FSlateVertex* vertex, float x, float y, float u, float v, const FColor& color, const FVector2D& offset) {
@@ -163,6 +170,12 @@ int32 SSpineWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeo
 void SSpineWidget::Flush(int32 LayerId, FSlateWindowElementList& OutDrawElements, const FGeometry& AllottedGeometry, int &Idx, TArray<FVector> &Vertices, TArray<int32> &Indices, TArray<FVector2D> &Uvs, TArray<FColor> &Colors, TArray<FVector>& Colors2, UMaterialInstanceDynamic* Material) {
 	if (Vertices.Num() == 0) return;
 	SSpineWidget* self = (SSpineWidget*)this;
+
+	const FVector2D widgetSize = AllottedGeometry.GetDrawSize();
+	const float setupScale = (widgetSize / FVector2D(boundsSize.X, boundsSize.Y)).GetMin();
+	for (int i = 0; i < Vertices.Num(); i++) {
+		Vertices[i] = (Vertices[i] - FVector(boundsMin.X, -(boundsMin.Y + boundsSize.Y), 0)) * setupScale * widget->Scale;
+	}
 	
 	self->renderData.IndexData.SetNumUninitialized(Indices.Num());
 	uint32* indexData = (uint32*)renderData.IndexData.GetData();
@@ -293,18 +306,6 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
 		}
 
 		if (lastMaterial != material) {
-			FBox VerticeBounds = FBox();
-			for (int i = 0; i < vertices.Num(); i++) {
-				VerticeBounds += vertices[i];
-			}
-			const FVector2D DrawSize = AllottedGeometry.GetDrawSize();
-			const FVector BoundMin = VerticeBounds.Min;
-			const FVector BoundSize = VerticeBounds.GetSize();
-			const float Scale = (DrawSize / FVector2D(BoundSize.X, BoundSize.Y)).GetMin();
-
-			for (int i = 0; i < vertices.Num(); i++) {
-				vertices[i] = (vertices[i] - BoundMin) * Scale;
-			}
 			Flush(LayerId, OutDrawElements, AllottedGeometry, meshSection, vertices, indices, uvs, colors, darkColors, lastMaterial);
 			lastMaterial = material;
 			idx = 0;
@@ -335,22 +336,7 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
 
 		clipper.clipEnd(*slot);		
 	}
-
-	FBox VerticeBounds = FBox();
-	for (int i = 0; i < vertices.Num(); i++)
-	{
-		VerticeBounds += vertices[i];
-	}
-	const FVector2D DrawSize = AllottedGeometry.GetDrawSize();
-	const FVector BoundMin = VerticeBounds.Min;
-	const FVector BoundSize = VerticeBounds.GetSize();
-	const float Scale = (DrawSize / FVector2D(BoundSize.X, BoundSize.Y)).GetMin();
-
-	for (int i = 0; i < vertices.Num(); i++)
-	{
-		vertices[i] = (vertices[i] - BoundMin)*Scale;
-	}
-
+	
 	Flush(LayerId, OutDrawElements, AllottedGeometry, meshSection, vertices, indices, uvs, colors, darkColors, lastMaterial);
 	clipper.clipEnd();
 }

+ 46 - 7
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp

@@ -38,7 +38,41 @@
 
 using namespace spine;
 
-void callback(AnimationState* state, spine::EventType type, TrackEntry* entry, Event* event);
+void callbackWidget(AnimationState* state, spine::EventType type, TrackEntry* entry, Event* event) {
+	USpineWidget* component = (USpineWidget*)state->getRendererObject();
+
+	if (entry->getRendererObject()) {
+		UTrackEntry* uEntry = (UTrackEntry*)entry->getRendererObject();
+		if (type == EventType_Start) {
+			component->AnimationStart.Broadcast(uEntry);
+			uEntry->AnimationStart.Broadcast(uEntry);
+		}
+		else if (type == EventType_Interrupt) {
+			component->AnimationInterrupt.Broadcast(uEntry);
+			uEntry->AnimationInterrupt.Broadcast(uEntry);
+		}
+		else if (type == EventType_Event) {
+			FSpineEvent evt;
+			evt.SetEvent(event);
+			component->AnimationEvent.Broadcast(uEntry, evt);
+			uEntry->AnimationEvent.Broadcast(uEntry, evt);
+		}
+		else if (type == EventType_Complete) {
+			component->AnimationComplete.Broadcast(uEntry);
+			uEntry->AnimationComplete.Broadcast(uEntry);
+		}
+		else if (type == EventType_End) {
+			component->AnimationEnd.Broadcast(uEntry);
+			uEntry->AnimationEnd.Broadcast(uEntry);
+		}
+		else if (type == EventType_Dispose) {
+			component->AnimationDispose.Broadcast(uEntry);
+			uEntry->AnimationDispose.Broadcast(uEntry);
+			uEntry->SetTrackEntry(nullptr);
+			component->GCTrackEntry(uEntry);
+		}
+	}
+}
 
 USpineWidget::USpineWidget(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer) {
 	static ConstructorHelpers::FObjectFinder<UMaterialInterface> NormalMaterialRef(TEXT("/SpinePlugin/UI_SpineUnlitNormalMaterial"));
@@ -130,7 +164,7 @@ void USpineWidget::CheckState() {
 				AnimationStateData* stateData = SkeletonData->GetAnimationStateData(Atlas->GetAtlas());
 				state = new (__FILE__, __LINE__) AnimationState(stateData);
 				state->setRendererObject((void*)this);
-				state->setListener(callback);
+				state->setListener(callbackWidget);
 				trackEntries.Empty();
 			}
 		}
@@ -355,7 +389,8 @@ UTrackEntry* USpineWidget::SetAnimation(int trackIndex, FString animationName, b
 		trackEntries.Add(uEntry);
 		return uEntry;
 	}
-	else return NewObject<UTrackEntry>();
+	else
+		return NewObject<UTrackEntry>();
 
 }
 
@@ -370,7 +405,8 @@ UTrackEntry* USpineWidget::AddAnimation(int trackIndex, FString animationName, b
 		trackEntries.Add(uEntry);
 		return uEntry;
 	}
-	else return NewObject<UTrackEntry>();
+	else
+		return NewObject<UTrackEntry>();
 }
 
 UTrackEntry* USpineWidget::SetEmptyAnimation(int trackIndex, float mixDuration) {
@@ -382,7 +418,8 @@ UTrackEntry* USpineWidget::SetEmptyAnimation(int trackIndex, float mixDuration)
 		trackEntries.Add(uEntry);
 		return uEntry;
 	}
-	else return NewObject<UTrackEntry>();
+	else
+		return NewObject<UTrackEntry>();
 }
 
 UTrackEntry* USpineWidget::AddEmptyAnimation(int trackIndex, float mixDuration, float delay) {
@@ -394,7 +431,8 @@ UTrackEntry* USpineWidget::AddEmptyAnimation(int trackIndex, float mixDuration,
 		trackEntries.Add(uEntry);
 		return uEntry;
 	}
-	else return NewObject<UTrackEntry>();
+	else
+		return NewObject<UTrackEntry>();
 }
 
 UTrackEntry* USpineWidget::GetCurrent(int trackIndex) {
@@ -411,7 +449,8 @@ UTrackEntry* USpineWidget::GetCurrent(int trackIndex) {
 			return uEntry;
 		}
 	}
-	else return NewObject<UTrackEntry>();
+	else
+		return NewObject<UTrackEntry>();
 }
 
 void USpineWidget::ClearTracks() {

+ 3 - 2
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SSpineWidget.h

@@ -55,7 +55,8 @@ protected:
 
 	void Flush(int32 LayerId, FSlateWindowElementList& OutDrawElements, const FGeometry& AllottedGeometry, int &Idx, TArray<FVector> &Vertices, TArray<int32> &Indices, TArray<FVector2D> &Uvs, TArray<FColor> &Colors, TArray<FVector> &Colors2, UMaterialInstanceDynamic* Material);
 
-	USpineWidget* widget;
-	
+	USpineWidget* widget;	
 	FRenderData renderData;
+	FVector boundsMin;
+	FVector boundsSize;
 };

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

@@ -52,6 +52,8 @@ 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;

+ 1 - 1
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/SpinePlugin.Build.cs

@@ -15,7 +15,7 @@ namespace UnrealBuildTool.Rules
 			PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "Private"));
 			PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "Public/spine-cpp/include"));
 
-            PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "RHI", "RenderCore", "ShaderCore", "ProceduralMeshComponent", "UMG", "Slate", "SlateCore" });
+            PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "ProceduralMeshComponent", "UMG", "Slate", "SlateCore" });
 			PublicDefinitions.Add("SPINE_UE4");
 		}
 	}

+ 1 - 1
spine-ue4/SpineUE4.uproject

@@ -1,6 +1,6 @@
 {
 	"FileVersion": 3,
-	"EngineAssociation": "4.21",
+	"EngineAssociation": "4.22",
 	"Category": "",
 	"Description": "",
 	"Modules": [

+ 0 - 0
spine-xna/example/data/goblins-mesh.atlas → spine-xna/example/data/goblins.atlas