mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ue4] Generated normals are now correctly being flipped at back-faces. Closes #1830.
This commit is contained in:
parent
a088270186
commit
9032040503
@ -332,14 +332,25 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
|
|||||||
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(verticesPtr[j], depthOffset, verticesPtr[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]));
|
uvs.Add(FVector2D(attachmentUvs[j], attachmentUvs[j + 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int firstIndex = indices.Num();
|
||||||
for (int j = 0; j < numIndices; j++) {
|
for (int j = 0; j < numIndices; j++) {
|
||||||
indices.Add(idx + attachmentIndices[j]);
|
indices.Add(idx + attachmentIndices[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FVector normal = FVector(0, -1, 0);
|
||||||
|
if (numVertices > 2 &&
|
||||||
|
FVector::CrossProduct(
|
||||||
|
vertices[indices[firstIndex + 2]] - vertices[indices[firstIndex]],
|
||||||
|
vertices[indices[firstIndex + 1]] - vertices[indices[firstIndex]]).Y > 0.f) {
|
||||||
|
normal.Y = 1;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < numVertices; j++) {
|
||||||
|
normals.Add(normal);
|
||||||
|
}
|
||||||
|
|
||||||
idx += numVertices;
|
idx += numVertices;
|
||||||
depthOffset += this->DepthOffset;
|
depthOffset += this->DepthOffset;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user