replace SGPawn::FImpl::EnableActorPhysics() and SGPawn::FImpl::DisableActorPhysics() with USGGrabComponent::SimulatePhysics()
This commit is contained in:
@@ -40,6 +40,7 @@ This is a minor release focusing mainly on bringing OpenXR-compatible hand track
|
||||
- GetMotionControllerData() has been introduced to the USGVitualHandComponent in order to retrieve the OpenXR-compatible glove data in Unreal's FXRMotionControllerData format.
|
||||
- Added FSGVirtualHandAnimInstanceProxy::GetMotionControllerData and many more accessor methods usable only by child classes to allow consumption of the data required for manipulating the virtual hand mesh animations.
|
||||
- GetMotionControllerData() has been introduced to the USGWristTrackerComponent in order to retrieve the OpenXR-compatible glove data in Unreal's FXRMotionControllerData format.
|
||||
- Added USGGrabComponent::SimulatePhysics() method.
|
||||
- Added FSGDebugCube.
|
||||
- Added FSGDebugCubeSettings.
|
||||
- Added the SenseGloveDebugKismet module in order to allow drawing of debugging, cubes, gizmos, and virtual hands from Blueprint.
|
||||
|
||||
@@ -137,12 +137,8 @@ void USGGrabComponent::FImplDeleter::operator()(const FImpl* P) const
|
||||
delete P;
|
||||
}
|
||||
|
||||
void USGGrabComponent::BeginPlay()
|
||||
void USGGrabComponent::SimulatePhysics(const bool bSimulatePhysics) const
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (bAffectPhysicsState)
|
||||
{
|
||||
const AActor* OwnerActor{GetOwner()};
|
||||
if (!ensureAlwaysMsgf(IsValid(OwnerActor), TEXT("Invalid OwnerActor!")))
|
||||
{
|
||||
@@ -156,8 +152,25 @@ void USGGrabComponent::BeginPlay()
|
||||
return;
|
||||
}
|
||||
|
||||
ActorRootComponent->SetEnableGravity(true);
|
||||
ActorRootComponent->SetSimulatePhysics(true);
|
||||
ActorRootComponent->SetEnableGravity(bSimulatePhysics);
|
||||
ActorRootComponent->SetSimulatePhysics(bSimulatePhysics);
|
||||
|
||||
if (bSimulatePhysics)
|
||||
{
|
||||
ActorRootComponent->WakeRigidBody();
|
||||
}
|
||||
else
|
||||
{
|
||||
ActorRootComponent->PutRigidBodyToSleep();
|
||||
}
|
||||
}
|
||||
|
||||
void USGGrabComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (bAffectPhysicsState)
|
||||
{
|
||||
SimulatePhysics(true);
|
||||
}
|
||||
}
|
||||
@@ -138,9 +138,6 @@ struct ASGPawn::FImpl
|
||||
return Owner->RightHandOverlappedActors.Num() > 0;
|
||||
}
|
||||
|
||||
void DisableActorPhysics(const AActor* Actor) const;
|
||||
void EnableActorPhysics(const AActor* Actor) const;
|
||||
|
||||
void ApplyHandVelocityToGrabbedActor(const FSGGrabState& GrabState) const;
|
||||
|
||||
void SetGrabbedActor(FSGGrabState& GrabState, AActor* Actor) const;
|
||||
@@ -1723,7 +1720,7 @@ void ASGPawn::Grab(USGVirtualHandComponent* Hand, AActor* Actor)
|
||||
|
||||
if (GrabComponent->GetAffectPhysicsState())
|
||||
{
|
||||
Pimpl->DisableActorPhysics(Actor);
|
||||
GrabComponent->SimulatePhysics(false);
|
||||
}
|
||||
|
||||
if (Hand->IsRight())
|
||||
@@ -2152,37 +2149,6 @@ void ASGPawn::FImpl::SetAllFingersColliderCollisionEnabled(const bool bRight, co
|
||||
}
|
||||
}
|
||||
|
||||
void ASGPawn::FImpl::DisableActorPhysics(const AActor* Actor) const
|
||||
{
|
||||
UPrimitiveComponent* ActorRootComponent{Cast<UPrimitiveComponent>(Actor->GetRootComponent())};
|
||||
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("RootComponent is not a valid UPrimativeComponent!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActorRootComponent->SetEnableGravity(false);
|
||||
ActorRootComponent->SetSimulatePhysics(false);
|
||||
ActorRootComponent->PutRigidBodyToSleep();
|
||||
}
|
||||
|
||||
void ASGPawn::FImpl::EnableActorPhysics(const AActor* Actor) const
|
||||
{
|
||||
if (!IsValid(Actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UPrimitiveComponent* ActorRootComponent{Cast<UPrimitiveComponent>(Actor->GetRootComponent())};
|
||||
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("RootComponent is not a valid UPrimativeComponent!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActorRootComponent->SetEnableGravity(true);
|
||||
ActorRootComponent->SetSimulatePhysics(true);
|
||||
ActorRootComponent->WakeRigidBody();
|
||||
}
|
||||
|
||||
void ASGPawn::FImpl::ApplyHandVelocityToGrabbedActor(const FSGGrabState& GrabState) const
|
||||
{
|
||||
if (!IsValid(GrabState.Hand))
|
||||
@@ -2271,7 +2237,7 @@ void ASGPawn::FImpl::Release(FSGGrabState& GrabState) const
|
||||
|
||||
if (GrabComponent->GetAffectPhysicsState())
|
||||
{
|
||||
EnableActorPhysics(GrabState.GrabbedActor);
|
||||
GrabComponent->SimulatePhysics(true);
|
||||
}
|
||||
|
||||
ApplyHandVelocityToGrabbedActor(GrabState);
|
||||
|
||||
@@ -197,6 +197,9 @@ public:
|
||||
bAffectPhysicsState = bInAffectPhysicsState;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void SimulatePhysics(bool bSimulatePhysics) const;
|
||||
|
||||
public:
|
||||
virtual void BeginPlay() override;
|
||||
};
|
||||
Reference in New Issue
Block a user