mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[ue4] Closes #1425, scratch buffer in renderer would eventually also turn into output buffer of clipper due to incorrect assignment of array.
This commit is contained in:
parent
083ef01160
commit
706c01de00
@ -230,7 +230,7 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
|
||||
unsigned short quadIndices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
|
||||
for (int i = 0; i < (int)Skeleton->getSlots().size(); ++i) {
|
||||
Vector<float> &attachmentVertices = worldVertices;
|
||||
Vector<float> *attachmentVertices = &worldVertices;
|
||||
unsigned short* attachmentIndices = nullptr;
|
||||
int numVertices;
|
||||
int numIndices;
|
||||
@ -250,7 +250,7 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
|
||||
RegionAttachment* regionAttachment = (RegionAttachment*)attachment;
|
||||
attachmentColor.set(regionAttachment->getColor());
|
||||
attachmentAtlasRegion = (AtlasRegion*)regionAttachment->getRendererObject();
|
||||
regionAttachment->computeWorldVertices(slot->getBone(), attachmentVertices, 0, 2);
|
||||
regionAttachment->computeWorldVertices(slot->getBone(), *attachmentVertices, 0, 2);
|
||||
attachmentIndices = quadIndices;
|
||||
attachmentUvs = regionAttachment->getUVs().buffer();
|
||||
numVertices = 4;
|
||||
@ -260,7 +260,7 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
|
||||
MeshAttachment* mesh = (MeshAttachment*)attachment;
|
||||
attachmentColor.set(mesh->getColor());
|
||||
attachmentAtlasRegion = (AtlasRegion*)mesh->getRendererObject();
|
||||
mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), attachmentVertices, 0, 2);
|
||||
mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), *attachmentVertices, 0, 2);
|
||||
attachmentIndices = mesh->getTriangles().buffer();
|
||||
attachmentUvs = mesh->getUVs().buffer();
|
||||
numVertices = mesh->getWorldVerticesLength() >> 1;
|
||||
@ -299,8 +299,8 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
|
||||
}
|
||||
|
||||
if (clipper.isClipping()) {
|
||||
clipper.clipTriangles(attachmentVertices.buffer(), attachmentIndices, numIndices, attachmentUvs, 2);
|
||||
attachmentVertices = clipper.getClippedVertices();
|
||||
clipper.clipTriangles(attachmentVertices->buffer(), attachmentIndices, numIndices, attachmentUvs, 2);
|
||||
attachmentVertices = &clipper.getClippedVertices();
|
||||
numVertices = clipper.getClippedVertices().size() >> 1;
|
||||
attachmentIndices = clipper.getClippedTriangles().buffer();
|
||||
numIndices = clipper.getClippedTriangles().size();
|
||||
@ -323,10 +323,11 @@ void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawEle
|
||||
float dg = slot->hasDarkColor() ? slot->getDarkColor().g : 0.0f;
|
||||
float db = slot->hasDarkColor() ? slot->getDarkColor().b : 0.0f;
|
||||
|
||||
float* verticesPtr = attachmentVertices->buffer();
|
||||
for (int j = 0; j < numVertices << 1; j += 2) {
|
||||
colors.Add(FColor(r, g, b, a));
|
||||
darkColors.Add(FVector(dr, dg, db));
|
||||
vertices.Add(FVector(attachmentVertices[j], -attachmentVertices[j + 1], depthOffset));
|
||||
vertices.Add(FVector(verticesPtr[j], -verticesPtr[j + 1], depthOffset));
|
||||
uvs.Add(FVector2D(attachmentUvs[j], attachmentUvs[j + 1]));
|
||||
}
|
||||
|
||||
|
||||
@ -206,7 +206,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
|
||||
unsigned short quadIndices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
|
||||
for (size_t i = 0; i < Skeleton->getSlots().size(); ++i) {
|
||||
Vector<float> &attachmentVertices = worldVertices;
|
||||
Vector<float> *attachmentVertices = &worldVertices;
|
||||
unsigned short* attachmentIndices = nullptr;
|
||||
int numVertices;
|
||||
int numIndices;
|
||||
@ -237,7 +237,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
|
||||
|
||||
attachmentColor.set(regionAttachment->getColor());
|
||||
attachmentAtlasRegion = (AtlasRegion*)regionAttachment->getRendererObject();
|
||||
regionAttachment->computeWorldVertices(slot->getBone(), attachmentVertices, 0, 2);
|
||||
regionAttachment->computeWorldVertices(slot->getBone(), *attachmentVertices, 0, 2);
|
||||
attachmentIndices = quadIndices;
|
||||
attachmentUvs = regionAttachment->getUVs().buffer();
|
||||
numVertices = 4;
|
||||
@ -253,7 +253,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
|
||||
|
||||
attachmentColor.set(mesh->getColor());
|
||||
attachmentAtlasRegion = (AtlasRegion*)mesh->getRendererObject();
|
||||
mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), attachmentVertices, 0, 2);
|
||||
mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), *attachmentVertices, 0, 2);
|
||||
attachmentIndices = mesh->getTriangles().buffer();
|
||||
attachmentUvs = mesh->getUVs().buffer();
|
||||
numVertices = mesh->getWorldVerticesLength() >> 1;
|
||||
@ -291,8 +291,8 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
|
||||
}
|
||||
|
||||
if (clipper.isClipping()) {
|
||||
clipper.clipTriangles(attachmentVertices.buffer(), attachmentIndices, numIndices, attachmentUvs, 2);
|
||||
attachmentVertices = clipper.getClippedVertices();
|
||||
clipper.clipTriangles(attachmentVertices->buffer(), attachmentIndices, numIndices, attachmentUvs, 2);
|
||||
attachmentVertices = &clipper.getClippedVertices();
|
||||
numVertices = clipper.getClippedVertices().size() >> 1;
|
||||
attachmentIndices = clipper.getClippedTriangles().buffer();
|
||||
numIndices = clipper.getClippedTriangles().size();
|
||||
@ -317,10 +317,11 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
|
||||
float dg = slot->hasDarkColor() ? slot->getDarkColor().g : 0.0f;
|
||||
float db = slot->hasDarkColor() ? slot->getDarkColor().b : 0.0f;
|
||||
|
||||
float* verticesPtr = attachmentVertices->buffer();
|
||||
for (int j = 0; j < numVertices << 1; j += 2) {
|
||||
colors.Add(FColor(r, g, b, a));
|
||||
darkColors.Add(FVector(dr, dg, db));
|
||||
vertices.Add(FVector(attachmentVertices[j], depthOffset, attachmentVertices[j + 1]));
|
||||
vertices.Add(FVector(verticesPtr[j], depthOffset, verticesPtr[j + 1]));
|
||||
normals.Add(FVector(0, -1, 0));
|
||||
uvs.Add(FVector2D(attachmentUvs[j], attachmentUvs[j + 1]));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user