Skip to content
Snippets Groups Projects
Select Git revision
  • c4b3781e247e415cdefab00fa8bc0935c6035ae7
  • stable default protected
  • MA_Pape_2018
  • MA_2018_Lopatin
  • feature/mesh_viewer
  • feature/#468_access_isosurface_scalar
  • feature/#459_default_primitives
  • master protected
  • feature/#470_Create_a_color_lookup_table
  • feature/#473_resize_companion_window
  • feature/#462_do_not_use_arb_extensions
  • feature/#495_Provide_data_for_larger_isosurfaces
  • feature/#323_default_image
  • feature/#480_Create_a_smaller_test_mesh_for_combustion_demo
  • feature/#236_Get_Integration_tests_running_on_CI
  • feature/#447_Copy_standard_assets_to_build_folder
  • 447-copy-standard-assets-to-build-folder-and-remove-resource-path
  • feature/#445_mesh_render_settings_component
  • feature/#251_Make_sure_tests_cpp_is_compiled_once
  • feature/#455_Remove_navigation_and_improve_interaction_for_combustion_demo
  • feature/446_strange_txt_files
  • v18.06.0
  • v18.05.0
  • #251_bad
  • #251_good
  • v18.03.0
  • v18.02.0
  • v18.01.0
  • v17.12.0
  • v17.11.0
  • v17.10.0
  • v17.09.0
  • v17.07.0
33 results

combustion_demo.cpp

Blame
  • VRPawnMovement.h 3.38 KiB
    #pragma once
    
    #include "CoreMinimal.h"
    #include "GameFramework/FloatingPawnMovement.h"
    #include "Components/CapsuleComponent.h"
    
    #include "VRPawnMovement.generated.h"
    
    /*
     * This Movement component is needed since in VR not only the pawn itself (UpdatedComponent) is moved but also the
     * user herself can walk and thereby move the CameraComponent, which can also lead to collisions or e.g. going up steps 
     *
     * The four modes are:
     * None: No controller movement is applied and no corrections regarding steps or collisions with walls are done
     * Ghost: The same as above but now the Inputs can be used for unconstrained flying (also through objects)
     * Fly: The user can fly but not through walls etc. When the user walks against a wall the scene is moved with her to avoid walking through
     *      The user can also walk up stairs with a maximum step height of MaxStepHeight
     * Walk: Additionally to Fly now gravity keeps the user on the floor
     */
    
    UENUM(BlueprintType)
    enum class EVRNavigationModes : uint8
    {
    	NAV_NONE UMETA(DisplayName = "None (no controller movement)"),
    	NAV_GHOST UMETA(DisplayName = "Ghost (flying, also through walls)"),
    	NAV_FLY UMETA(DisplayName = "Fly (prohibiting collisions)"),
    	NAV_WALK UMETA(DisplayName = "Walk (gravity and prohibiting collisions)")
    };
    
    UCLASS()
    class RWTHVRTOOLKIT_API UVRPawnMovement : public UFloatingPawnMovement
    {
    	GENERATED_UCLASS_BODY()
    
    public:
    	virtual void BeginPlay() override;
    	void CheckAndRevertCollisionSinceLastTick();
    
    	void MoveOutOfNewDynamicCollisions();
    	virtual void TickComponent(float DeltaTime, enum ELevelTick TickType,
    	                           FActorComponentTickFunction* ThisTickFunction) override;
    
    	void SetHeadComponent(USceneComponent* NewHeadComponent);
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
    	EVRNavigationModes NavigationMode = EVRNavigationModes::NAV_WALK;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta = (ClampMin="0.0"))
    	float MaxStepHeight = 40.0f;
    
    	// if the height that the pawn would fall (in walking mode) is higher
    	// it is not falling, set to <0.0f if you want to fall infinitely
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
    	float MaxFallingDepth = 1000.0f;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta = (ClampMax="0.0"))
    	float GravityAcceleration = -981.0f;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta = (ClampMin="0.0"))
    	float UpSteppingAcceleration = 981.0f;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta = (ClampMin="0.0"))
    	float CapsuleRadius = 40.0f;
    
    private:
    	//check for
    	FHitResult CreateCapsuleTrace(const FVector& Start, const FVector& End, bool DrawDebug = false) const;
    	FVector GetOverlapResolveDirection();
    	void SetCapsuleColliderToUserSize() const;
    	void CheckForPhysWalkingCollision();
    	FVector GetCollisionSafeVirtualSteeringVec(FVector InputVector, float DeltaTime);
    	void MoveByGravityOrStepUp(float DeltaSeconds);
    	void ShiftVertically(float Distance, float VerticalAcceleration, float DeltaSeconds);
    
    	UPROPERTY(VisibleAnywhere)
    	UCapsuleComponent* CapsuleColliderComponent = nullptr;
    	UPROPERTY()
    	USceneComponent* HeadComponent = nullptr;
    
    	float VerticalSpeed = 0.0f;
    	FVector LastCollisionFreeCapsulePosition;
    	FVector LastSteeringCollisionVector;
    
    	//just stored for performance gains;
    	UPROPERTY()
    	TArray<AActor*> ActorsToIgnore;
    };