Skip to content

Commit

Permalink
Minor fixes:
Browse files Browse the repository at this point in the history
Fixed wrong copyright lines
Fixed retrieving a tex coord channel
Fixed various include issues

Setup project to work alongside RMC-Pro
  • Loading branch information
Koderz committed Sep 14, 2020
1 parent fd1696a commit ce9fefa
Show file tree
Hide file tree
Showing 27 changed files with 174 additions and 37 deletions.
25 changes: 23 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Git files
.git/

# Visual Studio 2015 user specific files
.vs/

Expand Down Expand Up @@ -49,7 +52,7 @@ SourceArt/**/*.png
SourceArt/**/*.tga

# Binary Files
Binaries/*
Binaries/**
Plugins/*/Binaries/*

# Builds
Expand All @@ -70,8 +73,26 @@ Build/*/**
Saved/*

# Compiled source files for the engine to use
Intermediate/*
Intermediate/**
Plugins/*/Intermediate/*

# Cache files for the editor to use
DerivedDataCache/*

# Mac crap
.DS_Store

# Un-Ignore All ThirdParty binary/libs etc.
!ThirdParty/**

# Ignore Export directory
Export/**

# Ignore VS Code files
.vscode/**

# Unignore .github folder
!.github/**

# Unignore .gitignore
!.gitignore
File renamed without changes.
Binary file removed Source/RuntimeMeshComponent/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "RuntimeMeshComponentPlugin.h"
#include "RuntimeMeshModifier.h"


#define RMC_LOG_VERBOSE(Format, ...) \
UE_LOG(RuntimeMeshLog2, Verbose, TEXT("[RMPS:%d Thread:%d]: " Format), GetUniqueID(), FPlatformTLS::GetCurrentThreadId(), __VA_ARGS__);

Expand Down Expand Up @@ -295,6 +296,8 @@ void URuntimeMeshProviderStatic::SetShouldSerializeMeshData(bool bIsSerialized)
StoreEditorGeneratedDataForGame = bIsSerialized;
}



void URuntimeMeshProviderStatic::Initialize()
{
RMC_LOG_VERBOSE("Initializing...");
Expand Down Expand Up @@ -479,7 +482,6 @@ bool URuntimeMeshProviderStatic::GetCollisionMesh(FRuntimeMeshCollisionData& Col
}



void URuntimeMeshProviderStatic::ConfigureLODs(const TArray<FRuntimeMeshLODProperties>& LODSettings)
{
check(LODSettings.Num() > 0 && LODSettings.Num() <= RUNTIMEMESH_MAXLODS);
Expand Down Expand Up @@ -634,6 +636,30 @@ void URuntimeMeshProviderStatic::Serialize(FArchive& Ar)
LoadedMaterialSlots = MaterialSlots;
}
}

if (Ar.CustomVer(FRuntimeMeshVersion::GUID) >= FRuntimeMeshVersion::AddedDistanceField)
{
if (Ar.IsSaving())
{
bool bHasDistanceField = false;
Ar << bHasDistanceField;
if (bHasDistanceField)
{
FRuntimeMeshDistanceFieldData NullDistanceField;
Ar << NullDistanceField;
}
}
else if (Ar.IsLoading())
{
bool bHasDistanceField;
Ar << bHasDistanceField;
if (bHasDistanceField)
{
FRuntimeMeshDistanceFieldData NullDistanceField;
Ar << NullDistanceField;
}
}
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Source/RuntimeMeshComponent/Private/RuntimeMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class FRuntimeMeshUpdateTask : public FNonAbandonableTask
PinnedRef->HandleUpdate();
//}
}

}
}

Expand Down Expand Up @@ -602,6 +603,8 @@ void URuntimeMesh::QueueForDelayedInitialize()
}




void URuntimeMesh::QueueForUpdate()
{
FRuntimeMeshMisc::DoOnGameThread([MeshPtr = GetMeshReference()]()
Expand Down Expand Up @@ -899,6 +902,7 @@ void URuntimeMesh::HandleSingleSectionUpdate(const FRuntimeMeshProxyPtr& RenderP
}



URuntimeMeshComponentEngineSubsystem* URuntimeMesh::GetEngineSubsystem()
{
URuntimeMeshComponentEngineSubsystem* RMCSubsystem = GEngine->GetEngineSubsystem<URuntimeMeshComponentEngineSubsystem>();
Expand Down Expand Up @@ -1163,6 +1167,7 @@ FRuntimeMeshProxyPtr URuntimeMesh::GetRenderProxy(ERHIFeatureLevel::Type InFeatu
}
}


return RenderProxy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ void URuntimeMeshBlueprintFunctions::AppendTexCoords(FRuntimeMeshVertexTexCoordS
Stream.Append(InOther);
}

void URuntimeMeshBlueprintFunctions::GetTexCoord(FRuntimeMeshVertexTexCoordStream& Stream, FRuntimeMeshVertexTexCoordStream& OutStream, int32 Index, FVector2D& OutTexCoord)
void URuntimeMeshBlueprintFunctions::GetTexCoord(FRuntimeMeshVertexTexCoordStream& Stream, FRuntimeMeshVertexTexCoordStream& OutStream, int32 Index, int32 ChannelId, FVector2D& OutTexCoord)
{
OutStream = Stream;
OutTexCoord = Stream.GetTexCoord(Index);
OutTexCoord = Stream.GetTexCoord(Index, ChannelId);
}

void URuntimeMeshBlueprintFunctions::SetTexCoord(FRuntimeMeshVertexTexCoordStream& Stream, FRuntimeMeshVertexTexCoordStream& OutStream, int32 Index, FVector2D NewTexCoord, int32 ChannelId /*= 0*/)
Expand Down
2 changes: 0 additions & 2 deletions Source/RuntimeMeshComponent/Private/RuntimeMeshComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ void URuntimeMeshComponent::ForceProxyRecreate()
}




FBoxSphereBounds URuntimeMeshComponent::CalcBounds(const FTransform& LocalToWorld) const
{
if (GetRuntimeMesh())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ void URuntimeMeshComponentEngineSubsystem::Tick(float DeltaTime)
{
MeshRef->HandleUpdate();
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Serialization/CustomVersion.h"
#include "RuntimeMeshCore.h"


// Register the custom version with core
FCustomVersionRegistration GRegisterRuntimeMeshCustomVersion(FRuntimeMeshVersion::GUID, FRuntimeMeshVersion::LatestVersion, TEXT("RuntimeMesh"));

Expand All @@ -20,12 +21,10 @@ IMPLEMENT_MODULE(FRuntimeMeshComponentPlugin, RuntimeMeshComponent)

void FRuntimeMeshComponentPlugin::StartupModule()
{

}

void FRuntimeMeshComponentPlugin::ShutdownModule()
{

}

DEFINE_LOG_CATEGORY(RuntimeMeshLog2);
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "RayTracingDefinitions.h"
#include "RayTracingInstance.h"


DECLARE_CYCLE_STAT(TEXT("RuntimeMeshComponentSceneProxy - Create Mesh Batch"), STAT_RuntimeMeshComponentSceneProxy_CreateMeshBatch, STATGROUP_RuntimeMesh);
DECLARE_CYCLE_STAT(TEXT("RuntimeMeshComponentSceneProxy - Get Dynamic Mesh Elements"), STAT_RuntimeMeshComponentSceneProxy_GetDynamicMeshElements, STATGROUP_RuntimeMesh);
DECLARE_CYCLE_STAT(TEXT("RuntimeMeshComponentSceneProxy - Draw Static Mesh Elements"), STAT_RuntimeMeshComponentSceneProxy_DrawStaticMeshElements, STATGROUP_RuntimeMesh);
Expand Down Expand Up @@ -67,6 +68,8 @@ FRuntimeMeshComponentSceneProxy::FRuntimeMeshComponentSceneProxy(URuntimeMeshCom
// We always use local vertex factory, which gets its primitive data from GPUScene, so we can skip expensive primitive uniform buffer updates
bVFRequiresPrimitiveUniformBuffer = !UseGPUScene(GMaxRHIShaderPlatform, FeatureLevel);
bStaticElementsAlwaysUseProxyPrimitiveUniformBuffer = true;
bVerifyUsedMaterials = false;

}

FRuntimeMeshComponentSceneProxy::~FRuntimeMeshComponentSceneProxy()
Expand Down Expand Up @@ -119,14 +122,15 @@ void FRuntimeMeshComponentSceneProxy::CreateMeshBatch(FMeshBatch& MeshBatch, con
const bool bWantsAdjacencyInfo = !bForRayTracing && !bRenderWireframe && RequiresAdjacencyInformation(Material, Section.Buffers->VertexFactory.GetType(), GetScene().GetFeatureLevel());
check(!bWantsAdjacencyInfo || Section.bHasAdjacencyInfo);


// No support for stateless dithered LOD transitions for movable meshes
const bool bDitheredLODTransition = !IsMovable() && Material->IsDitheredLODTransition();


const FRuntimeMeshIndexBuffer* CurrentIndexBuffer =
(bWantsAdjacencyInfo ?
&Section.Buffers->AdjacencyIndexBuffer :
&Section.Buffers->IndexBuffer);
&Section.Buffers->IndexBuffer);

int32 NumIndicesPerTriangle = bWantsAdjacencyInfo ? 12 : 3;
int32 NumPrimitives = CurrentIndexBuffer->Num() / NumIndicesPerTriangle;
Expand Down Expand Up @@ -286,7 +290,6 @@ void FRuntimeMeshComponentSceneProxy::GetDynamicMeshElements(const TArray<const
}



// This function was exposed on 4.24, previously it existed but wasn't public
#if ENGINE_MAJOR_VERSION <= 4 && ENGINE_MINOR_VERSION < 24
static float ComputeBoundsScreenRadiusSquared(const FVector4& BoundsOrigin, const float SphereRadius, const FVector4& ViewOrigin, const FMatrix& ProjMatrix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class FRuntimeMeshComponentSceneProxy : public FPrimitiveSceneProxy

virtual void GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const override;


#if RHI_RAYTRACING
virtual bool IsRayTracingRelevant() const { return true; }
virtual bool IsRayTracingStaticRelevant() const { return false; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.
// Copyright 2016-2020 Chris Conway (Koderz). All Rights Reserved.


#include "RuntimeMeshComponentSettings.h"
Expand Down
2 changes: 2 additions & 0 deletions Source/RuntimeMeshComponent/Private/RuntimeMeshProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void URuntimeMeshProvider::MarkCollisionDirty()
}
}


void URuntimeMeshProvider::SetupMaterialSlot(int32 MaterialSlot, FName SlotName, UMaterialInterface* InMaterial)
{
FReadScopeLock Lock(TargetLock);
Expand Down Expand Up @@ -365,6 +366,7 @@ void URuntimeMeshProviderPassthrough::CollisionUpdateCompleted()
}
}


bool URuntimeMeshProviderPassthrough::IsThreadSafe()
{
FReadScopeLock Lock(ChildLock);
Expand Down
7 changes: 4 additions & 3 deletions Source/RuntimeMeshComponent/Private/RuntimeMeshProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "RuntimeMeshComponentPlugin.h"
#include "RuntimeMesh.h"


DECLARE_CYCLE_STAT(TEXT("RuntimeMeshProxy - Initialize LDOs - RenderThread"), STAT_RuntimeMeshProxy_InitializeLODs_RT, STATGROUP_RuntimeMesh);
DECLARE_CYCLE_STAT(TEXT("RuntimeMeshProxy - Clear LOD - RenderThread"), STAT_RuntimeMeshProxy_ClearLOD_RT, STATGROUP_RuntimeMesh);
DECLARE_CYCLE_STAT(TEXT("RuntimeMeshProxy - Create/Update Section - RenderThread"), STAT_RuntimeMeshProxy_CreateUpdateSection_RT, STATGROUP_RuntimeMesh);
Expand Down Expand Up @@ -86,7 +87,6 @@ void FRuntimeMeshProxy::FlushPendingUpdates()




void FRuntimeMeshProxy::ResetProxy_GameThread()
{
RMC_LOG_VERBOSE("ResetProxy_GameThread");
Expand Down Expand Up @@ -197,6 +197,7 @@ void FRuntimeMeshProxy::ResetProxy_RenderThread()
CurrentForcedLOD = INDEX_NONE;

LODs.Empty();

}

void FRuntimeMeshProxy::InitializeLODs_RenderThread(const TArray<FRuntimeMeshLODProperties>& InProperties)
Expand Down Expand Up @@ -449,6 +450,8 @@ void FRuntimeMeshProxy::RemoveSection_RenderThread(int32 LODIndex, int32 Section
}
}



void FRuntimeMeshProxy::UpdateRenderState()
{
bShouldRender = false;
Expand Down Expand Up @@ -547,9 +550,7 @@ void FRuntimeMeshProxy::ApplyMeshToSection(int32 LODIndex, int32 SectionId, FRun
FRuntimeMeshSectionProxyBuffers& Buffers = *Section.Buffers.Get();

Buffers.VertexFactory.ReleaseResource();
#if RHI_RAYTRACING
Buffers.RayTracingGeometry.ReleaseResource();
#endif
}

check(!Section.CanRender() || Section.Buffers->VertexFactory.IsInitialized());
Expand Down
4 changes: 3 additions & 1 deletion Source/RuntimeMeshComponent/Private/RuntimeMeshProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class FRuntimeMeshProxy : public TSharedFromThis<FRuntimeMeshProxy, ESPMode::Thr
{
TInlineLODArray<FRuntimeMeshLODData> LODs;



FThreadSafeBool IsQueuedForUpdate;
TQueue<TFunction<void()>, EQueueMode::Mpsc> PendingUpdates;

Expand Down Expand Up @@ -55,6 +57,7 @@ class FRuntimeMeshProxy : public TSharedFromThis<FRuntimeMeshProxy, ESPMode::Thr

float GetScreenSize(int32 LODIndex) const;


void QueueForUpdate();
void FlushPendingUpdates();

Expand Down Expand Up @@ -87,7 +90,6 @@ class FRuntimeMeshProxy : public TSharedFromThis<FRuntimeMeshProxy, ESPMode::Thr
void RemoveSection_RenderThread(int32 LODIndex, int32 SectionId);



void UpdateRenderState();

void ClearSection(FRuntimeMeshSectionProxy& Section);
Expand Down
2 changes: 2 additions & 0 deletions Source/RuntimeMeshComponent/Private/RuntimeMeshSectionProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct FRuntimeMeshSectionProxyBuffers : public TSharedFromThis<FRuntimeMeshSect
/** Index buffer for this section */
FRuntimeMeshIndexBuffer IndexBuffer;


/** Index buffer for this section */
FRuntimeMeshIndexBuffer AdjacencyIndexBuffer;

Expand Down Expand Up @@ -101,6 +102,7 @@ struct FRuntimeMeshSectionProxyBuffers : public TSharedFromThis<FRuntimeMeshSect

IndexBuffer.UpdateRHIFromExisting(UpdateData.TrianglesBuffer, UpdateData.Triangles.GetNumElements(), UpdateData.b32BitTriangles, Batcher);
AdjacencyIndexBuffer.UpdateRHIFromExisting(UpdateData.AdjacencyTrianglesBuffer, UpdateData.AdjacencyTriangles.GetNumElements(), UpdateData.b32BitAdjacencyTriangles, Batcher);

}

void UpdateRayTracingGeometry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@


#include "RuntimeMeshStaticMeshConverter.h"
#include "RuntimeMeshComponentPlugin.h"
#include "EngineGlobals.h"
#include "Engine/StaticMesh.h"
#include "PhysicsEngine/BodySetup.h"
#include "RuntimeMeshRenderable.h"
#include "RuntimeMeshComponent.h"
#include "Providers/RuntimeMeshProviderStatic.h"


#define RMC_LOG_VERBOSE(MeshId, Format, ...) \
UE_LOG(RuntimeMeshLog2, Verbose, TEXT("[SMC->RMC Mesh:%d Thread:%d]: " Format), MeshId, FPlatformTLS::GetCurrentThreadId(), __VA_ARGS__);

Expand Down Expand Up @@ -400,6 +402,7 @@ bool URuntimeMeshStaticMeshConverter::CopyStaticMeshToRuntimeMesh(UStaticMesh* S
StaticProvider->SetCollisionMesh(CollisionData);
}


return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshProviderStatic : public URuntimeMeshP

TArray<FRuntimeMeshMaterialSlot> LoadedMaterialSlots;


UPROPERTY(VisibleAnywhere, Category = "RuntimeMesh|Providers|Static")
TArray<URuntimeMeshModifier*> CurrentMeshModifiers;
public:
Expand Down Expand Up @@ -321,7 +322,6 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshProviderStatic : public URuntimeMeshP
UFUNCTION(BlueprintCallable, Category = "RuntimeMesh|Providers|Static")
void SetShouldSerializeMeshData(bool bIsSerialized);


public:

virtual void Initialize() override;
Expand All @@ -331,6 +331,7 @@ class RUNTIMEMESHCOMPONENT_API URuntimeMeshProviderStatic : public URuntimeMeshP
virtual bool HasCollisionMesh() override;
virtual bool GetCollisionMesh(FRuntimeMeshCollisionData& CollisionData) override;


public:
virtual void ConfigureLODs(const TArray<FRuntimeMeshLODProperties>& LODSettings) override;
virtual void SetLODScreenSize(int32 LODIndex, float ScreenSize) override;
Expand Down
Loading

0 comments on commit ce9fefa

Please sign in to comment.