mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-05 02:06:53 +08:00
Merge branch '3.7' of https://github.com/GitHub-NetFly/spine-runtimes into GitHub-NetFly-3.7
This commit is contained in:
commit
977d38c69f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -72,6 +72,10 @@ int32 SSpineWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeo
|
|||||||
|
|
||||||
SSpineWidget* self = (SSpineWidget*)this;
|
SSpineWidget* self = (SSpineWidget*)this;
|
||||||
|
|
||||||
|
//Begin Change
|
||||||
|
UMaterialInstanceDynamic* MatNow = nullptr;
|
||||||
|
// End Change
|
||||||
|
|
||||||
if (widget && widget->skeleton && widget->Atlas) {
|
if (widget && widget->skeleton && widget->Atlas) {
|
||||||
widget->skeleton->getColor().set(widget->Color.R, widget->Color.G, widget->Color.B, widget->Color.A);
|
widget->skeleton->getColor().set(widget->Color.R, widget->Color.G, widget->Color.B, widget->Color.A);
|
||||||
|
|
||||||
@ -153,10 +157,10 @@ int32 SSpineWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeo
|
|||||||
widget->pageToScreenBlendMaterial.Add(currPage, widget->atlasScreenBlendMaterials[i]);
|
widget->pageToScreenBlendMaterial.Add(currPage, widget->atlasScreenBlendMaterials[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// self->UpdateMesh(LayerId, OutDrawElements, AllottedGeometry, widget->skeleton);
|
self->UpdateMesh(LayerId, OutDrawElements, AllottedGeometry, widget->skeleton);
|
||||||
}
|
}
|
||||||
//return LayerId;
|
|
||||||
|
/*
|
||||||
self->renderData.IndexData.SetNumUninitialized(6);
|
self->renderData.IndexData.SetNumUninitialized(6);
|
||||||
uint32* indexData = (uint32*)renderData.IndexData.GetData();
|
uint32* indexData = (uint32*)renderData.IndexData.GetData();
|
||||||
indexData[0] = 0;
|
indexData[0] = 0;
|
||||||
@ -178,12 +182,16 @@ int32 SSpineWidget::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeo
|
|||||||
setVertex(&vertexData[1], width, 0, 1, 0, white, offset);
|
setVertex(&vertexData[1], width, 0, 1, 0, white, offset);
|
||||||
setVertex(&vertexData[2], width, height, 1, 1, white, offset);
|
setVertex(&vertexData[2], width, height, 1, 1, white, offset);
|
||||||
setVertex(&vertexData[3], 0, height, 0, 1, white, offset);
|
setVertex(&vertexData[3], 0, height, 0, 1, white, offset);
|
||||||
|
*/
|
||||||
if (brush && renderData.VertexData.Num() > 0 && renderData.IndexData.Num() > 0) {
|
if (renderData.VertexData.Num() > 0 && renderData.IndexData.Num() > 0) {
|
||||||
|
/*
|
||||||
FSlateShaderResourceProxy* shaderResource = FSlateDataPayload::ResourceManager->GetShaderResource(widget->Brush);
|
FSlateShaderResourceProxy* shaderResource = FSlateDataPayload::ResourceManager->GetShaderResource(widget->Brush);
|
||||||
FSlateResourceHandle resourceHandle = FSlateApplication::Get().GetRenderer()->GetResourceHandle(widget->Brush);
|
FSlateResourceHandle resourceHandle = FSlateApplication::Get().GetRenderer()->GetResourceHandle(widget->Brush);
|
||||||
if (shaderResource)
|
*/
|
||||||
FSlateDrawElement::MakeCustomVerts(OutDrawElements, LayerId, resourceHandle, renderData.VertexData,
|
//renderData.Brush = MakeShareable(new FSlateMaterialBrush(*MaterialFromMesh, FVector2D(64,64)));
|
||||||
|
|
||||||
|
if (renderData.RenderingResourceHandle.IsValid())
|
||||||
|
FSlateDrawElement::MakeCustomVerts(OutDrawElements, LayerId, renderData.RenderingResourceHandle, renderData.VertexData,
|
||||||
renderData.IndexData, nullptr, 0, 0);
|
renderData.IndexData, nullptr, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +217,26 @@ void SSpineWidget::Flush(int32 LayerId, FSlateWindowElementList& OutDrawElements
|
|||||||
for (size_t i = 0; i < (size_t)Vertices.Num(); i++) {
|
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], Vertices[i].X, Vertices[i].Y, Uvs[i].X, Uvs[i].Y, Colors[i], offset);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
|
||||||
|
*/
|
||||||
|
brush = &widget->Brush;
|
||||||
|
//Begin change
|
||||||
|
if (Material)
|
||||||
|
{
|
||||||
|
renderData.Brush = MakeShareable(new FSlateMaterialBrush(*Material, FVector2D(64, 64)));
|
||||||
|
renderData.RenderingResourceHandle = FSlateApplication::Get().GetRenderer()->GetResourceHandle(*renderData.Brush);
|
||||||
|
//renderData.Brush = MakeShareable(&widget->Brush);
|
||||||
|
|
||||||
|
//renderData.Brush = MakeShareable(new FSlateMaterialBrush(*Material, widget->Brush));
|
||||||
|
//renderData.RenderingResourceHandle = FSlateApplication::Get().GetRenderer()->GetResourceHandle(*brush);
|
||||||
|
}
|
||||||
|
// End change
|
||||||
|
|
||||||
|
if (renderData.RenderingResourceHandle.IsValid()) {
|
||||||
|
FSlateDrawElement::MakeCustomVerts(OutDrawElements, LayerId, renderData.RenderingResourceHandle, renderData.VertexData, renderData.IndexData, nullptr, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*FSlateBrush brush;
|
/*FSlateBrush brush;
|
||||||
brush.SetResourceObject(Material);
|
brush.SetResourceObject(Material);
|
||||||
@ -311,7 +339,7 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
|
|||||||
if (!widget->pageToNormalBlendMaterial.Contains(attachmentAtlasRegion->page)) continue;
|
if (!widget->pageToNormalBlendMaterial.Contains(attachmentAtlasRegion->page)) continue;
|
||||||
material = widget->pageToNormalBlendMaterial[attachmentAtlasRegion->page];
|
material = widget->pageToNormalBlendMaterial[attachmentAtlasRegion->page];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clipper.isClipping()) {
|
if (clipper.isClipping()) {
|
||||||
clipper.clipTriangles(attachmentVertices.buffer(), attachmentIndices, numIndices, attachmentUvs, 2);
|
clipper.clipTriangles(attachmentVertices.buffer(), attachmentIndices, numIndices, attachmentUvs, 2);
|
||||||
attachmentVertices = clipper.getClippedVertices();
|
attachmentVertices = clipper.getClippedVertices();
|
||||||
@ -323,7 +351,7 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastMaterial != material) {
|
if (lastMaterial != material) {
|
||||||
Flush(LayerId, OutDrawElements, AllottedGeometry, meshSection, vertices, indices, uvs, colors, darkColors, lastMaterial);
|
|
||||||
lastMaterial = material;
|
lastMaterial = material;
|
||||||
idx = 0;
|
idx = 0;
|
||||||
}
|
}
|
||||||
@ -340,7 +368,8 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
|
|||||||
for (int j = 0; j < numVertices << 1; j += 2) {
|
for (int j = 0; j < numVertices << 1; j += 2) {
|
||||||
colors.Add(FColor(r, g, b, a));
|
colors.Add(FColor(r, g, b, a));
|
||||||
darkColors.Add(FVector(dr, dg, db));
|
darkColors.Add(FVector(dr, dg, db));
|
||||||
vertices.Add(FVector(attachmentVertices[j], depthOffset, attachmentVertices[j + 1]));
|
//vertices.Add(FVector(attachmentVertices[j], depthOffset, attachmentVertices[j + 1]));
|
||||||
|
vertices.Add(FVector(attachmentVertices[j], -attachmentVertices[j + 1], depthOffset));
|
||||||
uvs.Add(FVector2D(attachmentUvs[j], attachmentUvs[j + 1]));
|
uvs.Add(FVector2D(attachmentUvs[j], attachmentUvs[j + 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,6 +381,23 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
|
|||||||
depthOffset += widget->DepthOffset;
|
depthOffset += widget->DepthOffset;
|
||||||
|
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
|
|
||||||
|
//Flush(LayerId, OutDrawElements, AllottedGeometry, meshSection, vertices, indices, uvs, colors, darkColors, lastMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
Flush(LayerId, OutDrawElements, AllottedGeometry, meshSection, vertices, indices, uvs, colors, darkColors, lastMaterial);
|
||||||
|
|||||||
@ -36,16 +36,16 @@
|
|||||||
#define LOCTEXT_NAMESPACE "Spine"
|
#define LOCTEXT_NAMESPACE "Spine"
|
||||||
|
|
||||||
USpineWidget::USpineWidget(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer) {
|
USpineWidget::USpineWidget(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer) {
|
||||||
static ConstructorHelpers::FObjectFinder<UMaterialInterface> NormalMaterialRef(TEXT("/SpinePlugin/SpineUnlitNormalMaterial"));
|
static ConstructorHelpers::FObjectFinder<UMaterialInterface> NormalMaterialRef(TEXT("/SpinePlugin/UI_SpineUnlitNormalMaterial"));
|
||||||
NormalBlendMaterial = NormalMaterialRef.Object;
|
NormalBlendMaterial = NormalMaterialRef.Object;
|
||||||
|
|
||||||
static ConstructorHelpers::FObjectFinder<UMaterialInterface> AdditiveMaterialRef(TEXT("/SpinePlugin/SpineUnlitAdditiveMaterial"));
|
static ConstructorHelpers::FObjectFinder<UMaterialInterface> AdditiveMaterialRef(TEXT("/SpinePlugin/UI_SpineUnlitAdditiveMaterial"));
|
||||||
AdditiveBlendMaterial = AdditiveMaterialRef.Object;
|
AdditiveBlendMaterial = AdditiveMaterialRef.Object;
|
||||||
|
|
||||||
static ConstructorHelpers::FObjectFinder<UMaterialInterface> MultiplyMaterialRef(TEXT("/SpinePlugin/SpineUnlitMultiplyMaterial"));
|
static ConstructorHelpers::FObjectFinder<UMaterialInterface> MultiplyMaterialRef(TEXT("/SpinePlugin/UI_SpineUnlitMultiplyMaterial"));
|
||||||
MultiplyBlendMaterial = MultiplyMaterialRef.Object;
|
MultiplyBlendMaterial = MultiplyMaterialRef.Object;
|
||||||
|
|
||||||
static ConstructorHelpers::FObjectFinder<UMaterialInterface> ScreenMaterialRef(TEXT("/SpinePlugin/SpineUnlitScreenMaterial"));
|
static ConstructorHelpers::FObjectFinder<UMaterialInterface> ScreenMaterialRef(TEXT("/SpinePlugin/UI_SpineUnlitScreenMaterial"));
|
||||||
ScreenBlendMaterial = ScreenMaterialRef.Object;
|
ScreenBlendMaterial = ScreenMaterialRef.Object;
|
||||||
|
|
||||||
TextureParameterName = FName(TEXT("SpriteTexture"));
|
TextureParameterName = FName(TEXT("SpriteTexture"));
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public:
|
|||||||
void Construct(const FArguments& Args);
|
void Construct(const FArguments& Args);
|
||||||
|
|
||||||
void SetData(USpineWidget* Widget);
|
void SetData(USpineWidget* Widget);
|
||||||
|
FSlateBrush* brush;
|
||||||
protected:
|
protected:
|
||||||
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
|
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
|
||||||
|
|
||||||
@ -56,6 +56,6 @@ 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);
|
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;
|
||||||
FSlateBrush* brush;
|
|
||||||
FRenderData renderData;
|
FRenderData renderData;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user