diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h index 88cabe2430b6c7422a61595dd6c1c7c099e795c8..adf168b3cc86c16e42e448d17cbb45ce72800651 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h @@ -12,37 +12,62 @@ class UClickBehaviour; class USelectionBehaviour; class UIntenSelectComponent; +/** + * A component designed to make an actor selectable within IntenSelect, handling various aspects + * of interaction including scoring, hover, and action behaviors. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectable : public UActorComponent { GENERATED_BODY() public: + /** Whether the actor can be selected. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) bool IsSelectable = true; + /** Collection of scoring behaviors that define how selection scores are calculated for this actor. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray<UIntenSelectableScoring*> ScoringBehaviours; + /** Collection of behaviors that define what happens when this actor is hovered over. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray<UHoverBehaviour*> OnHoverBehaviours; + /** Collection of behaviors that define what happens when an action is performed on this actor. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray<UActionBehaviour*> OnActionBehaviours; - -public: UIntenSelectable(); + /** + * Computes the best point and score for selection based on defined criteria and behaviors. + * + * @param ConeOrigin The origin point of the selection cone. + * @param ConeForwardDirection The forward direction of the selection cone. + * @param ConeBackwardShiftDistance The distance to shift the cone's origin backwards. + * @param ConeAngle The angle of the selection cone. + * @param LastValue The last score value calculated for ongoing adjustments. + * @param DeltaTime Time elapsed since the last score calculation. + * @return A pair containing the best hit result and its corresponding score. + */ TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) const; + /** Handles events when hover starts over this actor. */ void HandleOnHoverStartEvents(const UIntenSelectComponent* IntenSelect, const FHitResult& HitResult); + + /** Handles events when hover ends over this actor. */ void HandleOnHoverEndEvents(const UIntenSelectComponent* IntenSelect); + + /** Handles events when an action starts on this actor. */ void HandleOnActionStartEvents(UIntenSelectComponent* IntenSelect); + + /** Handles events when an action ends on this actor. */ void HandleOnActionEndEvents(UIntenSelectComponent* IntenSelect, FInputActionValue& InputValue); + /** Initializes default references for the component's behaviors. Useful for setting up initial states. */ void InitDefaultBehaviourReferences(); protected: diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h index b1022932d1e0d9e503d59ab0bdccd392a99849b1..ed28b5117474acce7a4e4e19269b5100d058ff31 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h @@ -4,23 +4,48 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableCircleScoring.generated.h" +/** + * A component for calculating and managing scores for selectable objects within a circular area. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableCircleScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: + /** + * Determines the closest point within a circle to a given point, taking into account the direction of selection. + * + * @param Point The point from which to find the closest selection point. + * @param Direction The direction in which the selection is being made. + * @return The closest point within the circle to the specified point, considering the given direction. + */ FVector GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const; public: UIntenSelectableCircleScoring(); + /** If true, selection scoring is only considered on the outline of the circle. Otherwise, the entire area is + * considered. */ UPROPERTY(EditAnywhere) bool OnlyOutline = true; + /** The radius of the circle used for selection scoring. */ UPROPERTY(EditAnywhere) float Radius = 50; + /** + * Overrides the parent class's method to calculate the best point and score pair for selection within a circular + * area. + * + * @param ConeOrigin The origin point of the cone used for selection. + * @param ConeForwardDirection The forward direction of the cone used for selection. + * @param ConeBackwardShiftDistance The distance to shift the cone's origin backwards, for selection purposes. + * @param ConeAngle The angle of the cone in degrees, used for selection. + * @param LastValue The last score value calculated for this point, used for selection. + * @param DeltaTime The time elapsed since the last score calculation, used for selection. + * @return A pair containing the hit result and the score for the best point within the circular area. + */ virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h index 1556dab1295c8082f1d3600df03512960f49363b..fadbbbb5ce1dd1278fde68de0d3c432dd4ffc6e8 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h @@ -4,15 +4,37 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableCubeScoring.generated.h" +/** + * A component that specializes in calculating and managing selection scores within a cubic area. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableCubeScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: + /** + * Determines if two lines intersect, which is critical for calculating selection boundaries + * and interactions within or around the cube. + * + * @param FromA The starting point of the first line. + * @param FromB The ending point of the first line. + * @param ToA The starting point of the second line. + * @param ToB The ending point of the second line. + * @param OutIntersection Output parameter that will be filled with the intersection point if an intersection + * occurs. + * @return true if the lines intersect; otherwise, false. + */ static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection); + /** + * Calculates the closest point within the cube to a given ray, which is essential for selection scoring. + * + * @param RayOrigin The origin of the ray. + * @param RayDirection The direction of the ray. + * @return The closest point within the cube to the specified ray. + */ FVector GetClosestSelectionPointTo(const FVector& RayOrigin, const FVector& RayDirection) const; virtual void TickComponent(float DeltaTime, ELevelTick TickType, @@ -21,17 +43,42 @@ protected: public: UIntenSelectableCubeScoring(); + /** Whether back faces of the cube should be considered in the selection process. */ UPROPERTY(EditAnywhere) bool BackFaceCulling = false; + /** If true, selection scoring is only considered on the outline of the cube, not the volume. */ UPROPERTY(EditAnywhere) bool OnlyOutline = false; + /** + * Overrides the base class method to compute the best point and score pair for selection within a cubic volume, + * considering the unique properties and geometry of the cube. + * + * @param ConeOrigin The origin point of the cone used for selection. + * @param ConeForwardDirection The forward direction of the cone. + * @param ConeBackwardShiftDistance How far to shift the cone's origin backward for selection purposes. + * @param ConeAngle The angle of the cone in degrees, used to define the selection area. + * @param LastValue The last score value calculated, useful for continuous adjustments of the selection score. + * @param DeltaTime Time since the last score calculation. + * @return A pair containing the hit result and the score for the best point within the cubic volume. + */ virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; + /** + * Finds the closest point on a rectangle, part of the cube, to a given start point, projecting in a specified + * direction. This function is useful for determining interaction points on the cube's surface. + * + * @param StartPoint The point from which closeness is measured. + * @param Direction The direction in which the closeness is projected. + * @param Corner00 One corner of the rectangle. + * @param Corner01 Adjacent corner to Corner00. + * @param Corner10 Adjacent corner to Corner00, opposite to Corner01. + * @return The closest point on the rectangle to the given start point. + */ FVector GetClosestPointToRectangle(const FVector& StartPoint, const FVector& Direction, const FVector& Corner00, const FVector& Corner01, const FVector& Corner10) const; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.h index 73fbeb615956ba93f747d6053dea6a23d2c85b2d..c85c026dbb5072d5f5820a2072f9e243cb87768f 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.h @@ -4,15 +4,37 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableCylinderScoring.generated.h" +/** + * A component for calculating and managing scores for selectable objects within a cylindrical area. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableCylinderScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: + /** + * Checks for intersection between two lines, which is useful for calculations involving + * the cylinder's geometry and selection logic. + * + * @param FromA The starting point of the first line. + * @param FromB The ending point of the first line. + * @param ToA The starting point of the second line. + * @param ToB The ending point of the second line. + * @param OutIntersection If an intersection exists, this parameter will be filled with the point of intersection. + * @return true if there is an intersection; false otherwise. + */ static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection); + /** + * Determines the closest point on the cylinder to a given ray, which can be used to calculate + * selection scores based on proximity and directionality. + * + * @param Point The origin point of the ray. + * @param Direction The direction of the ray. + * @return The closest point on the cylinder to the specified ray. + */ FVector GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const; virtual void TickComponent(float DeltaTime, ELevelTick TickType, @@ -21,14 +43,28 @@ protected: public: UIntenSelectableCylinderScoring(); + /** + * Overrides the parent class method to calculate the best point and score pair for selection + * within a cylindrical volume, taking into account the unique geometry of a cylinder. + * + * @param ConeOrigin The origin point of the cone used for selection. + * @param ConeForwardDirection The forward direction of the cone. + * @param ConeBackwardShiftDistance How far to shift the cone's origin backward for selection. + * @param ConeAngle The angle of the cone, in degrees, used for determining the selection area. + * @param LastValue The last score value calculated, used for continuous adjustments. + * @param DeltaTime Time since the last score calculation. + * @return A pair containing the hit result and score for the best selection point. + */ virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; + /** Defines the end points of the cylinder's central axis, used in selection calculations. */ UPROPERTY(EditAnywhere) TArray<FVector> LinePoints{FVector::UpVector * 50, FVector::DownVector * 50}; + /** The radius of the cylinder, important for determining the cylindrical selection area. */ UPROPERTY(EditAnywhere) float Radius = 50; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.h index 2b1b5cf58cb99b50cf12380605bbca339e0b3720..aabdfde1c0b043a0519149579e4d38c34f610ef8 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.h @@ -4,15 +4,37 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableLineScoring.generated.h" +/** + * A component that specializes in calculating and managing scores for selectable objects along a line. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableLineScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: + /** + * Checks for the intersection between two lines, which is crucial for determining + * the selection points and scoring along lines. + * + * @param FromA Starting point of the first line. + * @param FromB Ending point of the first line. + * @param ToA Starting point of the second line. + * @param ToB Ending point of the second line. + * @param OutIntersection Output parameter that will be populated with the intersection point, if it exists. + * @return true if an intersection occurs; false otherwise. + */ static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection); + /** + * Determines the closest point on the line to a given point, considering a specific direction. + * This method is pivotal for line-based selection scoring calculations. + * + * @param Point The reference point from which to find the closest point on the line. + * @param Direction The direction from the reference point towards the line. + * @return The closest point on the line to the specified point and direction. + */ FVector GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const; virtual void TickComponent(float DeltaTime, ELevelTick TickType, @@ -21,11 +43,27 @@ protected: public: UIntenSelectableLineScoring(); + /** + * Overrides the parent class's method to calculate the best point and score pair for selection + * within a line, accounting for the unique linear geometry. + * + * @param ConeOrigin The origin point of the cone used for selection. + * @param ConeForwardDirection The forward direction of the cone. + * @param ConeBackwardShiftDistance The distance to shift the cone's origin backward for selection purposes. + * @param ConeAngle The angle of the cone in degrees, defining the selection area. + * @param LastValue The last score value calculated, for continuous selection logic adjustments. + * @param DeltaTime Time elapsed since the last score calculation. + * @return A pair containing the hit result and the score for the best point along the line. + */ virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; + /** + * Defines the endpoints of the line used for selection scoring. The selection logic will + * consider these points to calculate the closest point and score along the line. + */ UPROPERTY(EditAnywhere, meta = (EditFixedSize)) TArray<FVector> LinePoints{FVector::RightVector * 50, FVector::LeftVector * 50}; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.h index ef5c5480004ef62e006fbafadfd8dfd37055d9c2..c63e15f19f8bed68b5b9b2989b3a1739f2a37503 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.h @@ -4,24 +4,53 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableMultiPointScoring.generated.h" +/** + * A component that specializes in calculating and managing selection scores based on multiple points. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableMultiPointScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: + /** + * Calculates the closest selection point to a given reference point, factoring in a specific direction. + * This function is crucial for multi-point selection scenarios, where the closest point + * within a set needs to be determined based on proximity and direction. + * + * @param Point The reference point from which to find the closest selection point. + * @param Direction The direction from the reference point towards the selection points. + * @return The closest point from the provided set to the specified reference point and direction. + */ FVector GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const; public: UIntenSelectableMultiPointScoring(); + /** + * Overrides the base class method to calculate the best point and score pair from among multiple points, + * based on the specified selection criteria. + * + * @param ConeOrigin The origin point of the cone used for selection. + * @param ConeForwardDirection The forward direction of the cone. + * @param ConeBackwardShiftDistance The distance to shift the cone's origin backward for selection purposes. + * @param ConeAngle The angle of the cone in degrees, defining the selection area. + * @param LastValue The last score value calculated, for continuous adjustments of the selection score. + * @param DeltaTime Time elapsed since the last score calculation. + * @return A pair containing the hit result and the score for the best point among the multiple points. + */ virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; + /** + * Updates the set of points to be considered for selection. This can be used to dynamically + * change the points that are eligible for selection, based on gameplay or application logic. + */ void UpdatePoints(); + /** The set of points to consider for selection. These points are evaluated to find the best selection score. */ UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray<FVector> PointsToSelect; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.h index 3df3eeec9b373547e324b1558e063b7ab5dd5a42..5d4c34f0c39e9b07ed430cf8fe68a0ed2f5536b0 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.h @@ -4,15 +4,37 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableRectangleScoring.generated.h" +/** + * A component for calculating and managing scores for selectable objects within a rectangular area. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableRectangleScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: + /** + * Determines if two lines intersect, which is particularly useful in calculating + * selection boundaries and points within the rectangle. + * + * @param FromA Starting point of the first line. + * @param FromB Ending point of the first line. + * @param ToA Starting point of the second line. + * @param ToB Ending point of the second line. + * @param OutIntersection Output parameter filled with the intersection point, if any. + * @return true if the lines intersect, false otherwise. + */ static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection); + /** + * Calculates the closest point within the rectangle to a given ray, which is essential + * for determining selection scores based on the geometry of rectangular areas. + * + * @param Point The origin point of the ray. + * @param Direction The direction of the ray. + * @return The closest point within the rectangle to the specified ray. + */ FVector GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const; virtual void TickComponent(float DeltaTime, ELevelTick TickType, @@ -21,17 +43,32 @@ protected: public: UIntenSelectableRectangleScoring(); + /** If true, only the outline of the rectangle is considered for selection scoring. */ UPROPERTY(EditAnywhere) bool OnlyOutline = false; + /** The length of the rectangle along the X-axis. */ UPROPERTY(EditAnywhere) float XLength = 100; + /** The length of the rectangle along the Y-axis. */ UPROPERTY(EditAnywhere) float YLength = 100; + /** + * Calculates the best point and score pair for selection within a rectangular area, + * taking into account the unique properties and dimensions of the rectangle. + * + * @param ConeOrigin Origin point of the cone used for selection. + * @param ConeForwardDirection Forward direction of the cone used for selection. + * @param ConeBackwardShiftDistance Distance to shift the cone's origin backward for selection purposes. + * @param ConeAngle Angle of the cone in degrees, used to define the selection area. + * @param LastValue Last score value calculated, useful for continuous selection logic. + * @param DeltaTime Time elapsed since the last score calculation. + * @return A pair containing the hit result and the score for the best selection point within the rectangle. + */ virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, - const float ConeBackwardShiftDistance, const float ConeAngle, + const float ConeBackwardShiftDistance, float ConeAngle, const float LastValue, const float DeltaTime) override; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h index df12d548abde9108fdffa4b8485a83b3c1e97259..815136832e530eb81775d30bc3bfd9c7a7d442a7 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h @@ -4,12 +4,27 @@ #include "Components/SceneComponent.h" #include "IntenSelectableScoring.generated.h" +/** + * A component for calculating and managing scores for selectable objects. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableScoring : public USceneComponent { GENERATED_BODY() protected: + /** + * Calculates a score based on the position and orientation of a cone, and a test point within the environment. + * + * @param ConeOrigin The origin point of the cone. + * @param ConeForwardDirection The forward direction of the cone. + * @param ConeBackwardShiftDistance The distance to shift the cone's origin backwards. + * @param ConeAngle The angle of the cone in degrees. + * @param TestPoint The point in the environment to test against the cone. + * @param LastValue The last score value calculated for this point. + * @param DeltaTime The time elapsed since the last score calculation. + * @return The calculated score for the test point. + */ float GetScore(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const FVector& TestPoint, const float LastValue, const float DeltaTime); @@ -17,28 +32,47 @@ protected: public: UIntenSelectableScoring(); + /** Whether to draw debug information in the editor. */ UPROPERTY(EditAnywhere) bool DrawDebug = true; + /** The current score of the component. */ UPROPERTY(BlueprintReadOnly) float CurrentScore = 0; + /** Whether the component is selectable. */ UPROPERTY(EditAnywhere) bool bIsSelectable = true; + /** The stickiness of selection. Higher values make selection more 'sticky'. */ UPROPERTY(EditAnywhere) float Stickiness = 10; + /** The snappiness of selection. Higher values make selection 'snap' more aggressively. */ UPROPERTY(EditAnywhere) float Snappiness = 15; + /** A constant used for compensating the score calculation. */ UPROPERTY(EditAnywhere) float CompensationConstant = 0.8; + /** Whether to overwrite the contribution of this component towards the final score. */ bool bOverwritingContrib = false; + /** The contribution of this component towards the final score. */ float Contrib = 0; + /** + * Gets the best point and score pair based on the input parameters. + * + * @param ConeOrigin The origin point of the cone. + * @param ConeForwardDirection The forward direction of the cone. + * @param ConeBackwardShiftDistance The distance to shift the cone's origin backwards. + * @param ConeAngle The angle of the cone in degrees. + * @param LastValue The last score value calculated for this point. + * @param DeltaTime The time elapsed since the last score calculation. + * @return A pair containing the hit result and the score for the best point. + */ virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h index f8dc22e8d9fa3594d9ac821b155ccc57c3d110c9..18ce45cea6d3d5504c2240ab643032e5e618428a 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h @@ -4,6 +4,9 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableSinglePointScoring.generated.h" +/** + * A component specifically designed for calculating and managing scores for selectable objects at a single point. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableSinglePointScoring : public UIntenSelectableScoring { @@ -12,6 +15,19 @@ class RWTHVRTOOLKIT_API UIntenSelectableSinglePointScoring : public UIntenSelect public: UIntenSelectableSinglePointScoring(); + /** + * Overrides the base class method to calculate the best point and score pair for a single point selection. + * This method is crucial for determining the effectiveness of selection based on the specified criteria. + * + * @param ConeOrigin The origin point of the cone used for selection. + * @param ConeForwardDirection The forward direction of the cone. + * @param ConeBackwardShiftDistance The distance to shift the cone's origin backward for selection purposes. + * @param ConeAngle The angle of the cone in degrees, defining the selection area. + * @param LastValue The last score value calculated, for continuous adjustments of the selection score. + * @param DeltaTime Time elapsed since the last score calculation. + * @return A pair containing the hit result and the score for the best selection point, which in this case is + * predetermined. + */ virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h index 6d0835a432366e189d0a080aa3254cd613e5ed48..94a8f9e911cd2128829e52f39040f80c43f91f0f 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h @@ -4,26 +4,60 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableSphereScoring.generated.h" +/** + * A component designed for calculating and managing selection scores within a spherical area. + */ UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableSphereScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: + /** + * Determines the closest point within the sphere to a given point and direction, which is essential + * for calculating selection scores that are based on proximity to a spherical surface or volume. + * + * @param Point The reference point from which to find the closest point on the sphere. + * @param Direction The direction from the reference point to project towards the sphere. + * @return The closest point on the sphere to the given reference point and direction. + */ FVector GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const; public: UIntenSelectableSphereScoring(); + /** + * Optional debug material to visualize the selection scoring area in the Unreal Editor or during gameplay. + * This material can be applied to a sphere mesh to aid in debugging and visualizing the scoring volume. + */ UPROPERTY(EditAnywhere) UMaterialInstance* DebugMaterial; + /** + * Determines whether the scoring calculation should only consider the outline of the sphere. + * If true, only the surface area of the sphere is considered for scoring. Otherwise, the entire + * volume of the sphere is used in the scoring calculations. + */ UPROPERTY(EditAnywhere) bool OnlyOutline = false; + /** The radius of the sphere used in the selection scoring calculations. */ UPROPERTY(EditAnywhere) float Radius = 50; + /** + * Overrides the base class method to calculate the best point and score pair for selections + * within a spherical volume, taking into account the sphere's radius and whether to consider + * just the outline or the entire volume for scoring. + * + * @param ConeOrigin The origin point of the cone used for selection. + * @param ConeForwardDirection The forward direction of the cone. + * @param ConeBackwardShiftDistance How far to shift the cone's origin backward for selection purposes. + * @param ConeAngle The angle of the cone in degrees, used to determine the selection area. + * @param LastValue The last score value calculated, for continuous adjustment of selection scoring. + * @param DeltaTime Time since the last score calculation. + * @return A pair containing the hit result and the score for the best point within or on the surface of the sphere. + */ virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle,