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.
|
- 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.
|
- 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.
|
- 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 FSGDebugCube.
|
||||||
- Added FSGDebugCubeSettings.
|
- Added FSGDebugCubeSettings.
|
||||||
- Added the SenseGloveDebugKismet module in order to allow drawing of debugging, cubes, gizmos, and virtual hands from Blueprint.
|
- Added the SenseGloveDebugKismet module in order to allow drawing of debugging, cubes, gizmos, and virtual hands from Blueprint.
|
||||||
|
|||||||
@@ -137,27 +137,40 @@ void USGGrabComponent::FImplDeleter::operator()(const FImpl* P) const
|
|||||||
delete P;
|
delete P;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void USGGrabComponent::SimulatePhysics(const bool bSimulatePhysics) const
|
||||||
|
{
|
||||||
|
const AActor* OwnerActor{GetOwner()};
|
||||||
|
if (!ensureAlwaysMsgf(IsValid(OwnerActor), TEXT("Invalid OwnerActor!")))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UPrimitiveComponent* ActorRootComponent{Cast<UPrimitiveComponent>(OwnerActor->GetRootComponent())};
|
||||||
|
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent),
|
||||||
|
TEXT("RootComponent is not a valid UPrimativeComponent!")))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActorRootComponent->SetEnableGravity(bSimulatePhysics);
|
||||||
|
ActorRootComponent->SetSimulatePhysics(bSimulatePhysics);
|
||||||
|
|
||||||
|
if (bSimulatePhysics)
|
||||||
|
{
|
||||||
|
ActorRootComponent->WakeRigidBody();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ActorRootComponent->PutRigidBodyToSleep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void USGGrabComponent::BeginPlay()
|
void USGGrabComponent::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
if (bAffectPhysicsState)
|
if (bAffectPhysicsState)
|
||||||
{
|
{
|
||||||
const AActor* OwnerActor{GetOwner()};
|
SimulatePhysics(true);
|
||||||
if (!ensureAlwaysMsgf(IsValid(OwnerActor), TEXT("Invalid OwnerActor!")))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UPrimitiveComponent* ActorRootComponent{Cast<UPrimitiveComponent>(OwnerActor->GetRootComponent())};
|
|
||||||
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent),
|
|
||||||
TEXT("RootComponent is not a valid UPrimativeComponent!")))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActorRootComponent->SetEnableGravity(true);
|
|
||||||
ActorRootComponent->SetSimulatePhysics(true);
|
|
||||||
ActorRootComponent->WakeRigidBody();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,9 +138,6 @@ struct ASGPawn::FImpl
|
|||||||
return Owner->RightHandOverlappedActors.Num() > 0;
|
return Owner->RightHandOverlappedActors.Num() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisableActorPhysics(const AActor* Actor) const;
|
|
||||||
void EnableActorPhysics(const AActor* Actor) const;
|
|
||||||
|
|
||||||
void ApplyHandVelocityToGrabbedActor(const FSGGrabState& GrabState) const;
|
void ApplyHandVelocityToGrabbedActor(const FSGGrabState& GrabState) const;
|
||||||
|
|
||||||
void SetGrabbedActor(FSGGrabState& GrabState, AActor* Actor) const;
|
void SetGrabbedActor(FSGGrabState& GrabState, AActor* Actor) const;
|
||||||
@@ -1723,7 +1720,7 @@ void ASGPawn::Grab(USGVirtualHandComponent* Hand, AActor* Actor)
|
|||||||
|
|
||||||
if (GrabComponent->GetAffectPhysicsState())
|
if (GrabComponent->GetAffectPhysicsState())
|
||||||
{
|
{
|
||||||
Pimpl->DisableActorPhysics(Actor);
|
GrabComponent->SimulatePhysics(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hand->IsRight())
|
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
|
void ASGPawn::FImpl::ApplyHandVelocityToGrabbedActor(const FSGGrabState& GrabState) const
|
||||||
{
|
{
|
||||||
if (!IsValid(GrabState.Hand))
|
if (!IsValid(GrabState.Hand))
|
||||||
@@ -2271,7 +2237,7 @@ void ASGPawn::FImpl::Release(FSGGrabState& GrabState) const
|
|||||||
|
|
||||||
if (GrabComponent->GetAffectPhysicsState())
|
if (GrabComponent->GetAffectPhysicsState())
|
||||||
{
|
{
|
||||||
EnableActorPhysics(GrabState.GrabbedActor);
|
GrabComponent->SimulatePhysics(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyHandVelocityToGrabbedActor(GrabState);
|
ApplyHandVelocityToGrabbedActor(GrabState);
|
||||||
|
|||||||
@@ -197,6 +197,9 @@ public:
|
|||||||
bAffectPhysicsState = bInAffectPhysicsState;
|
bAffectPhysicsState = bInAffectPhysicsState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void SimulatePhysics(bool bSimulatePhysics) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user