From 517ba46a7e9f00f85798e2d1b7752f7a05710de7 Mon Sep 17 00:00:00 2001 From: kamex-kumax Date: Sun, 22 Sep 2019 17:57:05 +0900 Subject: [PATCH 1/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79f3092..c397a90 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Street Map Plugin for UE4 [4.22] +# Street Map Plugin for UE4 [4.23] This plugin allows you to import **OpenStreetMap** XML data into your **Unreal Engine 4** project as a new StreetMap asset type. You can use the example **Street Map Component** to render streets and buildings. From aa993990fecb1ad07d289d8e8b78984e020bff32 Mon Sep 17 00:00:00 2001 From: kamex-kumax Date: Sun, 22 Sep 2019 21:04:57 +0900 Subject: [PATCH 2/4] Formated a indent and indent character. --- .../StreetMapImporting.Build.cs | 54 +++++++++---------- .../StreetMapRuntime.Build.cs | 38 ++++++------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/Source/StreetMapImporting/StreetMapImporting.Build.cs b/Source/StreetMapImporting/StreetMapImporting.Build.cs index 1dc7d2e..74d9bc2 100644 --- a/Source/StreetMapImporting/StreetMapImporting.Build.cs +++ b/Source/StreetMapImporting/StreetMapImporting.Build.cs @@ -2,33 +2,33 @@ namespace UnrealBuildTool.Rules { - public class StreetMapImporting : ModuleRules + public class StreetMapImporting : ModuleRules + { + public StreetMapImporting(ReadOnlyTargetRules Target) + : base(Target) { - public StreetMapImporting(ReadOnlyTargetRules Target) - : base(Target) - { - PrivatePCHHeaderFile = "StreetMapImporting.h"; - PrivateDependencyModuleNames.AddRange( - new string[] { - "Core", - "CoreUObject", - "Engine", - "UnrealEd", - "XmlParser", - "AssetTools", - "Projects", - "Slate", - "EditorStyle", - "SlateCore", - "PropertyEditor", - "RenderCore", - "RHI", - "RawMesh", - "AssetTools", - "AssetRegistry", - "StreetMapRuntime" - } - ); + PrivatePCHHeaderFile = "StreetMapImporting.h"; + PrivateDependencyModuleNames.AddRange( + new string[] { + "Core", + "CoreUObject", + "Engine", + "UnrealEd", + "XmlParser", + "AssetTools", + "Projects", + "Slate", + "EditorStyle", + "SlateCore", + "PropertyEditor", + "RenderCore", + "RHI", + "RawMesh", + "AssetTools", + "AssetRegistry", + "StreetMapRuntime" } + ); } -} \ No newline at end of file + } +} diff --git a/Source/StreetMapRuntime/StreetMapRuntime.Build.cs b/Source/StreetMapRuntime/StreetMapRuntime.Build.cs index 9615dc9..5cdf8f9 100644 --- a/Source/StreetMapRuntime/StreetMapRuntime.Build.cs +++ b/Source/StreetMapRuntime/StreetMapRuntime.Build.cs @@ -2,22 +2,22 @@ namespace UnrealBuildTool.Rules { - public class StreetMapRuntime : ModuleRules - { - public StreetMapRuntime(ReadOnlyTargetRules Target) - : base(Target) - { - PrivatePCHHeaderFile = "StreetMapRuntime.h"; - PrivateDependencyModuleNames.AddRange( - new string[] { - "Core", - "CoreUObject", - "Engine", - "RHI", - "RenderCore", - "PropertyEditor" - } - ); - } - } -} \ No newline at end of file + public class StreetMapRuntime : ModuleRules + { + public StreetMapRuntime(ReadOnlyTargetRules Target) + : base(Target) + { + PrivatePCHHeaderFile = "StreetMapRuntime.h"; + PrivateDependencyModuleNames.AddRange( + new string[] { + "Core", + "CoreUObject", + "Engine", + "RHI", + "RenderCore", + "PropertyEditor" + } + ); + } + } +} From fa5e9e5685f4a7ffb00f17b326da6cb8ca6a12fa Mon Sep 17 00:00:00 2001 From: kamex-kumax Date: Mon, 23 Sep 2019 03:25:25 +0900 Subject: [PATCH 3/4] Formated a indent and indent cahracter, newline character. --- .../StreetMapRuntime/StreetMapSceneProxy.cpp | 384 +++++++++--------- 1 file changed, 192 insertions(+), 192 deletions(-) diff --git a/Source/StreetMapRuntime/StreetMapSceneProxy.cpp b/Source/StreetMapRuntime/StreetMapSceneProxy.cpp index 92b1cd1..3f54296 100644 --- a/Source/StreetMapRuntime/StreetMapSceneProxy.cpp +++ b/Source/StreetMapRuntime/StreetMapSceneProxy.cpp @@ -1,32 +1,32 @@ -// Copyright 2017 Mike Fricker. All Rights Reserved. - -#include "StreetMapRuntime.h" -#include "StreetMapSceneProxy.h" -#include "StreetMapComponent.h" -#include "Runtime/Engine/Public/SceneManagement.h" -#include "Runtime/Renderer/Public/MeshPassProcessor.h" -#include "Runtime/Renderer/Public/PrimitiveSceneInfo.h" - - -FStreetMapSceneProxy::FStreetMapSceneProxy(const UStreetMapComponent* InComponent) - : FPrimitiveSceneProxy(InComponent), - VertexFactory(GetScene().GetFeatureLevel(), "FStreetMapSceneProxy"), - StreetMapComp(InComponent), - CollisionResponse(InComponent->GetCollisionResponseToChannels()) -{ - -} - -void FStreetMapSceneProxy::Init(const UStreetMapComponent* InComponent, const TArray< FStreetMapVertex >& Vertices, const TArray< uint32 >& Indices) -{ +// Copyright 2017 Mike Fricker. All Rights Reserved. + +#include "StreetMapRuntime.h" +#include "StreetMapSceneProxy.h" +#include "StreetMapComponent.h" +#include "Runtime/Engine/Public/SceneManagement.h" +#include "Runtime/Renderer/Public/MeshPassProcessor.h" +#include "Runtime/Renderer/Public/PrimitiveSceneInfo.h" + + +FStreetMapSceneProxy::FStreetMapSceneProxy(const UStreetMapComponent* InComponent) + : FPrimitiveSceneProxy(InComponent), + VertexFactory(GetScene().GetFeatureLevel(), "FStreetMapSceneProxy"), + StreetMapComp(InComponent), + CollisionResponse(InComponent->GetCollisionResponseToChannels()) +{ + +} + +void FStreetMapSceneProxy::Init(const UStreetMapComponent* InComponent, const TArray< FStreetMapVertex >& Vertices, const TArray< uint32 >& Indices) +{ // Copy index buffer - IndexBuffer32.Indices = Indices; - - MaterialInterface = nullptr; - this->MaterialRelevance = InComponent->GetMaterialRelevance(GetScene().GetFeatureLevel()); - - // Copy vertex data - const int32 NumVerts = Vertices.Num(); + IndexBuffer32.Indices = Indices; + + MaterialInterface = nullptr; + this->MaterialRelevance = InComponent->GetMaterialRelevance(GetScene().GetFeatureLevel()); + + // Copy vertex data + const int32 NumVerts = Vertices.Num(); TArray DynamicVertices; DynamicVertices.SetNumUninitialized(NumVerts); @@ -39,183 +39,183 @@ void FStreetMapSceneProxy::Init(const UStreetMapComponent* InComponent, const TA Vert.TextureCoordinate[0] = StreetMapVert.TextureCoordinate; Vert.TangentX = StreetMapVert.TangentX; Vert.TangentZ = StreetMapVert.TangentZ; - } - - VertexBuffer.InitFromDynamicVertex(&VertexFactory, DynamicVertices); - - // Enqueue initialization of render resource - InitResources(); - - // Set a material - { - if (InComponent->GetNumMaterials() > 0) - { - MaterialInterface = InComponent->GetMaterial(0); - } - - // Use the default material if we don't have one set - if (MaterialInterface == nullptr) - { - MaterialInterface = UMaterial::GetDefaultMaterial(MD_Surface); - } - } -} - -FStreetMapSceneProxy::~FStreetMapSceneProxy() -{ + } + + VertexBuffer.InitFromDynamicVertex(&VertexFactory, DynamicVertices); + + // Enqueue initialization of render resource + InitResources(); + + // Set a material + { + if (InComponent->GetNumMaterials() > 0) + { + MaterialInterface = InComponent->GetMaterial(0); + } + + // Use the default material if we don't have one set + if (MaterialInterface == nullptr) + { + MaterialInterface = UMaterial::GetDefaultMaterial(MD_Surface); + } + } +} + +FStreetMapSceneProxy::~FStreetMapSceneProxy() +{ VertexBuffer.PositionVertexBuffer.ReleaseResource(); VertexBuffer.StaticMeshVertexBuffer.ReleaseResource(); VertexBuffer.ColorVertexBuffer.ReleaseResource(); IndexBuffer32.ReleaseResource(); - VertexFactory.ReleaseResource(); -} - - -SIZE_T FStreetMapSceneProxy::GetTypeHash() const + VertexFactory.ReleaseResource(); +} + + +SIZE_T FStreetMapSceneProxy::GetTypeHash() const { static size_t UniquePointer; return reinterpret_cast(&UniquePointer); -} - -void FStreetMapSceneProxy::InitResources() -{ +} + +void FStreetMapSceneProxy::InitResources() +{ // Start initializing our vertex buffer, index buffer, and vertex factory. This will be kicked off on the render thread. BeginInitResource(&VertexBuffer.PositionVertexBuffer); BeginInitResource(&VertexBuffer.StaticMeshVertexBuffer); BeginInitResource(&VertexBuffer.ColorVertexBuffer); BeginInitResource(&IndexBuffer32); - BeginInitResource(&VertexFactory); -} - -bool FStreetMapSceneProxy::MustDrawMeshDynamically( const FSceneView& View ) const -{ - return ( AllowDebugViewmodes() && View.Family->EngineShowFlags.Wireframe ) || IsSelected(); -} - - -bool FStreetMapSceneProxy::IsInCollisionView(const FEngineShowFlags& EngineShowFlags) const -{ - return EngineShowFlags.CollisionVisibility || EngineShowFlags.CollisionPawn; -} - -FPrimitiveViewRelevance FStreetMapSceneProxy::GetViewRelevance( const FSceneView* View ) const -{ - FPrimitiveViewRelevance Result; - Result.bDrawRelevance = IsShown(View); - Result.bShadowRelevance = IsShadowCast(View); - - const bool bAlwaysHasDynamicData = false; - - // Only draw dynamically if we're drawing in wireframe or we're selected in the editor - Result.bDynamicRelevance = MustDrawMeshDynamically( *View ) || bAlwaysHasDynamicData; - Result.bStaticRelevance = !MustDrawMeshDynamically( *View ); - - MaterialRelevance.SetPrimitiveViewRelevance(Result); - return Result; -} - - -bool FStreetMapSceneProxy::CanBeOccluded() const -{ - return !MaterialRelevance.bDisableDepthTest; -} - - -void FStreetMapSceneProxy::MakeMeshBatch( FMeshBatch& Mesh, class FMeshElementCollector& Collector, FMaterialRenderProxy* WireframeMaterialRenderProxyOrNull, bool bDrawCollision) const -{ - FMaterialRenderProxy* MaterialProxy = NULL; - if( WireframeMaterialRenderProxyOrNull != nullptr ) - { - MaterialProxy = WireframeMaterialRenderProxyOrNull; - } - else - { - if (bDrawCollision) - { - MaterialProxy = new FColoredMaterialRenderProxy(GEngine->ShadedLevelColorationUnlitMaterial->GetRenderProxy(), FLinearColor::Blue); - } - else if (MaterialProxy == nullptr) - { - MaterialProxy = StreetMapComp->GetDefaultMaterial()->GetRenderProxy(); - } - } - - FMeshBatchElement& BatchElement = Mesh.Elements[0]; - - BatchElement.IndexBuffer = &IndexBuffer32; - Mesh.bWireframe = WireframeMaterialRenderProxyOrNull != nullptr; - Mesh.VertexFactory = &VertexFactory; - Mesh.MaterialRenderProxy = MaterialProxy; + BeginInitResource(&VertexFactory); +} + +bool FStreetMapSceneProxy::MustDrawMeshDynamically( const FSceneView& View ) const +{ + return ( AllowDebugViewmodes() && View.Family->EngineShowFlags.Wireframe ) || IsSelected(); +} + + +bool FStreetMapSceneProxy::IsInCollisionView(const FEngineShowFlags& EngineShowFlags) const +{ + return EngineShowFlags.CollisionVisibility || EngineShowFlags.CollisionPawn; +} + +FPrimitiveViewRelevance FStreetMapSceneProxy::GetViewRelevance( const FSceneView* View ) const +{ + FPrimitiveViewRelevance Result; + Result.bDrawRelevance = IsShown(View); + Result.bShadowRelevance = IsShadowCast(View); + + const bool bAlwaysHasDynamicData = false; + + // Only draw dynamically if we're drawing in wireframe or we're selected in the editor + Result.bDynamicRelevance = MustDrawMeshDynamically( *View ) || bAlwaysHasDynamicData; + Result.bStaticRelevance = !MustDrawMeshDynamically( *View ); + + MaterialRelevance.SetPrimitiveViewRelevance(Result); + return Result; +} + + +bool FStreetMapSceneProxy::CanBeOccluded() const +{ + return !MaterialRelevance.bDisableDepthTest; +} + + +void FStreetMapSceneProxy::MakeMeshBatch( FMeshBatch& Mesh, class FMeshElementCollector& Collector, FMaterialRenderProxy* WireframeMaterialRenderProxyOrNull, bool bDrawCollision) const +{ + FMaterialRenderProxy* MaterialProxy = NULL; + if( WireframeMaterialRenderProxyOrNull != nullptr ) + { + MaterialProxy = WireframeMaterialRenderProxyOrNull; + } + else + { + if (bDrawCollision) + { + MaterialProxy = new FColoredMaterialRenderProxy(GEngine->ShadedLevelColorationUnlitMaterial->GetRenderProxy(), FLinearColor::Blue); + } + else if (MaterialProxy == nullptr) + { + MaterialProxy = StreetMapComp->GetDefaultMaterial()->GetRenderProxy(); + } + } + + FMeshBatchElement& BatchElement = Mesh.Elements[0]; + + BatchElement.IndexBuffer = &IndexBuffer32; + Mesh.bWireframe = WireframeMaterialRenderProxyOrNull != nullptr; + Mesh.VertexFactory = &VertexFactory; + Mesh.MaterialRenderProxy = MaterialProxy; Mesh.CastShadow = true; - // BatchElement.PrimitiveUniformBufferResource = &GetUniformBuffer(); - // BatchElement.PrimitiveUniformBuffer = CreatePrimitiveUniformBufferImmediate(GetLocalToWorld(), GetBounds(), GetLocalBounds(), true, UseEditorDepthTest()); + // BatchElement.PrimitiveUniformBufferResource = &GetUniformBuffer(); + // BatchElement.PrimitiveUniformBuffer = CreatePrimitiveUniformBufferImmediate(GetLocalToWorld(), GetBounds(), GetLocalBounds(), true, UseEditorDepthTest()); FDynamicPrimitiveUniformBuffer& DynamicPrimitiveUniformBuffer = Collector.AllocateOneFrameResource(); DynamicPrimitiveUniformBuffer.Set(GetLocalToWorld(), GetLocalToWorld(), GetBounds(), GetLocalBounds(), true, false, UseEditorDepthTest()); - BatchElement.PrimitiveUniformBufferResource = &DynamicPrimitiveUniformBuffer.UniformBuffer; - - BatchElement.FirstIndex = 0; - const int IndexCount = IndexBuffer32.Indices.Num(); - BatchElement.NumPrimitives = IndexCount / 3; - BatchElement.MinVertexIndex = 0; - BatchElement.MaxVertexIndex = VertexBuffer.PositionVertexBuffer.GetNumVertices() - 1; - Mesh.ReverseCulling = IsLocalToWorldDeterminantNegative(); - Mesh.Type = PT_TriangleList; - Mesh.DepthPriorityGroup = SDPG_World; - - -} - -/* -void FStreetMapSceneProxy::DrawStaticElements( FStaticPrimitiveDrawInterface* PDI ) -{ - const int IndexCount = IndexBuffer32.Indices.Num(); - if( VertexBuffer.PositionVertexBuffer.GetNumVertices() > 0 && IndexCount > 0 ) - { - const float ScreenSize = 1.0f; - FMeshBatch MeshBatch; - MakeMeshBatch( MeshBatch, nullptr); - PDI->DrawMesh( MeshBatch, ScreenSize ); - - } -} -*/ - -void FStreetMapSceneProxy::GetDynamicMeshElements(const TArray& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, class FMeshElementCollector& Collector) const -{ - const int IndexCount = IndexBuffer32.Indices.Num(); - if (VertexBuffer.PositionVertexBuffer.GetNumVertices() > 0 && IndexCount > 0) - { - for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ++ViewIndex) - { - const FSceneView& View = *Views[ViewIndex]; - - const bool bIsWireframe = AllowDebugViewmodes() && View.Family->EngineShowFlags.Wireframe; - - FColoredMaterialRenderProxy* WireframeMaterialRenderProxy = GEngine->WireframeMaterial && bIsWireframe ? new FColoredMaterialRenderProxy(GEngine->WireframeMaterial->GetRenderProxy(), FLinearColor(0, 0.5f, 1.f)) : NULL; - - - if (MustDrawMeshDynamically(View)) - { - const bool bInCollisionView = IsInCollisionView(ViewFamily.EngineShowFlags); - const bool bCanDrawCollision = bInCollisionView && IsCollisionEnabled(); - - if (!IsCollisionEnabled() && bInCollisionView) - { - continue; - } - - // Draw the mesh! - FMeshBatch& MeshBatch = Collector.AllocateMesh(); - MakeMeshBatch(MeshBatch, Collector, WireframeMaterialRenderProxy, bCanDrawCollision); - Collector.AddMesh(ViewIndex, MeshBatch); - } - } - } -} - - -uint32 FStreetMapSceneProxy::GetMemoryFootprint( void ) const -{ - return sizeof( *this ) + GetAllocatedSize(); -} + BatchElement.PrimitiveUniformBufferResource = &DynamicPrimitiveUniformBuffer.UniformBuffer; + + BatchElement.FirstIndex = 0; + const int IndexCount = IndexBuffer32.Indices.Num(); + BatchElement.NumPrimitives = IndexCount / 3; + BatchElement.MinVertexIndex = 0; + BatchElement.MaxVertexIndex = VertexBuffer.PositionVertexBuffer.GetNumVertices() - 1; + Mesh.ReverseCulling = IsLocalToWorldDeterminantNegative(); + Mesh.Type = PT_TriangleList; + Mesh.DepthPriorityGroup = SDPG_World; + + +} + +/* +void FStreetMapSceneProxy::DrawStaticElements( FStaticPrimitiveDrawInterface* PDI ) +{ + const int IndexCount = IndexBuffer32.Indices.Num(); + if( VertexBuffer.PositionVertexBuffer.GetNumVertices() > 0 && IndexCount > 0 ) + { + const float ScreenSize = 1.0f; + FMeshBatch MeshBatch; + MakeMeshBatch( MeshBatch, nullptr); + PDI->DrawMesh( MeshBatch, ScreenSize ); + + } +} +*/ + +void FStreetMapSceneProxy::GetDynamicMeshElements(const TArray& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, class FMeshElementCollector& Collector) const +{ + const int IndexCount = IndexBuffer32.Indices.Num(); + if (VertexBuffer.PositionVertexBuffer.GetNumVertices() > 0 && IndexCount > 0) + { + for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ++ViewIndex) + { + const FSceneView& View = *Views[ViewIndex]; + + const bool bIsWireframe = AllowDebugViewmodes() && View.Family->EngineShowFlags.Wireframe; + + FColoredMaterialRenderProxy* WireframeMaterialRenderProxy = GEngine->WireframeMaterial && bIsWireframe ? new FColoredMaterialRenderProxy(GEngine->WireframeMaterial->GetRenderProxy(), FLinearColor(0, 0.5f, 1.f)) : NULL; + + + if (MustDrawMeshDynamically(View)) + { + const bool bInCollisionView = IsInCollisionView(ViewFamily.EngineShowFlags); + const bool bCanDrawCollision = bInCollisionView && IsCollisionEnabled(); + + if (!IsCollisionEnabled() && bInCollisionView) + { + continue; + } + + // Draw the mesh! + FMeshBatch& MeshBatch = Collector.AllocateMesh(); + MakeMeshBatch(MeshBatch, Collector, WireframeMaterialRenderProxy, bCanDrawCollision); + Collector.AddMesh(ViewIndex, MeshBatch); + } + } + } +} + + +uint32 FStreetMapSceneProxy::GetMemoryFootprint( void ) const +{ + return sizeof( *this ) + GetAllocatedSize(); +} From 72b821f9c0ca16d184b7cb6554a88af0658caab4 Mon Sep 17 00:00:00 2001 From: kamex-kumax Date: Mon, 23 Sep 2019 03:28:46 +0900 Subject: [PATCH 4/4] Updated a invalid function for UE4.23 --- Source/StreetMapRuntime/StreetMapSceneProxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/StreetMapRuntime/StreetMapSceneProxy.cpp b/Source/StreetMapRuntime/StreetMapSceneProxy.cpp index 3f54296..2a88fb3 100644 --- a/Source/StreetMapRuntime/StreetMapSceneProxy.cpp +++ b/Source/StreetMapRuntime/StreetMapSceneProxy.cpp @@ -151,7 +151,7 @@ void FStreetMapSceneProxy::MakeMeshBatch( FMeshBatch& Mesh, class FMeshElementCo // BatchElement.PrimitiveUniformBuffer = CreatePrimitiveUniformBufferImmediate(GetLocalToWorld(), GetBounds(), GetLocalBounds(), true, UseEditorDepthTest()); FDynamicPrimitiveUniformBuffer& DynamicPrimitiveUniformBuffer = Collector.AllocateOneFrameResource(); - DynamicPrimitiveUniformBuffer.Set(GetLocalToWorld(), GetLocalToWorld(), GetBounds(), GetLocalBounds(), true, false, UseEditorDepthTest()); + DynamicPrimitiveUniformBuffer.Set(GetLocalToWorld(), GetLocalToWorld(), GetBounds(), GetLocalBounds(), true, false, DrawsVelocity(), false); BatchElement.PrimitiveUniformBufferResource = &DynamicPrimitiveUniformBuffer.UniformBuffer; BatchElement.FirstIndex = 0;