[ue4] render component actually only renders first sub section. Bug in procedural mesh component?

This commit is contained in:
badlogic 2016-12-14 12:31:38 +01:00
parent 277920b7fa
commit 74850f67a3
8 changed files with 24 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -163,7 +163,25 @@ void USpineSkeletonRendererComponent::UpdateMesh(spSkeleton* Skeleton) {
if (attachment->type == SP_ATTACHMENT_REGION) {
spRegionAttachment* regionAttachment = (spRegionAttachment*)attachment;
spAtlasRegion* region = (spAtlasRegion*)regionAttachment->rendererObject;
UMaterialInstanceDynamic* material = pageToNormalBlendMaterial[region->page];
UMaterialInstanceDynamic* material = nullptr;
switch(slot->data->blendMode) {
case SP_BLEND_MODE_NORMAL:
material = pageToNormalBlendMaterial[region->page];
break;
/*case SP_BLEND_MODE_ADDITIVE:
material = pageToAdditiveBlendMaterial[region->page];
break;
case SP_BLEND_MODE_MULTIPLY:
material = pageToMultiplyBlendMaterial[region->page];
break;
case SP_BLEND_MODE_SCREEN:
material = pageToScreenBlendMaterial[region->page];
break;*/
default:
material = pageToNormalBlendMaterial[region->page];
}
if (lastMaterial != material) {
Flush(meshSection, vertices, indices, uvs, colors, lastMaterial);
@ -201,8 +219,6 @@ void USpineSkeletonRendererComponent::UpdateMesh(spSkeleton* Skeleton) {
indices.Add(idx + 3);
idx += 4;
depthOffset += this->DepthOffset;
SetMaterial(meshSection, material);
} else if (attachment->type == SP_ATTACHMENT_MESH) {
spMeshAttachment* mesh = (spMeshAttachment*)attachment;
spAtlasRegion* region = (spAtlasRegion*)mesh->rendererObject;

View File

@ -42,15 +42,20 @@ protected:
void Flush (int &Idx, TArray<FVector> &Vertices, TArray<int32> &Indices, TArray<FVector2D> &Uvs, TArray<FColor> &Colors, UMaterialInstanceDynamic* Material);
// Need to hold on to the dynamic instances, or the GC will kill us while updating them
UPROPERTY()
TArray<UMaterialInstanceDynamic*> atlasNormalBlendMaterials;
TMap<spAtlasPage*, UMaterialInstanceDynamic*> pageToNormalBlendMaterial;
UPROPERTY()
TArray<UMaterialInstanceDynamic*> atlasAdditiveBlendMaterials;
TMap<spAtlasPage*, UMaterialInstanceDynamic*> pageToAdditiveBlendMaterial;
UPROPERTY()
TArray<UMaterialInstanceDynamic*> atlasMultiplyBlendMaterials;
TMap<spAtlasPage*, UMaterialInstanceDynamic*> pageToMultiplyBlendMaterial;
UPROPERTY()
TArray<UMaterialInstanceDynamic*> atlasScreenBlendMaterials;
TMap<spAtlasPage*, UMaterialInstanceDynamic*> pageToScreenBlendMaterial;
};