Added checks to prevent rendering before component initilization for instance semantic segmentation.
This commit is contained in:
parent
c96370193b
commit
1afce0ee55
|
@ -2,6 +2,7 @@
|
|||
#include "TaggedComponent.h"
|
||||
|
||||
#include "Rendering/SkeletalMeshRenderData.h"
|
||||
#include "SkeletalRenderPublic.h"
|
||||
|
||||
//
|
||||
// UTaggedComponent
|
||||
|
@ -125,30 +126,29 @@ FPrimitiveSceneProxy * UTaggedComponent::CreateSceneProxy(UStaticMeshComponent *
|
|||
|
||||
FPrimitiveSceneProxy * UTaggedComponent::CreateSceneProxy(USkeletalMeshComponent * SkeletalMeshComponent)
|
||||
{
|
||||
|
||||
FSkeletalMeshRenderData * SkeletalMeshRenderData = SkeletalMeshComponent->GetSkeletalMeshRenderData();
|
||||
if (bShouldWaitFrame)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
ERHIFeatureLevel::Type SceneFeatureLevel = GetWorld()->FeatureLevel;
|
||||
FSkeletalMeshRenderData* SkelMeshRenderData = SkeletalMeshComponent->GetSkeletalMeshRenderData();
|
||||
|
||||
// Only create a scene proxy for rendering if properly initialized
|
||||
if (SkeletalMeshRenderData == NULL)
|
||||
if (SkelMeshRenderData &&
|
||||
SkelMeshRenderData->LODRenderData.IsValidIndex(SkeletalMeshComponent->PredictedLODLevel) &&
|
||||
!SkeletalMeshComponent->bHideSkin &&
|
||||
SkeletalMeshComponent->MeshObject)
|
||||
{
|
||||
UE_LOG(LogCarla, Error, TEXT("Failed to create scene proxy for skeletal mesh component: %s"), *SkeletalMeshComponent->GetReadableName());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SkeletalMeshRenderData->LODRenderData.IsValidIndex(SkeletalMeshComponent->PredictedLODLevel) == false)
|
||||
// Only create a scene proxy if the bone count being used is supported, or if we don't have a skeleton (this is the case with destructibles)
|
||||
int32 MinLODIndex = SkeletalMeshComponent->ComputeMinLOD();
|
||||
int32 MaxBonesPerChunk = SkelMeshRenderData->GetMaxBonesPerSection(MinLODIndex);
|
||||
int32 MaxSupportedNumBones = SkeletalMeshComponent->MeshObject->IsCPUSkinned() ? MAX_int32 : GetFeatureLevelMaxNumberOfBones(SceneFeatureLevel);
|
||||
if (MaxBonesPerChunk <= MaxSupportedNumBones)
|
||||
{
|
||||
UE_LOG(LogCarla, Error, TEXT("Failed to create scene proxy for skeletal mesh component: %s"), *SkeletalMeshComponent->GetReadableName());
|
||||
return NULL;
|
||||
return new FTaggedSkeletalMeshSceneProxy(SkeletalMeshComponent, SkelMeshRenderData, TaggedMID);
|
||||
}
|
||||
|
||||
if (SkeletalMeshComponent->MeshObject == NULL)
|
||||
{
|
||||
UE_LOG(LogCarla, Error, TEXT("Failed to create scene proxy for skeletal mesh component: %s"), *SkeletalMeshComponent->GetReadableName());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FIXME: How does this allocation get freed?
|
||||
return new FTaggedSkeletalMeshSceneProxy(SkeletalMeshComponent, SkeletalMeshRenderData, TaggedMID);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FPrimitiveSceneProxy * UTaggedComponent::CreateSceneProxy(UHierarchicalInstancedStaticMeshComponent * MeshComponent)
|
||||
|
@ -199,7 +199,16 @@ void UTaggedComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActo
|
|||
// // TODO: Try removing this
|
||||
if (bSkeletalMesh)
|
||||
{
|
||||
// MarkRenderTransformDirty();
|
||||
MarkRenderStateDirty();
|
||||
if(bShouldWaitFrame)
|
||||
{
|
||||
if(NumFramesToWait < 0)
|
||||
{
|
||||
bShouldWaitFrame = false;
|
||||
}
|
||||
NumFramesToWait--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +234,7 @@ FPrimitiveViewRelevance FTaggedStaticMeshSceneProxy::GetViewRelevance(const FSce
|
|||
{
|
||||
FPrimitiveViewRelevance ViewRelevance = FStaticMeshSceneProxy::GetViewRelevance(View);
|
||||
|
||||
ViewRelevance.bDrawRelevance = !View->Family->EngineShowFlags.NotDrawTaggedComponents;
|
||||
ViewRelevance.bDrawRelevance = ViewRelevance.bDrawRelevance && !View->Family->EngineShowFlags.NotDrawTaggedComponents;
|
||||
|
||||
return ViewRelevance;
|
||||
}
|
||||
|
@ -252,7 +261,7 @@ FPrimitiveViewRelevance FTaggedSkeletalMeshSceneProxy::GetViewRelevance(const FS
|
|||
{
|
||||
FPrimitiveViewRelevance ViewRelevance = FSkeletalMeshSceneProxy::GetViewRelevance(View);
|
||||
|
||||
ViewRelevance.bDrawRelevance = !View->Family->EngineShowFlags.NotDrawTaggedComponents;
|
||||
ViewRelevance.bDrawRelevance = ViewRelevance.bDrawRelevance && !View->Family->EngineShowFlags.NotDrawTaggedComponents;
|
||||
|
||||
return ViewRelevance;
|
||||
}
|
||||
|
@ -277,7 +286,7 @@ FPrimitiveViewRelevance FTaggedInstancedStaticMeshSceneProxy::GetViewRelevance(c
|
|||
{
|
||||
FPrimitiveViewRelevance ViewRelevance = FInstancedStaticMeshSceneProxy::GetViewRelevance(View);
|
||||
|
||||
ViewRelevance.bDrawRelevance = !View->Family->EngineShowFlags.NotDrawTaggedComponents;
|
||||
ViewRelevance.bDrawRelevance = ViewRelevance.bDrawRelevance && !View->Family->EngineShowFlags.NotDrawTaggedComponents;
|
||||
|
||||
return ViewRelevance;
|
||||
}
|
||||
|
@ -303,7 +312,7 @@ FPrimitiveViewRelevance FTaggedHierarchicalStaticMeshSceneProxy::GetViewRelevanc
|
|||
{
|
||||
FPrimitiveViewRelevance ViewRelevance = FHierarchicalStaticMeshSceneProxy::GetViewRelevance(View);
|
||||
|
||||
ViewRelevance.bDrawRelevance = !View->Family->EngineShowFlags.NotDrawTaggedComponents;
|
||||
ViewRelevance.bDrawRelevance = ViewRelevance.bDrawRelevance && !View->Family->EngineShowFlags.NotDrawTaggedComponents;
|
||||
|
||||
return ViewRelevance;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ private:
|
|||
FPrimitiveSceneProxy * CreateSceneProxy(USkeletalMeshComponent * SkeletalMeshComponent);
|
||||
FPrimitiveSceneProxy * CreateSceneProxy(UHierarchicalInstancedStaticMeshComponent * MeshComponent);
|
||||
FPrimitiveSceneProxy * CreateSceneProxy(UInstancedStaticMeshComponent * MeshComponent);
|
||||
|
||||
// small hack to allow unreal to initialize the base component in skeletal meshes
|
||||
bool bShouldWaitFrame = true;
|
||||
int NumFramesToWait = 2;
|
||||
};
|
||||
|
||||
class FTaggedStaticMeshSceneProxy : public FStaticMeshSceneProxy
|
||||
|
|
|
@ -104,10 +104,10 @@ void ATagger::TagActor(const AActor &Actor, bool bTagForSemanticSegmentation)
|
|||
UE_LOG(LogCarla, Log, TEXT(" - Label: \"%s\""), *GetTagAsString(Label));
|
||||
#endif // CARLA_TAGGER_EXTRA_LOG
|
||||
|
||||
// Don't instance segment non-things (i.e., stuff)
|
||||
// if (!IsThing(Label)) {
|
||||
// continue;
|
||||
// }
|
||||
if(!Component->IsVisible() || !Component->GetStaticMesh())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find a tagged component that is attached to this component
|
||||
UTaggedComponent *TaggedComponent = NULL;
|
||||
|
@ -154,10 +154,10 @@ void ATagger::TagActor(const AActor &Actor, bool bTagForSemanticSegmentation)
|
|||
UE_LOG(LogCarla, Log, TEXT(" - Label: \"%s\""), *GetTagAsString(Label));
|
||||
#endif // CARLA_TAGGER_EXTRA_LOG
|
||||
|
||||
// Don't instance segment non-things (i.e., stuff)
|
||||
// if (!IsThing(Label)) {
|
||||
// continue;
|
||||
// }
|
||||
if(!Component->IsVisible() || !Component->GetSkeletalMeshRenderData())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find a tagged component that is attached to this component
|
||||
UTaggedComponent *TaggedComponent = NULL;
|
||||
|
|
|
@ -33,44 +33,14 @@ void AInstanceSegmentationCamera::SetUpSceneCaptureComponent(USceneCaptureCompon
|
|||
ApplyViewMode(VMI_Unlit, true, SceneCapture.ShowFlags);
|
||||
|
||||
SceneCapture.ShowFlags.SetNotDrawTaggedComponents(false); // TaggedComponent detects this and sets view relevance for proxy material
|
||||
//SceneCapture.ShowFlags.SetDecals(false);
|
||||
//SceneCapture.ShowFlags.SetPostProcessing(false);
|
||||
//SceneCapture.ShowFlags.SetAmbientCubemap(false);
|
||||
//SceneCapture.ShowFlags.SetVignette(false);
|
||||
//SceneCapture.ShowFlags.SetRectLights(false);
|
||||
//SceneCapture.ShowFlags.SetToneCurve(false);
|
||||
//SceneCapture.ShowFlags.SetScreenPercentage(false);
|
||||
//SceneCapture.ShowFlags.SetReflectionEnvironment(false);
|
||||
//SceneCapture.ShowFlags.SetSpecular(false);
|
||||
//SceneCapture.ShowFlags.SetContactShadows(false);
|
||||
//SceneCapture.ShowFlags.SetRayTracedDistanceFieldShadows(false);
|
||||
//SceneCapture.ShowFlags.SetCapsuleShadows(false);
|
||||
//SceneCapture.ShowFlags.SetVolumetricLightmap(false);
|
||||
//SceneCapture.ShowFlags.SetIndirectLightingCache(false);
|
||||
//SceneCapture.ShowFlags.SetTexturedLightProfiles(false);
|
||||
//SceneCapture.ShowFlags.SetDeferredLighting(false);
|
||||
//SceneCapture.ShowFlags.SetTranslucency(false);
|
||||
//SceneCapture.ShowFlags.SetBillboardSprites(false);
|
||||
//SceneCapture.ShowFlags.SetBSPTriangles(false); // hmm
|
||||
//SceneCapture.ShowFlags.SetLandscape(false); // hmm
|
||||
//SceneCapture.ShowFlags.SetBSP(false); // hmm
|
||||
//SceneCapture.ShowFlags.SetPostProcessMaterial(false); // hmm
|
||||
SceneCapture.ShowFlags.SetAtmosphere(false);
|
||||
//SceneCapture.ShowFlags.SetPrecomputedVisibility(false);
|
||||
//SceneCapture.ShowFlags.SetPaper2DSprites(false);
|
||||
//SceneCapture.ShowFlags.SetDistanceFieldAO(false);
|
||||
//SceneCapture.ShowFlags.SetWidgetComponents(false);
|
||||
//SceneCapture.ShowFlags.SetMediaPlanes(false);
|
||||
|
||||
//SceneCapture.PostProcessSettings.AutoExposureBias = 0;
|
||||
SceneCapture.ShowFlags.SetAtmosphere(false);
|
||||
|
||||
SceneCapture.PrimitiveRenderMode = ESceneCapturePrimitiveRenderMode::PRM_UseShowOnlyList;
|
||||
|
||||
TArray<UObject *> TaggedComponents;
|
||||
GetObjectsOfClass(UTaggedComponent::StaticClass(), TaggedComponents, false, EObjectFlags::RF_ClassDefaultObject, EInternalObjectFlags::AllFlags);
|
||||
|
||||
UE_LOG(LogCarla, Warning, TEXT("AInstanceSegmentationCamera::SetUpSceneCaptureComponent with %d tagged components!"), TaggedComponents.Num());
|
||||
|
||||
TArray<UPrimitiveComponent *> ShowOnlyComponents;
|
||||
for (UObject *Object : TaggedComponents) {
|
||||
UPrimitiveComponent *Component = Cast<UPrimitiveComponent>(Object);
|
||||
|
@ -86,7 +56,6 @@ void AInstanceSegmentationCamera::PostPhysTick(UWorld *World, ELevelTick TickTyp
|
|||
TArray<UObject *> TaggedComponents;
|
||||
GetObjectsOfClass(UTaggedComponent::StaticClass(), TaggedComponents, false, EObjectFlags::RF_ClassDefaultObject, EInternalObjectFlags::AllFlags);
|
||||
|
||||
// UE_LOG(LogCarla, Warning, TEXT("AInstanceSegmentationCamera::SetUpSceneCaptureComponent with %d tagged components!"), TaggedComponents.Num());
|
||||
SceneCapture->ClearShowOnlyComponents();
|
||||
for (UObject *Object : TaggedComponents) {
|
||||
UPrimitiveComponent *Component = Cast<UPrimitiveComponent>(Object);
|
||||
|
|
Loading…
Reference in New Issue