Advertisement
Guest User

BuoyancyComponent.h Header File

a guest
Mar 26th, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.91 KB | None | 0 0
  1. ###### BuoyancyComponent.h header file #######
  2.  
  3. //TK's Solution :: WORKING ON > The goal of this is to be able to set mesh density to individual test points, or as a whole using a struct, just like Handkors setup with Dotcams struct addon
  4.  
  5. #pragma once
  6.  
  7. #include "OceanPluginPrivatePCH.h"
  8. #include "GameFramework/MovementComponent.h" //Nsomnia >> added this whole line in
  9. #include "OceanManager.h"
  10. #include "BuoyancyComponent.generated.h"
  11.  
  12. /* Defines an individual test point for buoyancy calculation. */
  13. USTRUCT(BlueprintType)
  14. struct FBuoyancyTK {
  15.     GENERATED_USTRUCT_BODY();
  16.  
  17.     UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Buoyancy")
  18.         float MeshDensity; 
  19.     UPROPERTY(BlueprintReadWrite, EditAnywhere)
  20.         FVector Location;
  21.     };
  22.  
  23.  
  24. /*
  25. * A custom MovementComponent that enables Buoyancy when used with an ocean surface.
  26. */
  27. UCLASS(ClassGroup = Movement, meta = (BlueprintSpawnableComponent), HideCategories = (PlanarMovement, "Components|Movement|Planar", Velocity))
  28. class UBuoyancyComponent : public UMovementComponent
  29. {
  30.     GENERATED_UCLASS_BODY()
  31.  
  32.     /* OceanManager used by the component, if unassigned component will auto-detect */
  33.     UPROPERTY(BlueprintReadOnly)
  34.     AOceanManager* OceanManager;
  35.    
  36.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
  37.     float MeshDensity;
  38.  
  39.     /* Density of water */
  40.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
  41.     float FluidDensity;
  42.  
  43.     /* Linear damping when object is in fluid */
  44.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
  45.     float FluidLinearDamping;
  46.  
  47.     /* Angular damping when object is in fluid */
  48.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
  49.     float FluidAngularDamping;
  50.  
  51.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
  52.     FVector VelocityDamper;
  53.  
  54.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
  55.     bool ClampMaxVelocity;
  56.  
  57.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
  58.     float MaxUnderwaterVelocity;
  59.  
  60.     /* Radius of the points */
  61.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
  62.     float TestPointRadius;
  63.  
  64.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy")
  65.     TArray<FBuoyancyTK> TestPoints;
  66.  
  67.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
  68.     bool DrawDebugPoints;
  69.  
  70.     //Begin UActorComponent Interface
  71.     virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
  72.     virtual void InitializeComponent() override;
  73.     //virtual bool IsInWater() const override; //Nsomnia > Added this whole line in
  74.     //End UActorComponent Interface
  75.  
  76. private:
  77.  
  78.     static FVector GetVelocityAtPoint(UPrimitiveComponent* Target, FVector Point, FName BoneName = NAME_None);
  79.  
  80.     float _SignedRadius;
  81.     float _baseAngularDamping;
  82.     float _baseLinearDamping;
  83.  
  84. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement