Skip to content

Commit 357bdc6

Browse files
author
Chris Conway
committed
Maintenance pass...
Updated plugin information. Added icon to plugin. Removed unnecessary RuntimeMeshAsync.cpp file Added pre-processor checks to handle UE4.12 Updated for deprecated functions in UE4.14
1 parent 16f7fda commit 357bdc6

File tree

7 files changed

+55
-28
lines changed

7 files changed

+55
-28
lines changed

Resources/Icon128.png

5.46 KB
Loading

RuntimeMeshComponent.uplugin

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"FileVersion": 3,
3-
"Version": 1,
4-
"VersionName": "1.3",
3+
"Version": 2,
4+
"VersionName": "2.0",
55
"FriendlyName": "Runtime Mesh Component",
66
"Description": "A renderable component with utilities for creating and modifying mesh geometry procedurally at runtime.",
77
"Category": "Rendering",
88
"CreatedBy" : "Chris Conway (Koderz)",
9-
"CreatedByURL" : "https://answers.unrealengine.com/users/29368/koderz.html",
9+
"CreatedByURL" : "https://forums.unrealengine.com/member.php?141752-Koderz",
1010
"DocsURL": "https://github.com/Koderz/UE4RuntimeMeshComponent/wiki",
11-
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/offers/ad0b45a6a31e462aba7cf7c790a9c125",
11+
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/ad0b45a6a31e462aba7cf7c790a9c125",
1212
"SupportURL": "https://github.com/Koderz/UE4RuntimeMeshComponent/issues",
1313
"EnabledByDefault": true,
1414
"CanContainContent": false,

Source/RuntimeMeshComponent/Private/RuntimeMeshAsync.cpp

Lines changed: 0 additions & 5 deletions
This file was deleted.

Source/RuntimeMeshComponent/Private/RuntimeMeshComponent.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,14 @@ class FRuntimeMeshSceneProxy : public FPrimitiveSceneProxy
330330
{
331331
if (VisibilityMap & (1 << ViewIndex))
332332
{
333+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13
333334
// Draw simple collision as wireframe if 'show collision', and collision is enabled, and we are not using the complex as the simple
334335
if (ViewFamily.EngineShowFlags.Collision && IsCollisionEnabled() && BodySetup->GetCollisionTraceFlag() != ECollisionTraceFlag::CTF_UseComplexAsSimple)
335336
{
336337
FTransform GeomTransform(GetLocalToWorld());
337338
BodySetup->AggGeom.GetAggGeom(GeomTransform, GetSelectionColor(FColor(157, 149, 223, 255), IsSelected(), IsHovered()).ToFColor(true), NULL, false, false, UseEditorDepthTest(), ViewIndex, Collector);
338339
}
340+
#endif
339341

340342
// Render bounds
341343
RenderBounds(Collector.GetPDI(ViewIndex), ViewFamily.EngineShowFlags, GetBounds(), IsSelected());
@@ -1558,12 +1560,14 @@ bool URuntimeMeshComponent::GetPhysicsTriMeshData(struct FTriMeshCollisionData*
15581560

15591561
bool HadCollision = false;
15601562

1563+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13
15611564
// See if we should copy UVs
15621565
bool bCopyUVs = UPhysicsSettings::Get()->bSupportUVFromHitResults;
15631566
if (bCopyUVs)
15641567
{
15651568
CollisionData->UVs.AddZeroed(1); // only one UV channel
15661569
}
1570+
#endif
15671571

15681572
// For each section..
15691573
for (int32 SectionIdx = 0; SectionIdx < MeshSections.Num(); SectionIdx++)
@@ -1573,7 +1577,11 @@ bool URuntimeMeshComponent::GetPhysicsTriMeshData(struct FTriMeshCollisionData*
15731577
if (Section.IsValid() && Section->CollisionEnabled)
15741578
{
15751579
// Copy vertex data
1580+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13
15761581
Section->GetCollisionInformation(CollisionData->Vertices, CollisionData->UVs, bCopyUVs);
1582+
#else
1583+
Section->GetCollisionInformation(CollisionData->Vertices);
1584+
#endif
15771585

15781586
// Copy indices
15791587
const int32 NumTriangles = Section->IndexBuffer.Num() / 3;
@@ -1747,8 +1755,14 @@ void URuntimeMeshComponent::UpdateNavigation()
17471755
if (UNavigationSystem::ShouldUpdateNavOctreeOnComponentChange() && IsRegistered())
17481756
{
17491757
UWorld* MyWorld = GetWorld();
1758+
1759+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13
17501760
if (MyWorld != nullptr && MyWorld->GetNavigationSystem() != nullptr &&
17511761
(MyWorld->GetNavigationSystem()->ShouldAllowClientSideNavigation() || !MyWorld->IsNetMode(ENetMode::NM_Client)))
1762+
#else
1763+
1764+
if (MyWorld != nullptr && MyWorld->IsGameWorld() && MyWorld->GetNetMode() < ENetMode::NM_Client)
1765+
#endif
17521766
{
17531767
UNavigationSystem::UpdateComponentInNavOctree(*this);
17541768
}

Source/RuntimeMeshComponent/Private/RuntimeMeshLibrary.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,23 +467,33 @@ void URuntimeMeshLibrary::GetSectionFromStaticMesh(UStaticMesh* InMesh, int32 LO
467467
void URuntimeMeshLibrary::CopyRuntimeMeshFromStaticMeshComponent(UStaticMeshComponent* StaticMeshComp, int32 LODIndex,
468468
URuntimeMeshComponent* RuntimeMeshComp, bool bShouldCreateCollision)
469469
{
470-
if (StaticMeshComp != nullptr && StaticMeshComp->StaticMesh != nullptr && RuntimeMeshComp != nullptr)
471-
{
472-
UStaticMesh* StaticMesh = StaticMeshComp->StaticMesh;
470+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 14
471+
UStaticMesh* StaticMesh = StaticMeshComp->GetStaticMesh();
472+
#else
473+
UStaticMesh* StaticMesh = StaticMeshComp->StaticMesh;
474+
#endif
473475

476+
if (StaticMeshComp != nullptr && StaticMesh != nullptr && RuntimeMeshComp != nullptr)
477+
{
474478
//// MESH DATA
475479

476480
// Make sure LOD index is valid
477481
if (StaticMesh->RenderData == nullptr || !StaticMesh->RenderData->LODResources.IsValidIndex(LODIndex))
478482
{
479483
return;
480484
}
481-
485+
486+
// Get specified LOD
487+
const FStaticMeshLODResources& LOD = StaticMesh->RenderData->LODResources[LODIndex];
488+
489+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13
482490
int32 NumSections = StaticMesh->GetNumSections(LODIndex);
491+
#else
492+
int32 NumSections = LOD.Sections.Num();
493+
#endif
483494
for (int32 SectionIndex = 0; SectionIndex < NumSections; SectionIndex++)
484495
{
485496
// Buffers for copying geom data
486-
const FStaticMeshLODResources& LOD = StaticMesh->RenderData->LODResources[LODIndex];
487497
if (LOD.Sections.IsValidIndex(SectionIndex))
488498
{
489499
int32 NumUVChannels = LOD.GetNumTexCoords();

Source/RuntimeMeshComponent/Public/RuntimeMeshCore.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,6 @@ struct FRuntimeMeshVertexTraits
121121
};
122122

123123

124-
CONSTEXPR static int32 CalculateNumUVChannels()
125-
{
126-
return
127-
(HasUV0 ? 1 : 0) +
128-
(HasUV1 ? 1 : 0) +
129-
(HasUV2 ? 1 : 0) +
130-
(HasUV3 ? 1 : 0) +
131-
(HasUV4 ? 1 : 0) +
132-
(HasUV5 ? 1 : 0) +
133-
(HasUV6 ? 1 : 0) +
134-
(HasUV7 ? 1 : 0);
135-
}
136-
137124
public:
138125
static const bool HasPosition = sizeof(PositionCheck<DerivedPosition>(0)) == 2;
139126
static const bool HasNormal = sizeof(NormalCheck<DerivedNormal>(0)) == 2;
@@ -147,7 +134,15 @@ struct FRuntimeMeshVertexTraits
147134
static const bool HasUV5 = sizeof(UV5Check<DerivedUV5>(0)) == 2;
148135
static const bool HasUV6 = sizeof(UV6Check<DerivedUV6>(0)) == 2;
149136
static const bool HasUV7 = sizeof(UV7Check<DerivedUV7>(0)) == 2;
150-
static const int32 NumUVChannels = CalculateNumUVChannels();
137+
static const int32 NumUVChannels =
138+
(HasUV0 ? 1 : 0) +
139+
(HasUV1 ? 1 : 0) +
140+
(HasUV2 ? 1 : 0) +
141+
(HasUV3 ? 1 : 0) +
142+
(HasUV4 ? 1 : 0) +
143+
(HasUV5 ? 1 : 0) +
144+
(HasUV6 ? 1 : 0) +
145+
(HasUV7 ? 1 : 0);
151146

152147

153148

Source/RuntimeMeshComponent/Public/RuntimeMeshSection.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ class FRuntimeMeshSectionInterface
152152

153153
virtual void RecalculateBoundingBox() = 0;
154154

155+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13
155156
virtual int32 GetCollisionInformation(TArray<FVector>& Positions, TArray<TArray<FVector2D>>& UVs, bool bIncludeUVs) = 0;
157+
#else
158+
virtual int32 GetCollisionInformation(TArray<FVector>& Positions) = 0;
159+
#endif
156160

157161
virtual void GetInternalVertexComponents(int32& NumUVChannels, bool& WantsHalfPrecisionUVs) { }
158162

@@ -428,25 +432,34 @@ class FRuntimeMeshSection : public FRuntimeMeshSectionInterface
428432
return UpdateData;
429433
}
430434

435+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13
431436
virtual int32 GetCollisionInformation(TArray<FVector>& Positions, TArray<TArray<FVector2D>>& UVs, bool bIncludeUVs) override
437+
#else
438+
virtual int32 GetCollisionInformation(TArray<FVector>& Positions) override
439+
#endif
432440
{
433441
FRuntimeMeshPackedVerticesBuilder<VertexType> VerticesBuilder(&VertexBuffer, bNeedsPositionOnlyBuffer ? &PositionVertexBuffer : nullptr);
434442

435443
int32 PositionStart = Positions.Num();
436444
Positions.SetNum(PositionStart + VerticesBuilder.Length());
437445

446+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13
438447
if (bIncludeUVs)
439448
{
440449
UVs[0].SetNumZeroed(PositionStart + VerticesBuilder.Length());
441450
}
451+
#endif
442452

443453
for (int VertexIdx = 0; VertexIdx < VerticesBuilder.Length(); VertexIdx++)
444454
{
445455
Positions[PositionStart + VertexIdx] = VerticesBuilder.GetPosition(VertexIdx);
456+
457+
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 13
446458
if (bIncludeUVs && VerticesBuilder.HasUVComponent(0))
447459
{
448460
UVs[0][PositionStart + VertexIdx] = VerticesBuilder.GetUV(0);
449461
}
462+
#endif
450463
}
451464

452465
return VerticesBuilder.Length();

0 commit comments

Comments
 (0)