Skip to content

Commit

Permalink
Fixed DX12 crash when creating empty sections
Browse files Browse the repository at this point in the history
Fixed automation warning of uninitialized FRuntimeMeshCollisionConvexMesh
Fixed bug in clearing sections.
  • Loading branch information
Koderz committed Aug 24, 2020
1 parent d307bbd commit b16613a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Source/RuntimeMeshComponent/Private/RuntimeMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ void URuntimeMesh::HandleSingleSectionUpdate(const FRuntimeMeshProxyPtr& RenderP
Properties.bWants32BitIndices);
bool bResult = MeshProviderPtr->GetSectionMeshForLOD(LODId, SectionId, MeshData);

if (bResult)
if (bResult && MeshData.HasValidMeshData())
{
// Update section
TSharedPtr<FRuntimeMeshSectionUpdateData> UpdateData = MakeShared<FRuntimeMeshSectionUpdateData>(MoveTemp(MeshData));
Expand Down
13 changes: 13 additions & 0 deletions Source/RuntimeMeshComponent/Private/RuntimeMeshProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,19 @@ void FRuntimeMeshProxy::ClearAllSectionsForLOD_RenderThread(int32 LODIndex)
RMC_LOG_VERBOSE("ClearAllSectionsForLOD_RenderThread: LOD:%d", LODIndex);
check(IsInRenderingThread());

if (LODs.IsValidIndex(LODIndex))
{
auto& LOD = LODs[LODIndex];
for (auto& SectionEntry : LOD.Sections)
{
ClearSection(SectionEntry.Value);
}
UpdateRenderState();
}
else
{
// Invalid LOD
}
}

void FRuntimeMeshProxy::RemoveAllSectionsForLOD_RenderThread(int32 LODIndex)
Expand Down
2 changes: 1 addition & 1 deletion Source/RuntimeMeshComponent/Private/RuntimeMeshRendering.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class FRuntimeMeshVertexBuffer : public FVertexBuffer
check(InVertexBufferRHI);

VertexBufferRHI = InVertexBufferRHI;
if (RHISupportsManualVertexFetch(GMaxRHIShaderPlatform))
if (VertexBufferRHI.IsValid() && RHISupportsManualVertexFetch(GMaxRHIShaderPlatform))
{
ShaderResourceView = RHICreateShaderResourceView(VertexBufferRHI, GetElementDatumSize(), GetElementFormat());
}
Expand Down
6 changes: 3 additions & 3 deletions Source/RuntimeMeshComponent/Public/RuntimeMeshCollision.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ struct RUNTIMEMESHCOMPONENT_API FRuntimeMeshCollisionConvexMesh
GENERATED_BODY()

public:
FRuntimeMeshCollisionConvexMesh() { }
FRuntimeMeshCollisionConvexMesh() : BoundingBox(ForceInit) { }
FRuntimeMeshCollisionConvexMesh(const TArray<FVector>& InVertexBuffer)
: VertexBuffer(InVertexBuffer)
, BoundingBox(InVertexBuffer)
{
}
FRuntimeMeshCollisionConvexMesh(TArray<FVector>&& InVertexBuffer)
: VertexBuffer(InVertexBuffer)
, BoundingBox(VertexBuffer)
{
BoundingBox = FBox(VertexBuffer);
}
FRuntimeMeshCollisionConvexMesh(const TArray<FVector>& InVertexBuffer, const FBox& InBoundingBox)
: VertexBuffer(InVertexBuffer)
Expand All @@ -36,8 +36,8 @@ struct RUNTIMEMESHCOMPONENT_API FRuntimeMeshCollisionConvexMesh
}
FRuntimeMeshCollisionConvexMesh(TArray<FVector>&& InVertexBuffer, const FBox& InBoundingBox)
: VertexBuffer(InVertexBuffer)
, BoundingBox(VertexBuffer)
{
BoundingBox = FBox(VertexBuffer);
}

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "RuntimeMesh|Collision|Convex")
Expand Down

0 comments on commit b16613a

Please sign in to comment.