From 435181da2d9ff063c061ba12013bfd9daabd997d Mon Sep 17 00:00:00 2001 From: Megafunk Date: Sat, 15 Oct 2022 04:04:36 -0600 Subject: [PATCH] 5.1 Port mostly done! Phew --- Config/DefaultEditor.ini | 3 + Config/DefaultEngine.ini | 5 +- .../Blueprints/BP_FirstPersonCharacter.uasset | 4 +- .../Experimental/MEC_NavMeshCrowd.uasset | 4 +- .../MEC_NiagaraVisualization.uasset | 4 +- .../MEC_NiagaraVisualization_Mesh.uasset | 4 +- .../Experimental/MEC_Projectile.uasset | 4 +- .../MEC_Projectile_BuiltInVisualizer.uasset | 4 +- .../ST_RandomNavMeshMovement.uasset | 4 +- .../Content/MassSample/Maps/GymBenchmark.umap | 2 +- .../MEC_MovingCubeActorRepresentation.uasset | 4 +- .../MassSample/Maps/MassSampleHall.umap | 4 +- .../MEC_CrowdMemberThatMoves.uasset | 4 +- .../MEC_MovableWithVisualization.uasset | 4 +- ...MassEntityConfigAsset_AgentObstacle.uasset | 4 +- ...onfigAsset_MassAgentTransformToMass.uasset | 4 +- .../ST_SampleZoneGraphStateTree.uasset | 4 +- .../Common/Fragments/MSHashGridFragments.h | 4 + .../Common/Misc/MSBPFunctionLibrary.cpp | 83 ++++--------------- .../Common/Misc/MSBPFunctionLibrary.h | 7 -- .../Common/Processors/MSHashGridProcessor.cpp | 3 + .../Common/Processors/MSHashGridProcessor.h | 2 + .../Common/Traits/MSMoverMassTrait.cpp | 2 +- .../Navigation/MSNavMeshMoveTask.cpp | 9 +- .../Source/MassCommunitySample/MSSubsystem.h | 1 + .../Traits/MSProjectileSimTrait.cpp | 4 +- .../Traits/MSNiagaraRepresentationTraits.cpp | 2 +- 27 files changed, 69 insertions(+), 114 deletions(-) diff --git a/Config/DefaultEditor.ini b/Config/DefaultEditor.ini index 407c16a..eb24d3a 100644 --- a/Config/DefaultEditor.ini +++ b/Config/DefaultEditor.ini @@ -11,3 +11,6 @@ bBlueprintIsNotBlueprintType= true RealtimeScreenPercentageMode=Manual NonRealtimeScreenPercentageMode=Manual +[/Script/AdvancedPreviewScene.SharedProfiles] + + diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index bceec7a..007d793 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -205,8 +205,11 @@ bUseManualIPAddress=False ManualIPAddress= [ConsoleVariables] +; This enables fully parallel mass processing +mass.FullyParallel=1 -mass.FullyParallel=False +; This is to avoid a bug in 5.1's cmc +p.CVarGeometryCollectionImpulseWorkAround=0 [CoreRedirects] +ClassRedirects=(OldName="/Script/MassSample.MSBPFunctionLibarary",NewName="/Script/MassSample.MSBPFunctionLibrary") diff --git a/Plugins/MassCommunitySample/Content/MassSample/Blueprints/BP_FirstPersonCharacter.uasset b/Plugins/MassCommunitySample/Content/MassSample/Blueprints/BP_FirstPersonCharacter.uasset index 7e86df5..a587c7a 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Blueprints/BP_FirstPersonCharacter.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/Blueprints/BP_FirstPersonCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:051377da7c23cb56602bc468909570f8f2d5d53211f69b373f656af44e34a27b -size 301297 +oid sha256:b1d931a1da01622778b3c74a4a6419708abd33b1ea5bf8ae1377b630b931db57 +size 305231 diff --git a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NavMeshCrowd.uasset b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NavMeshCrowd.uasset index 534eef2..7c00d59 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NavMeshCrowd.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NavMeshCrowd.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5cfea29296cce5e944a143c4740fdaddac81cf5d11a9f7ac8f6207f0bb3ce144 -size 6830 +oid sha256:5642a560e2452237d31d26bc8618f668884dabdb472fd294c1a05b9db4492754 +size 7209 diff --git a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NiagaraVisualization.uasset b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NiagaraVisualization.uasset index 351b2cc..02c96e7 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NiagaraVisualization.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NiagaraVisualization.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3e663646162720f23dfadf725dc5f61f4e3735dbdd379cc8b5ce5cd0c9542212 -size 2267 +oid sha256:20af5449ff297df45c4e7dc8f83ea8c99e45218ab97d781d0ad95f179de52f2c +size 2765 diff --git a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NiagaraVisualization_Mesh.uasset b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NiagaraVisualization_Mesh.uasset index 38a7317..66c2728 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NiagaraVisualization_Mesh.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_NiagaraVisualization_Mesh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f479e8a159fed8e11255c33018a64b8f98e19974a21a84c29a0b64be05227767 -size 2288 +oid sha256:73ea10a54a84b4b285d550a2cc181691784d070f32463c6b5134314cdcb6bee4 +size 2786 diff --git a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_Projectile.uasset b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_Projectile.uasset index ffb91c6..36ce17c 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_Projectile.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_Projectile.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:023898b4a9fa3e71d590ec868deeab295ea176c40a2c3c877f6e32ef41d2da4a -size 2595 +oid sha256:f0970b4e5e0856d1ee9b35cf64f778e130fdd0cefdc08d74dcd06d96cabb96da +size 3176 diff --git a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_Projectile_BuiltInVisualizer.uasset b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_Projectile_BuiltInVisualizer.uasset index 3ac2f6e..4c45b2d 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_Projectile_BuiltInVisualizer.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/Experimental/MEC_Projectile_BuiltInVisualizer.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:225829d330d9d1a628cd91e03f80cc9105cd6a16a0689e925901aff9b1eee700 -size 2503 +oid sha256:8bbb07847f29dfd1bb18c923be9c3f1ead335b20f673efc1687ff6047ec79428 +size 3160 diff --git a/Plugins/MassCommunitySample/Content/MassSample/Experimental/ST_RandomNavMeshMovement.uasset b/Plugins/MassCommunitySample/Content/MassSample/Experimental/ST_RandomNavMeshMovement.uasset index a57c68c..a1781bc 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Experimental/ST_RandomNavMeshMovement.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/Experimental/ST_RandomNavMeshMovement.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c62af90e5cc8f0e804191ac052f7083b8fdf8480b3045e4a3babce3e6f53d517 -size 15009 +oid sha256:2000b62864e9136b0d21766589627e24a6703bfec627d089e3dde9e51b3adb20 +size 15823 diff --git a/Plugins/MassCommunitySample/Content/MassSample/Maps/GymBenchmark.umap b/Plugins/MassCommunitySample/Content/MassSample/Maps/GymBenchmark.umap index a6532dc..0034261 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Maps/GymBenchmark.umap +++ b/Plugins/MassCommunitySample/Content/MassSample/Maps/GymBenchmark.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1f78ffba2a49a31d050bf17dcee61d515df176949d0a1af61ced1f8c3f911b7c +oid sha256:3f1a0782818ae36dde32b74a3e9a0ed52ae48f699ff1dfe558ad142a4d5fe364 size 64934 diff --git a/Plugins/MassCommunitySample/Content/MassSample/Maps/MapAssets/MEC_MovingCubeActorRepresentation.uasset b/Plugins/MassCommunitySample/Content/MassSample/Maps/MapAssets/MEC_MovingCubeActorRepresentation.uasset index 659685b..10fa1ab 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Maps/MapAssets/MEC_MovingCubeActorRepresentation.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/Maps/MapAssets/MEC_MovingCubeActorRepresentation.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:89d3e1dede0fa417149d000a8c135ec2234274df8c103284870eba41502432e5 -size 4359 +oid sha256:c2da0b0bb466fd6f4e3875851d4387adc69cdce292c7568ce8e866a74561f55f +size 6271 diff --git a/Plugins/MassCommunitySample/Content/MassSample/Maps/MassSampleHall.umap b/Plugins/MassCommunitySample/Content/MassSample/Maps/MassSampleHall.umap index 9629654..bb9cfb9 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/Maps/MassSampleHall.umap +++ b/Plugins/MassCommunitySample/Content/MassSample/Maps/MassSampleHall.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:996f0a28f851c2eb579de14ab7e8aef52de83089a169eedacc45c55b417d139a -size 252960 +oid sha256:5cc35abfa333a8a0eddcd8bc17cfa88abbea025c6fabb69f5127b796aff3feb7 +size 259235 diff --git a/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MEC_CrowdMemberThatMoves.uasset b/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MEC_CrowdMemberThatMoves.uasset index b5e6d2b..737a53c 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MEC_CrowdMemberThatMoves.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MEC_CrowdMemberThatMoves.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4511ec78c664c2606337569c525c9cc5379245f1919e71402aa511f915ddda87 -size 7321 +oid sha256:86744b54ed7f82658f0afda13e85029369af91615643e6f739fecec377d41613 +size 7952 diff --git a/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MEC_MovableWithVisualization.uasset b/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MEC_MovableWithVisualization.uasset index 43ea440..f117f2f 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MEC_MovableWithVisualization.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MEC_MovableWithVisualization.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:da8db59ec05cf7cd62ae1d9ae4e69c92aa76911f28098add550f8079c34c94e6 -size 2231 +oid sha256:6ebe51e8fb0d0095abfb7b96ceb5c78ff7da0a4608897354d76785e361aa4f4a +size 2721 diff --git a/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MassEntityConfigAsset_AgentObstacle.uasset b/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MassEntityConfigAsset_AgentObstacle.uasset index d946630..9cef3a1 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MassEntityConfigAsset_AgentObstacle.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MassEntityConfigAsset_AgentObstacle.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5321bf72c3d924e7b0288fde34828f7d521147c0856c6b437453e187da946e08 -size 2931 +oid sha256:62ac79d4ca8d3bec1d893f25b9b30d5fb8344747097a89c24fd6c46e51ce7254 +size 3086 diff --git a/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MassEntityConfigAsset_MassAgentTransformToMass.uasset b/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MassEntityConfigAsset_MassAgentTransformToMass.uasset index 3c029f0..583acb0 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MassEntityConfigAsset_MassAgentTransformToMass.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/MassConfigs/MassEntityConfigAsset_MassAgentTransformToMass.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:36ce4f95b22966b9318dd5e4e876a50423e8f46cf5d753b49b0104ed9aefffc7 -size 2986 +oid sha256:c75acefea1b9f0c0934745be8d569ea442fd52532376fe8a8d5983920337cc9d +size 3141 diff --git a/Plugins/MassCommunitySample/Content/MassSample/ST_SampleZoneGraphStateTree.uasset b/Plugins/MassCommunitySample/Content/MassSample/ST_SampleZoneGraphStateTree.uasset index 090a18d..4bd9bce 100644 --- a/Plugins/MassCommunitySample/Content/MassSample/ST_SampleZoneGraphStateTree.uasset +++ b/Plugins/MassCommunitySample/Content/MassSample/ST_SampleZoneGraphStateTree.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:34c86382077bf363bf10866a04df1123d936a8542c9e63752a086455114a79df -size 15799 +oid sha256:26c4a5b724a18f7c52271c769d2f363fa1950867c16064e865419030bdfdaa07 +size 16215 diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Fragments/MSHashGridFragments.h b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Fragments/MSHashGridFragments.h index c06aa8b..8725cae 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Fragments/MSHashGridFragments.h +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Fragments/MSHashGridFragments.h @@ -5,12 +5,16 @@ #include "CoreMinimal.h" #include "MassEntityTypes.h" #include "MassNavigationSubsystem.h" +#include "Chaos/SpatialHash.h" #include "Spatial/PointHashGrid3.h" #include "MSHashGridFragments.generated.h" // FIXMEFUNK: Less weird place to stuff this? some types thing? oh well... typedef UE::Geometry::TPointHashGrid3 FMSHashGrid3D; +// +//typedef Chaos::TSpatialHash FMSSpatialHash; + // This entity's start location on our 2D hashgrid this frame USTRUCT() struct MASSCOMMUNITYSAMPLE_API FMSGridCellStartingLocationFragment : public FMassFragment diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Misc/MSBPFunctionLibrary.cpp b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Misc/MSBPFunctionLibrary.cpp index 7fabb0c..701c41a 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Misc/MSBPFunctionLibrary.cpp +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Misc/MSBPFunctionLibrary.cpp @@ -54,66 +54,6 @@ FEntityHandleWrapper UMSBPFunctionLibrary::SpawnEntityFromEntityConfig(UMassEnti FEntityHandleWrapper UMSBPFunctionLibrary::SpawnEntityFromEntityConfigDeferred( AActor* Owner, UMassEntityConfigAsset* MassEntityConfig, const UObject* WorldContextObject) -{ - // FMassExecutionContext ExecutionContext(WorldContextObject->GetWorld()->DeltaTimeSeconds); - FMassExecutionContext ExecutionContext; - - ExecutionContext.SetDeferredCommandBuffer(MakeShareable(new FMassCommandBuffer())); - - - if (!Owner || !MassEntityConfig) return FEntityHandleWrapper(); - - const FMassEntityTemplate& EntityTemplate = MassEntityConfig->GetConfig().GetOrCreateEntityTemplate( - *WorldContextObject->GetWorld(), *MassEntityConfig); - - FMassEntityManager& EntitySubSystem = WorldContextObject->GetWorld()->GetSubsystem()-> - GetMutableEntityManager(); - - //const FMassEntityHandle ReservedEntity = EntitySubSystem.ReserveEntity(); - - - //todo: this is very slow! I am just doing this to be able to stuff configs in here for now - TArray FragmentTypesList; - EntityTemplate.GetCompositionDescriptor().Fragments.ExportTypes(FragmentTypesList); - TArray TagsTypeList; - - EntityTemplate.GetCompositionDescriptor().Tags.ExportTypes(TagsTypeList); - - TArray InstanceStructs = TArray(FragmentTypesList); - - TConstArrayView InitialFragmentInstances = EntityTemplate.GetInitialFragmentValues(); - - // InstanceStructs need to have the InitialFragmentInstances data-filled instanced structs, all of which already exist inside of InstanceStructs - - for (auto InitialFragmentInstance : InitialFragmentInstances) - { - int32 index = InstanceStructs.IndexOfByPredicate([&](const FInstancedStruct InstancedStructValue) - { - return InstancedStructValue.GetScriptStruct() == InitialFragmentInstance.GetScriptStruct(); - }); - if (index != INDEX_NONE) - InstanceStructs[index] = InitialFragmentInstance; - } - - // ExecutionContext.Defer().PushCommand( - // FBuildEntityFromFragmentInstancesAndTags(ReservedEntity, - // InstanceStructs, - // TagsTypeList, - // EntityTemplate.GetSharedFragmentValues())); - - - ExecutionContext.FlushDeferred(); - //EntitySubSystem->FlushCommands(MakeShareable(new FMassCommandBuffer())); - //return FEntityHandleWrapper{ReservedEntity}; - - - return FEntityHandleWrapper(); -} - - -FEntityHandleWrapper UMSBPFunctionLibrary::SpawnEntityFromEntityConfigDeferredBugRepro( - AActor* Owner, UMassEntityConfigAsset* MassEntityConfig, - const UObject* WorldContextObject) { if (!Owner || !MassEntityConfig) return FEntityHandleWrapper(); @@ -123,7 +63,6 @@ FEntityHandleWrapper UMSBPFunctionLibrary::SpawnEntityFromEntityConfigDeferredBu FMassEntityManager& EntityManager = WorldContextObject->GetWorld()->GetSubsystem()-> GetMutableEntityManager(); - const FMassEntityHandle ReservedEntity = EntityManager.ReserveEntity(); //todo: this is very slow! I am just doing this to be able to stuff configs in here for now @@ -153,16 +92,30 @@ FEntityHandleWrapper UMSBPFunctionLibrary::SpawnEntityFromEntityConfigDeferredBu // Copy a new composition descriptor because it gets changed in the addcomposition call FMassArchetypeCompositionDescriptor CompositionDescriptor = EntityTemplate.GetCompositionDescriptor(); + // Reserve an entity + const FMassEntityHandle ReservedEntity = EntityManager.ReserveEntity(); + // We are using a lambda here because we don't have a deferred command that can do EntityManager.Defer().PushCommand([&](FMassEntityManager& System) { - System.BuildEntity(ReservedEntity,InstanceStructs,EntityTemplate.GetSharedFragmentValues()); - System.AddCompositionToEntity_GetDelta(ReservedEntity,CompositionDescriptor); + EntityManager.BuildEntity(ReservedEntity,InstanceStructs,EntityTemplate.GetSharedFragmentValues()); + EntityManager.AddCompositionToEntity_GetDelta(ReservedEntity,CompositionDescriptor); }); - - // Immediately flush? Doesn't seem too bad here but I imagine we could do this in a nicer way?s + + // Immediately flush? Doesn't seem too bad here but I imagine we could do this in a nicer way? EntityManager.FlushCommands(); + // trigger observers manually for now as I'm too lazy to use the batch add for now + if (EntityManager.GetObserverManager().HasObserversForBitSet(EntityTemplate.GetCompositionDescriptor().Fragments, EMassObservedOperation::Add)) + { + + EntityManager.GetObserverManager().OnCompositionChanged( + FMassArchetypeEntityCollection(EntityTemplate.GetArchetype(), {ReservedEntity},FMassArchetypeEntityCollection::NoDuplicates) + , EntityTemplate.GetCompositionDescriptor() + , EMassObservedOperation::Add); + } + + return FEntityHandleWrapper{ReservedEntity}; } diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Misc/MSBPFunctionLibrary.h b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Misc/MSBPFunctionLibrary.h index 6ea4566..e0c4991 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Misc/MSBPFunctionLibrary.h +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Misc/MSBPFunctionLibrary.h @@ -44,17 +44,10 @@ class MASSCOMMUNITYSAMPLE_API UMSBPFunctionLibrary : public UBlueprintFunctionLi static FEntityHandleWrapper SpawnEntityFromEntityConfig(UMassEntityConfigAsset* MassEntityConfig, const UObject* WorldContextObject, const bool bDebug = false); - // todo: broken and hardcoded for testing, Don't use this yet! UFUNCTION(BlueprintCallable, Category = "Mass", meta = (WorldContext = "WorldContextObject")) static FEntityHandleWrapper SpawnEntityFromEntityConfigDeferred(AActor* Owner, UMassEntityConfigAsset* MassEntityConfig, const UObject* WorldContextObject); - // todo: also broken and hardcoded for testing, Don't use this yet! - UFUNCTION(BlueprintCallable, Category = "Mass", meta = (WorldContext = "WorldContextObject")) - static FEntityHandleWrapper SpawnEntityFromEntityConfigDeferredBugRepro(AActor* Owner, - UMassEntityConfigAsset* MassEntityConfig, - const UObject* WorldContextObject); - //todo: Lazy fragment-specific versions until we can think of something nicer UFUNCTION(BlueprintCallable, Category = "Mass", meta = (WorldContext = "WorldContextObject")) static void SetEntityTransform(const FEntityHandleWrapper EntityHandle,const FTransform Transform, const UObject* WorldContextObject); diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Processors/MSHashGridProcessor.cpp b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Processors/MSHashGridProcessor.cpp index b189d7a..e23d762 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Processors/MSHashGridProcessor.cpp +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Processors/MSHashGridProcessor.cpp @@ -10,6 +10,8 @@ UMSHashGridProcessor::UMSHashGridProcessor() { ExecutionOrder.ExecuteAfter.Add(UE::Mass::ProcessorGroupNames::Movement); + // In theory it should be thread save but I'm seeing wackiness so I'm slapping on singlethreaded for now + bRequiresGameThreadExecution = true; ExecutionFlags = (int32)EProcessorExecutionFlags::All; } @@ -49,6 +51,7 @@ void UMSHashGridProcessor::Execute(FMassEntityManager& EntitySubsystem, FMassExe UMSHashGridMemberInitializationProcessor::UMSHashGridMemberInitializationProcessor() { ObservedType = FMSGridCellStartingLocationFragment::StaticStruct(); + bRequiresGameThreadExecution = true; Operation = EMassObservedOperation::Add; } diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Processors/MSHashGridProcessor.h b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Processors/MSHashGridProcessor.h index f3393c8..f942ca7 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Processors/MSHashGridProcessor.h +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Processors/MSHashGridProcessor.h @@ -28,6 +28,8 @@ class MASSCOMMUNITYSAMPLE_API UMSHashGridProcessor : public UMassProcessor FMassEntityQuery AddToHashGridQuery; FMassEntityQuery UpdateHashGridQuery; FMassEntityQuery RemoveFromGridEntityQuery; + + UPROPERTY() UMSSubsystem* MassSampleSystem; virtual void Initialize(UObject& Owner) override; diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Traits/MSMoverMassTrait.cpp b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Traits/MSMoverMassTrait.cpp index 65b4c45..ac95b2b 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Traits/MSMoverMassTrait.cpp +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/Common/Traits/MSMoverMassTrait.cpp @@ -11,6 +11,6 @@ void UMSMoverMassTrait::BuildTemplate(FMassEntityTemplateBuildContext& BuildContext, const UWorld& World) const { BuildContext.AddTag(); - BuildContext.AddFragment(); + BuildContext.RequireFragment(); BuildContext.AddFragment_GetRef().Value = Force; } diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/Experimental/Navigation/MSNavMeshMoveTask.cpp b/Plugins/MassCommunitySample/Source/MassCommunitySample/Experimental/Navigation/MSNavMeshMoveTask.cpp index e223062..8969831 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/Experimental/Navigation/MSNavMeshMoveTask.cpp +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/Experimental/Navigation/MSNavMeshMoveTask.cpp @@ -22,7 +22,6 @@ EStateTreeRunStatus FMassNavMeshPathFollowTask::Tick(FStateTreeExecutionContext& { FMassStateTreeExecutionContext& MassContext = static_cast(Context); - const UMSSubsystem& MSSubsystem = Context.GetExternalData(MSSubsystemHandle); const FAgentRadiusFragment& AgentRadius = Context.GetExternalData(AgentRadiusHandle); FMassMoveTargetFragment& MoveTarget = Context.GetExternalData(MoveTargetHandle); FMassNavMeshPathFollowTaskInstanceData& InstanceData = Context.GetInstanceData< @@ -34,13 +33,7 @@ EStateTreeRunStatus FMassNavMeshPathFollowTask::Tick(FStateTreeExecutionContext& const FMassMovementParameters& MovementParams = Context.GetExternalData(MovementParamsHandle); const FVector AgentNavLocation = Context.GetExternalData(TransformHandle).GetTransform().GetLocation(); - - // const FMassMovementStyleRef MovementStyle = Context.GetInstanceData(MovementStyleHandle); - // - // const FVector TargetLocation = Context.GetInstanceData(TargetLocationHandle); - // const float SpeedScale = Context.GetInstanceData(SpeedScaleHandle); - - + auto NavMeshSubsystem = Cast(Context.GetWorld()->GetNavigationSystem()); diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/MSSubsystem.h b/Plugins/MassCommunitySample/Source/MassCommunitySample/MSSubsystem.h index a088e9c..feca3b9 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/MSSubsystem.h +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/MSSubsystem.h @@ -22,6 +22,7 @@ class MASSCOMMUNITYSAMPLE_API UMSSubsystem : public UWorldSubsystem FMassArchetypeHandle MoverArchetype; + //FMSSpatialHash SpatialHashGrid; FMSHashGrid3D HashGrid = FMSHashGrid3D(100.0f,FMassEntityHandle()); UPROPERTY() diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/ProjectileSim/Traits/MSProjectileSimTrait.cpp b/Plugins/MassCommunitySample/Source/MassCommunitySample/ProjectileSim/Traits/MSProjectileSimTrait.cpp index 2297e97..650c353 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/ProjectileSim/Traits/MSProjectileSimTrait.cpp +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/ProjectileSim/Traits/MSProjectileSimTrait.cpp @@ -11,8 +11,8 @@ void UMSProjectileSimTrait::BuildTemplate(FMassEntityTemplateBuildContext& BuildContext, const UWorld& World) const { BuildContext.AddFragment(); - BuildContext.AddFragment(); - BuildContext.AddFragment(); + BuildContext.RequireFragment(); + BuildContext.RequireFragment(); BuildContext.AddTag(); if (bFiresHitEventToActors) diff --git a/Plugins/MassCommunitySample/Source/MassCommunitySample/Representation/Traits/MSNiagaraRepresentationTraits.cpp b/Plugins/MassCommunitySample/Source/MassCommunitySample/Representation/Traits/MSNiagaraRepresentationTraits.cpp index 1acec97..ff87824 100644 --- a/Plugins/MassCommunitySample/Source/MassCommunitySample/Representation/Traits/MSNiagaraRepresentationTraits.cpp +++ b/Plugins/MassCommunitySample/Source/MassCommunitySample/Representation/Traits/MSNiagaraRepresentationTraits.cpp @@ -11,7 +11,7 @@ void UMSNiagaraRepresentationTrait::BuildTemplate(FMassEntityTemplateBuildContex { UMSNiagaraSubsystem* ProjectileSubsystem = UWorld::GetSubsystem(&World); - BuildContext.AddFragment(); + BuildContext.RequireFragment(); FSharedStruct SharedFragment = ProjectileSubsystem->GetOrCreateSharedNiagaraFragmentForSystemType( SharedNiagaraSystem);