Skip to content
Snippets Groups Projects
Commit 0bb6ff02 authored by Kamil Karwacki's avatar Kamil Karwacki
Browse files

final changes before merge request

parent de71a6a9
No related branches found
No related tags found
1 merge request!36Feature/interaction additions
...@@ -79,7 +79,6 @@ void UBasicVRInteractionComponent::EndInteraction() ...@@ -79,7 +79,6 @@ void UBasicVRInteractionComponent::EndInteraction()
GrabbedActor = nullptr; GrabbedActor = nullptr;
ComponentSimulatingPhysics = nullptr; ComponentSimulatingPhysics = nullptr;
Behavior = nullptr; Behavior = nullptr;
bDidSimulatePhysics = false;
} }
// Called every frame // Called every frame
...@@ -155,15 +154,12 @@ TOptional<FHitResult> UBasicVRInteractionComponent::RaytraceForFirstHit(const FT ...@@ -155,15 +154,12 @@ TOptional<FHitResult> UBasicVRInteractionComponent::RaytraceForFirstHit(const FT
const FVector Start = Ray.v1; const FVector Start = Ray.v1;
const FVector End = Ray.v2; const FVector End = Ray.v2;
DrawDebugLine(GetWorld(), Start, End, FColor::Red, true, 2, 1, 1);
// will be filled by the Line Trace Function // will be filled by the Line Trace Function
FHitResult Hit; FHitResult Hit;
const FCollisionObjectQueryParams Params; const FCollisionObjectQueryParams Params;
FCollisionQueryParams Params2; FCollisionQueryParams Params2;
Params2.AddIgnoredActor(GetOwner()->GetUniqueID()); // prevents actor hitting itself Params2.AddIgnoredActor(GetOwner()->GetUniqueID()); // prevents actor hitting itself
//if(GetWorld()->LineTraceSingleByChannel(Hit, Start, End, ECollisionChannel::ECC_Visibility, Params2))
if (GetWorld()->LineTraceSingleByObjectType(Hit, Start, End, Params, Params2)) if (GetWorld()->LineTraceSingleByObjectType(Hit, Start, End, Params, Params2))
return {Hit}; return {Hit};
else else
...@@ -175,7 +171,7 @@ UPrimitiveComponent* GetFirstComponentSimulatingPhysics(const AActor* TargetActo ...@@ -175,7 +171,7 @@ UPrimitiveComponent* GetFirstComponentSimulatingPhysics(const AActor* TargetActo
TArray<UPrimitiveComponent*> PrimitiveComponents; TArray<UPrimitiveComponent*> PrimitiveComponents;
TargetActor->GetComponents<UPrimitiveComponent>(PrimitiveComponents); TargetActor->GetComponents<UPrimitiveComponent>(PrimitiveComponents);
// find the component that simulates physics // find any component that simulates physics, then traverse the hierarchy
for (const auto& Component : PrimitiveComponents) { for (const auto& Component : PrimitiveComponents) {
if (Component->IsSimulatingPhysics()) { if (Component->IsSimulatingPhysics()) {
return GetHighestParentSimulatingPhysics(Component); return GetHighestParentSimulatingPhysics(Component);
......
...@@ -34,8 +34,6 @@ public: ...@@ -34,8 +34,6 @@ public:
UFUNCTION(BlueprintCallable, BlueprintPure) AActor* GetGrabbedActor() const { return GrabbedActor;} UFUNCTION(BlueprintCallable, BlueprintPure) AActor* GetGrabbedActor() const { return GrabbedActor;}
UFUNCTION(BlueprintCallable, BlueprintPure) USceneComponent* GetInteractionRayEmitter() const { return InteractionRayEmitter; } UFUNCTION(BlueprintCallable, BlueprintPure) USceneComponent* GetInteractionRayEmitter() const { return InteractionRayEmitter; }
private: private:
/* indicates if the grabbed actor was simulating physics before we grabbed it */
UPROPERTY() bool bDidSimulatePhysics;
/* Holding a reference to the actor that is currently being grabbed */ /* Holding a reference to the actor that is currently being grabbed */
UPROPERTY() AActor* GrabbedActor; UPROPERTY() AActor* GrabbedActor;
/* Holds a reference to the grabbed actors physics simulating component if there was one*/ /* Holds a reference to the grabbed actors physics simulating component if there was one*/
...@@ -49,7 +47,15 @@ private: ...@@ -49,7 +47,15 @@ private:
}; };
// Free utility functions // Free utility functions
/*
Returns the UPrimitiveComponent simulating physics that is highest in the hierarchy
*/
UPrimitiveComponent* GetFirstComponentSimulatingPhysics(const AActor* TargetActor); UPrimitiveComponent* GetFirstComponentSimulatingPhysics(const AActor* TargetActor);
/*
Recursive Function
If parent component simulates physics returns GetHighestParentSimulatingPhysics(Parent)
else returns Comp itself
*/
UPrimitiveComponent* GetHighestParentSimulatingPhysics(UPrimitiveComponent* Comp); UPrimitiveComponent* GetHighestParentSimulatingPhysics(UPrimitiveComponent* Comp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment