Skip to content
This repository was archived by the owner on Jun 19, 2020. It is now read-only.

Commit 506a8d1

Browse files
author
Chris Conway
committed
Fixed a quick issue where one actor was rendering in game due to not being serialized, so it's now recreated in beginplay correctly.
1 parent f3b30ec commit 506a8d1

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Source/RMC_Examples/Actors/BasicRMCPackedVertexActor.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,29 @@ void ABasicRMCPackedVertexActor::CreateBoxMesh(const FVector& Size, TArray<FRunt
3030
}
3131
}
3232

33-
34-
void ABasicRMCPackedVertexActor::OnConstruction(const FTransform& Transform)
33+
void ABasicRMCPackedVertexActor::Generate()
3534
{
3635
TArray<FRuntimeMeshVertexSimple> Vertices;
3736
TArray<int32> Triangles;
38-
37+
3938
CreateBoxMesh(FVector(100, 100, 100), Vertices, Triangles);
4039

4140
// Create the mesh section (also enables collision, and sets the section update frequency to infrequent)
4241
RuntimeMesh->CreateMeshSection(0, Vertices, Triangles, true, EUpdateFrequency::Infrequent);
43-
}
42+
}
43+
44+
void ABasicRMCPackedVertexActor::BeginPlay()
45+
{
46+
// These types of sections can't be serialized currently.
47+
// So check if it was already created and if not create it now
48+
if (!RuntimeMesh->DoesSectionExist(0))
49+
{
50+
Generate();
51+
}
52+
}
53+
54+
void ABasicRMCPackedVertexActor::OnConstruction(const FTransform& Transform)
55+
{
56+
Generate();
57+
}
58+

Source/RMC_Examples/Actors/BasicRMCPackedVertexActor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ class RMC_EXAMPLES_API ABasicRMCPackedVertexActor : public ARuntimeMeshObjectBas
1515

1616
void OnConstruction(const FTransform& Transform) override;
1717

18+
// Called when the game starts or when spawned
19+
virtual void BeginPlay() override;
1820

1921
/* Helper to generate a box mesh and convert it to FRuntimeMeshVertexSimple */
2022
void CreateBoxMesh(const FVector& Size, TArray<FRuntimeMeshVertexSimple>& Vertices, TArray<int32>& Triangles);
2123

24+
void Generate();
2225

2326
};

0 commit comments

Comments
 (0)