Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###### BuoyancyComponent.h header file #######
- //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
- #pragma once
- #include "OceanPluginPrivatePCH.h"
- #include "GameFramework/MovementComponent.h" //Nsomnia >> added this whole line in
- #include "OceanManager.h"
- #include "BuoyancyComponent.generated.h"
- /* Defines an individual test point for buoyancy calculation. */
- USTRUCT(BlueprintType)
- struct FBuoyancyTK {
- GENERATED_USTRUCT_BODY();
- UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Buoyancy")
- float MeshDensity;
- UPROPERTY(BlueprintReadWrite, EditAnywhere)
- FVector Location;
- };
- /*
- * A custom MovementComponent that enables Buoyancy when used with an ocean surface.
- */
- UCLASS(ClassGroup = Movement, meta = (BlueprintSpawnableComponent), HideCategories = (PlanarMovement, "Components|Movement|Planar", Velocity))
- class UBuoyancyComponent : public UMovementComponent
- {
- GENERATED_UCLASS_BODY()
- /* OceanManager used by the component, if unassigned component will auto-detect */
- UPROPERTY(BlueprintReadOnly)
- AOceanManager* OceanManager;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
- float MeshDensity;
- /* Density of water */
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
- float FluidDensity;
- /* Linear damping when object is in fluid */
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
- float FluidLinearDamping;
- /* Angular damping when object is in fluid */
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
- float FluidAngularDamping;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
- FVector VelocityDamper;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
- bool ClampMaxVelocity;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
- float MaxUnderwaterVelocity;
- /* Radius of the points */
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
- float TestPointRadius;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy")
- TArray<FBuoyancyTK> TestPoints;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
- bool DrawDebugPoints;
- //Begin UActorComponent Interface
- virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
- virtual void InitializeComponent() override;
- //virtual bool IsInWater() const override; //Nsomnia > Added this whole line in
- //End UActorComponent Interface
- private:
- static FVector GetVelocityAtPoint(UPrimitiveComponent* Target, FVector Point, FName BoneName = NAME_None);
- float _SignedRadius;
- float _baseAngularDamping;
- float _baseLinearDamping;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement