Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakobzs committed Mar 6, 2024
2 parents fea6512 + c101027 commit bfddf20
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
37 changes: 37 additions & 0 deletions Source/glTFRuntime/Private/glTFRuntimeParserStaticMeshes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
#include "PhysicsEngine/BodySetup.h"
#include "Runtime/Launch/Resources/Version.h"
#include "StaticMeshResources.h"
#if ENGINE_MAJOR_VERSION >= 5
#if ENGINE_MINOR_VERSION < 2
#include "MeshCardRepresentation.h"
#else
#undef UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2
#define UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2 0
#include "MeshCardBuild.h"
#endif
#endif

FglTFRuntimeStaticMeshContext::FglTFRuntimeStaticMeshContext(TSharedRef<FglTFRuntimeParser> InParser, const FglTFRuntimeStaticMeshConfig& InStaticMeshConfig) :
Parser(InParser),
Expand Down Expand Up @@ -589,6 +598,34 @@ UStaticMesh* FglTFRuntimeParser::LoadStaticMesh_Internal(TSharedRef<FglTFRuntime

}
#endif

if (StaticMeshConfig.bBuildLumenCards)
{
#if ENGINE_MAJOR_VERSION >= 5
if (!LODResources.CardRepresentationData)
{
LODResources.CardRepresentationData = new FCardRepresentationData();
}

LODResources.CardRepresentationData->MeshCardsBuildData.Bounds = StaticMeshContext->BoundingBoxAndSphere.GetBox().ExpandBy(2);

for (int32 Index = 0; Index < 6; Index++)
{
FLumenCardBuildData CardBuildData;
CardBuildData.AxisAlignedDirectionIndex = Index;
CardBuildData.OBB.AxisZ = FVector3f(0, 0, 0);
CardBuildData.OBB.AxisZ[Index / 2] = Index & 1 ? 1.0f : -1.0f;
CardBuildData.OBB.AxisZ.FindBestAxisVectors(CardBuildData.OBB.AxisX, CardBuildData.OBB.AxisY);
CardBuildData.OBB.AxisX = FVector3f::CrossProduct(CardBuildData.OBB.AxisZ, CardBuildData.OBB.AxisY);
CardBuildData.OBB.AxisX.Normalize();

CardBuildData.OBB.Origin = FVector3f(LODResources.CardRepresentationData->MeshCardsBuildData.Bounds.GetCenter());
CardBuildData.OBB.Extent = CardBuildData.OBB.RotateLocalToCard(FVector3f(LODResources.CardRepresentationData->MeshCardsBuildData.Bounds.GetExtent())).GetAbs();

LODResources.CardRepresentationData->MeshCardsBuildData.CardBuildData.Add(CardBuildData);
}
#endif
}
}

OnPostCreatedStaticMesh.Broadcast(StaticMeshContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool UglTFRuntimeSkeletalMeshComponent::ContainsPhysicsTriMeshData(bool InUseAll
return false;
}

#if (ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION > 0) || (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 26)
#if ENGINE_MAJOR_VERSION >= 5 || (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 26)
return bEnablePerPolyCollision && CurrentSkeletalMeshAsset->GetEnablePerPolyCollision();
#else
return bEnablePerPolyCollision && CurrentSkeletalMeshAsset->bEnablePerPolyCollision;
Expand Down
4 changes: 4 additions & 0 deletions Source/glTFRuntime/Public/glTFRuntimeParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,9 @@ struct FglTFRuntimeStaticMeshConfig
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "glTFRuntime")
float LODScreenSizeMultiplier;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "glTFRuntime")
bool bBuildLumenCards;

template<typename T>
T* GetCustomConfig() const
{
Expand Down Expand Up @@ -734,6 +737,7 @@ struct FglTFRuntimeStaticMeshConfig
bGenerateStaticMeshDescription = false;
bBuildNavCollision = false;
LODScreenSizeMultiplier = 2;
bBuildLumenCards = false;
}
};

Expand Down

0 comments on commit bfddf20

Please sign in to comment.