Skip to main content
Sign in
Snippets Groups Projects
Select Git revision
  • 6324d85c16a219ed94a24fa212bfb2a7dd466119
  • master default protected
  • feature/refactor
  • 4.24
  • develop
  • Rendering
  • temp-optix-6
7 results

LineInstancedStaticMeshComponent.cpp

Blame
  • LineInstancedStaticMeshComponent.cpp 6.11 KiB
    // Fill out your copyright notice in the Description page of Project Settings.
    
    
    #include "LineInstancedStaticMeshComponent.h"
    
    #include "Components/InstancedStaticMeshComponent.h"
    #include "Runtime/Engine/Private/InstancedStaticMesh.h"
    #include "Runtime/Engine/Classes/Materials/MaterialInstanceDynamic.h"
    #include "UObject/ConstructorHelpers.h"
    
    #include "Runtime/Engine/Classes/Engine/Texture2D.h"
    
    
    #include "OptiXModule.h"
    #include "OptiXContextManager.h"
    
    
    ULineInstancedStaticMeshComponent::ULineInstancedStaticMeshComponent(const FObjectInitializer& ObjectInitializer)
    	: Super(ObjectInitializer)
    {
    
    	UE_LOG(LogTemp, Display, TEXT("ULineInstancedStaticMeshComponent Constructor"));
    
    
    	SetGenerateOverlapEvents(false);
    
    	static ConstructorHelpers::FObjectFinder<UStaticMesh>LineMeshAsset(TEXT("StaticMesh'/OptiX/Laser/cylinder.cylinder'"));
    	UStaticMesh* LineAsset = LineMeshAsset.Object;
    	SetStaticMesh(LineAsset);
    
    	SetRenderCustomDepth(true);
    	SetCastShadow(false);
    	SetCollisionEnabled(ECollisionEnabled::NoCollision);
    
    
    	SegmentsPerLine = 20;
    	LineNumber = 16;
    
    }
    
    void ULineInstancedStaticMeshComponent::BeginPlay()
    {
    	Super::BeginPlay();
    }
    
    FPrimitiveSceneProxy* ULineInstancedStaticMeshComponent::CreateSceneProxy()
    {
    
    	FPrimitiveSceneProxy* Proxy = Super::CreateSceneProxy();
    
    	if (!PerInstanceRenderData.IsValid() || PerInstanceSMData.Num() < 1 )
    	{
    		return Proxy;
    	}
    
    	//check(IsInGameThread());
    
    	//bool bSupportsVertexHalfFloat = GVertexElementTypeSupport.IsSupported(VET_Half2);
    	//int32 NumInstances = PerInstanceSMData.Num();
    	int32 NumInstancesRenderData = PerInstanceRenderData->InstanceBuffer_GameThread->GetNumInstances();
    	
    
    	for (int32 Index = 0; Index < NumInstancesRenderData; ++Index)
    	{
    		int32 RenderIndex = InstanceReorderTable.IsValidIndex(Index) ? InstanceReorderTable[Index] : Index;
    		if (RenderIndex == INDEX_NONE)
    		{
    			// could be skipped by density settings
    			continue;
    		}