Skip to content

Commit

Permalink
The big motion controller conversion + more
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua committed Mar 26, 2024
1 parent d246d34 commit 801433c
Show file tree
Hide file tree
Showing 8 changed files with 475 additions and 61 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "GripScripts/VRGripScriptBase.h"
#include "PhysicsEngine/PhysicsAsset.h" // Tmp until epic bug fixes skeletal welding
#include "Net/UnrealNetwork.h"
#if WITH_PUSH_MODEL
#include "Net/Core/PushModel/PushModel.h"
#endif

//=============================================================================
UGrippableSkeletalMeshComponent::UGrippableSkeletalMeshComponent(const FObjectInitializer& ObjectInitializer)
Expand Down Expand Up @@ -44,12 +47,19 @@ void UGrippableSkeletalMeshComponent::GetLifetimeReplicatedProps(TArray< class F
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);

DOREPLIFETIME_CONDITION(UGrippableSkeletalMeshComponent, GripLogicScripts, COND_Custom);
DOREPLIFETIME(UGrippableSkeletalMeshComponent, bReplicateGripScripts);
DOREPLIFETIME(UGrippableSkeletalMeshComponent, bRepGripSettingsAndGameplayTags);
DOREPLIFETIME(UGrippableSkeletalMeshComponent, bReplicateMovement);
DOREPLIFETIME_CONDITION(UGrippableSkeletalMeshComponent, VRGripInterfaceSettings, COND_Custom);
DOREPLIFETIME_CONDITION(UGrippableSkeletalMeshComponent, GameplayTags, COND_Custom);
// For std properties
FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true };

DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, bReplicateGripScripts, PushModelParams);
DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, bRepGripSettingsAndGameplayTags, PushModelParams);
DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, bReplicateMovement, PushModelParams);

// For properties with special conditions
FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true };

DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, GripLogicScripts, PushModelParamsWithCondition);
DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, VRGripInterfaceSettings, PushModelParamsWithCondition);
DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableSkeletalMeshComponent, GameplayTags, PushModelParamsWithCondition);
}

void UGrippableSkeletalMeshComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker)
Expand Down Expand Up @@ -389,4 +399,72 @@ FBodyInstance* UGrippableSkeletalMeshComponent::GetBodyInstance(FName BoneName,
}

return BodyInst;
}
}

/////////////////////////////////////////////////
//- Push networking getter / setter functions
/////////////////////////////////////////////////

void UGrippableSkeletalMeshComponent::SetReplicateGripScripts(bool bNewReplicateGripScripts)
{
bReplicateGripScripts = bNewReplicateGripScripts;
#if WITH_PUSH_MODEL
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, bReplicateGripScripts, this);
#endif
}

TArray<TObjectPtr<UVRGripScriptBase>>& UGrippableSkeletalMeshComponent::GetGripLogicScripts()
{
#if WITH_PUSH_MODEL
if (bReplicateGripScripts)
{
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, GripLogicScripts, this);
}
#endif

return GripLogicScripts;
}

void UGrippableSkeletalMeshComponent::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags)
{
bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags;
#if WITH_PUSH_MODEL
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, bRepGripSettingsAndGameplayTags, this);
#endif
}

void UGrippableSkeletalMeshComponent::SetReplicateMovement(bool bNewReplicateMovement)
{
bReplicateMovement = bNewReplicateMovement;
#if WITH_PUSH_MODEL
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, bReplicateMovement, this);
#endif
}

FBPInterfaceProperties& UGrippableSkeletalMeshComponent::GetVRGripInterfaceSettings(bool bMarkDirty)
{
#if WITH_PUSH_MODEL
if (bMarkDirty && bRepGripSettingsAndGameplayTags)
{
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, VRGripInterfaceSettings, this);
}
#endif

return VRGripInterfaceSettings;
}

FGameplayTagContainer& UGrippableSkeletalMeshComponent::GetGameplayTags()
{
#if WITH_PUSH_MODEL
if (bRepGripSettingsAndGameplayTags)
{
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableSkeletalMeshComponent, GameplayTags, this);
}
#endif

return GameplayTags;
}

/////////////////////////////////////////////////
//- End Push networking getter / setter functions
/////////////////////////////////////////////////
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "VRExpansionFunctionLibrary.h"
#include "GripScripts/VRGripScriptBase.h"
#include "Net/UnrealNetwork.h"
#if WITH_PUSH_MODEL
#include "Net/Core/PushModel/PushModel.h"
#endif

//=============================================================================
UGrippableStaticMeshComponent::UGrippableStaticMeshComponent(const FObjectInitializer& ObjectInitializer)
Expand Down Expand Up @@ -43,12 +46,19 @@ void UGrippableStaticMeshComponent::GetLifetimeReplicatedProps(TArray< class FLi
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);

DOREPLIFETIME_CONDITION(UGrippableStaticMeshComponent, GripLogicScripts, COND_Custom);
DOREPLIFETIME(UGrippableStaticMeshComponent, bReplicateGripScripts);
DOREPLIFETIME(UGrippableStaticMeshComponent, bRepGripSettingsAndGameplayTags);
DOREPLIFETIME(UGrippableStaticMeshComponent, bReplicateMovement);
DOREPLIFETIME_CONDITION(UGrippableStaticMeshComponent, VRGripInterfaceSettings, COND_Custom);
DOREPLIFETIME_CONDITION(UGrippableStaticMeshComponent, GameplayTags, COND_Custom);
// For std properties
FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true };

DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, bReplicateGripScripts, PushModelParams);
DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, bRepGripSettingsAndGameplayTags, PushModelParams);
DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, bReplicateMovement, PushModelParams);

// For properties with special conditions
FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true };

DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, GripLogicScripts, PushModelParamsWithCondition);
DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, VRGripInterfaceSettings, PushModelParamsWithCondition);
DOREPLIFETIME_WITH_PARAMS_FAST(UGrippableStaticMeshComponent, GameplayTags, PushModelParamsWithCondition);
}

void UGrippableStaticMeshComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker)
Expand Down Expand Up @@ -314,4 +324,72 @@ void UGrippableStaticMeshComponent::OnComponentDestroyed(bool bDestroyingHierarc
}

GripLogicScripts.Empty();
}
}

/////////////////////////////////////////////////
//- Push networking getter / setter functions
/////////////////////////////////////////////////

void UGrippableStaticMeshComponent::SetReplicateGripScripts(bool bNewReplicateGripScripts)
{
bReplicateGripScripts = bNewReplicateGripScripts;
#if WITH_PUSH_MODEL
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, bReplicateGripScripts, this);
#endif
}

TArray<TObjectPtr<UVRGripScriptBase>>& UGrippableStaticMeshComponent::GetGripLogicScripts()
{
#if WITH_PUSH_MODEL
if (bReplicateGripScripts)
{
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, GripLogicScripts, this);
}
#endif

return GripLogicScripts;
}

void UGrippableStaticMeshComponent::SetRepGripSettingsAndGameplayTags(bool bNewRepGripSettingsAndGameplayTags)
{
bRepGripSettingsAndGameplayTags = bNewRepGripSettingsAndGameplayTags;
#if WITH_PUSH_MODEL
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, bRepGripSettingsAndGameplayTags, this);
#endif
}

void UGrippableStaticMeshComponent::SetReplicateMovement(bool bNewReplicateMovement)
{
bReplicateMovement = bNewReplicateMovement;
#if WITH_PUSH_MODEL
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, bReplicateMovement, this);
#endif
}

FBPInterfaceProperties& UGrippableStaticMeshComponent::GetVRGripInterfaceSettings(bool bMarkDirty)
{
#if WITH_PUSH_MODEL
if (bMarkDirty && bRepGripSettingsAndGameplayTags)
{
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, VRGripInterfaceSettings, this);
}
#endif

return VRGripInterfaceSettings;
}

FGameplayTagContainer& UGrippableStaticMeshComponent::GetGameplayTags()
{
#if WITH_PUSH_MODEL
if (bRepGripSettingsAndGameplayTags)
{
MARK_PROPERTY_DIRTY_FROM_NAME(UGrippableStaticMeshComponent, GameplayTags, this);
}
#endif

return GameplayTags;
}

/////////////////////////////////////////////////
//- End Push networking getter / setter functions
/////////////////////////////////////////////////
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include "Net/UnrealNetwork.h"
#include "Serialization/CustomVersion.h"

#if WITH_PUSH_MODEL
#include "Net/Core/PushModel/PushModel.h"
#endif

DEFINE_LOG_CATEGORY(LogVRHandSocketComponent);

const FGuid FVRHandSocketCustomVersion::GUID(0x5A018B7F, 0x48A7AFDE, 0xAFBEB580, 0xAD575412);
Expand Down Expand Up @@ -876,10 +880,17 @@ void UHandSocketComponent::OnComponentDestroyed(bool bDestroyingHierarchy)
void UHandSocketComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);

DOREPLIFETIME(UHandSocketComponent, bRepGameplayTags);
DOREPLIFETIME(UHandSocketComponent, bReplicateMovement);
DOREPLIFETIME_CONDITION(UHandSocketComponent, GameplayTags, COND_Custom);

// For std properties
FDoRepLifetimeParams PushModelParams{ COND_None, REPNOTIFY_OnChanged, /*bIsPushBased=*/true };

DOREPLIFETIME_WITH_PARAMS_FAST(UHandSocketComponent, bRepGameplayTags, PushModelParams);
DOREPLIFETIME_WITH_PARAMS_FAST(UHandSocketComponent, bReplicateMovement, PushModelParams);

// For properties with special conditions
FDoRepLifetimeParams PushModelParamsWithCondition{ COND_Custom, REPNOTIFY_OnChanged, /*bIsPushBased=*/true };

DOREPLIFETIME_WITH_PARAMS_FAST(UHandSocketComponent, GameplayTags, PushModelParamsWithCondition);
}

void UHandSocketComponent::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker)
Expand Down Expand Up @@ -963,4 +974,40 @@ UHandSocketComponent* UHandSocketComponent::GetHandSocketComponentFromObject(UOb
}

return nullptr;
}
}

/////////////////////////////////////////////////
//- Push networking getter / setter functions
/////////////////////////////////////////////////

void UHandSocketComponent::SetRepGameplayTags(bool bNewRepGameplayTags)
{
bRepGameplayTags = bNewRepGameplayTags;
#if WITH_PUSH_MODEL
MARK_PROPERTY_DIRTY_FROM_NAME(UHandSocketComponent, bRepGameplayTags, this);
#endif
}

void UHandSocketComponent::SetReplicateMovement(bool bNewReplicateMovement)
{
bReplicateMovement = bNewReplicateMovement;
#if WITH_PUSH_MODEL
MARK_PROPERTY_DIRTY_FROM_NAME(UHandSocketComponent, bReplicateMovement, this);
#endif
}

FGameplayTagContainer& UHandSocketComponent::GetGameplayTags()
{
#if WITH_PUSH_MODEL
if (bRepGameplayTags)
{
MARK_PROPERTY_DIRTY_FROM_NAME(UHandSocketComponent, GameplayTags, this);
}
#endif

return GameplayTags;
}

/////////////////////////////////////////////////
//- End Push networking getter / setter functions
/////////////////////////////////////////////////
Loading

0 comments on commit 801433c

Please sign in to comment.