diff --git a/Source/RuntimeMeshComponent/Private/RuntimeMesh.cpp b/Source/RuntimeMeshComponent/Private/RuntimeMesh.cpp index 66582dc..67c9d21 100644 --- a/Source/RuntimeMeshComponent/Private/RuntimeMesh.cpp +++ b/Source/RuntimeMeshComponent/Private/RuntimeMesh.cpp @@ -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 UpdateData = MakeShared(MoveTemp(MeshData)); diff --git a/Source/RuntimeMeshComponent/Private/RuntimeMeshProxy.cpp b/Source/RuntimeMeshComponent/Private/RuntimeMeshProxy.cpp index f6e2a22..6fe77f6 100644 --- a/Source/RuntimeMeshComponent/Private/RuntimeMeshProxy.cpp +++ b/Source/RuntimeMeshComponent/Private/RuntimeMeshProxy.cpp @@ -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) diff --git a/Source/RuntimeMeshComponent/Private/RuntimeMeshRendering.h b/Source/RuntimeMeshComponent/Private/RuntimeMeshRendering.h index 56a6e12..b867a9f 100644 --- a/Source/RuntimeMeshComponent/Private/RuntimeMeshRendering.h +++ b/Source/RuntimeMeshComponent/Private/RuntimeMeshRendering.h @@ -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()); } diff --git a/Source/RuntimeMeshComponent/Public/RuntimeMeshCollision.h b/Source/RuntimeMeshComponent/Public/RuntimeMeshCollision.h index 5c47426..fcd858d 100644 --- a/Source/RuntimeMeshComponent/Public/RuntimeMeshCollision.h +++ b/Source/RuntimeMeshComponent/Public/RuntimeMeshCollision.h @@ -18,7 +18,7 @@ struct RUNTIMEMESHCOMPONENT_API FRuntimeMeshCollisionConvexMesh GENERATED_BODY() public: - FRuntimeMeshCollisionConvexMesh() { } + FRuntimeMeshCollisionConvexMesh() : BoundingBox(ForceInit) { } FRuntimeMeshCollisionConvexMesh(const TArray& InVertexBuffer) : VertexBuffer(InVertexBuffer) , BoundingBox(InVertexBuffer) @@ -26,8 +26,8 @@ struct RUNTIMEMESHCOMPONENT_API FRuntimeMeshCollisionConvexMesh } FRuntimeMeshCollisionConvexMesh(TArray&& InVertexBuffer) : VertexBuffer(InVertexBuffer) + , BoundingBox(VertexBuffer) { - BoundingBox = FBox(VertexBuffer); } FRuntimeMeshCollisionConvexMesh(const TArray& InVertexBuffer, const FBox& InBoundingBox) : VertexBuffer(InVertexBuffer) @@ -36,8 +36,8 @@ struct RUNTIMEMESHCOMPONENT_API FRuntimeMeshCollisionConvexMesh } FRuntimeMeshCollisionConvexMesh(TArray&& InVertexBuffer, const FBox& InBoundingBox) : VertexBuffer(InVertexBuffer) + , BoundingBox(VertexBuffer) { - BoundingBox = FBox(VertexBuffer); } UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "RuntimeMesh|Collision|Convex")