Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial upgrade to UE 4.19 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions FluidSurface/FluidSurface.uplugin
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{
"PluginFileVersion" : 3,

"FileVersion" : 3,
"Version" : 1,
"FriendlyName" : "Fluid Surface Actor",
"Version" : 10,
"VersionName" : "0.1.3",
"CreatedBy" : "Ehamloptiran",
"CreatedByURL" : "[email protected]",
"EngineVersion" : "4.10.0",
"Description" : "Simulated fluid surface actor",
"Category" : "Rendering",
"EnabledByDefault" : true,

"Modules" :
[
{
Expand All @@ -20,7 +18,7 @@
{
"Name" : "FluidSurfaceEngine",
"Type" : "Runtime",
"LoadingPhase" : "PostConfigInit"
"LoadingPhase": "PostConfigInit"
}
]
}
56 changes: 27 additions & 29 deletions FluidSurface/Source/FluidSurface/FluidSurface.Build.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;

namespace UnrealBuildTool.Rules
public class FluidSurface : ModuleRules
{
public class FluidSurface : ModuleRules
public FluidSurface(ReadOnlyTargetRules Target) : base(Target)
{
public FluidSurface(TargetInfo Target)
{
PrivateIncludePaths.AddRange(
new string[] {
"FluidSurface/Private",
"FluidSurface/Private/Modifiers"
}
);
PrivateIncludePaths.AddRange(
new string[] {
"FluidSurface/Private",
"FluidSurface/Private/Modifiers"
}
);

PublicIncludePaths.AddRange(
new string[] {
"FluidSurfaceRender/Public"
}
);
PublicIncludePaths.AddRange(
new string[] {
"FluidSurfaceRender/Public"
}
);

PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
"RenderCore",
"ShaderCore",
"RHI",
"FluidSurfaceEngine"
}
);
}
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
"RenderCore",
"ShaderCore",
"RHI",
"FluidSurfaceEngine"
}
);
}
}
16 changes: 2 additions & 14 deletions FluidSurface/Source/FluidSurface/Private/FluidSurface.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

#include "FluidSurfacePrivatePCH.h"

class FFluidSurface : public IModuleInterface
{
/** IModuleInterface implementation */
virtual void StartupModule( ) override;
virtual void ShutdownModule( ) override;
};
#include "FluidSurface.h"

IMPLEMENT_MODULE( FFluidSurface, FluidSurface )



void FFluidSurface::StartupModule()
{
// This code will execute after your module is loaded into memory (but after global variables are initialized, of course.)
Expand All @@ -23,7 +14,4 @@ void FFluidSurface::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
}



}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

#include "FluidSurfacePrivatePCH.h"
#include "FluidSurfaceActor.h"

#include "FluidSurfaceComponent.h"

AFluidSurfaceActor::AFluidSurfaceActor(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
Expand Down
42 changes: 17 additions & 25 deletions FluidSurface/Source/FluidSurface/Private/FluidSurfaceComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

#include "FluidSurfacePrivatePCH.h"
#include "FluidSurfaceComponent.h"

#include "FluidSurfaceRender.h"

#include "FluidSurfaceModifier.h"

#include "Particles/Emitter.h"
#include "Particles/ParticleSystemComponent.h"
#include "PhysicsEngine/BodySetup.h"
Expand Down Expand Up @@ -58,7 +61,7 @@ UFluidSurfaceComponent::UFluidSurfaceComponent(const FObjectInitializer& ObjectI
UpdateComponent = true;

/* Create dynamic delegate for overlapped event */
OnComponentBeginOverlap.AddDynamic( this, &UFluidSurfaceComponent::ComponentTouched );
OnComponentBeginOverlap.AddDynamic( this, &UFluidSurfaceComponent::ComponentBeginOverlap );
}

#if WITH_EDITOR
Expand Down Expand Up @@ -154,7 +157,8 @@ void UFluidSurfaceComponent::Pling( const FVector& Position, float Strength, flo
int HitX, HitY;
GetNearestIndex( Position, HitX, HitY );

PLingBuffer[ NumPLing ].LocalHitPosition = GetWorldToComponent( ).TransformPosition( Position );
PLingBuffer[ NumPLing ].LocalHitPosition = GetComponentTransform( ).Inverse( ).TransformPosition( Position );

PLingBuffer[ NumPLing ].HitX = HitX;
PLingBuffer[ NumPLing ].HitY = HitY;
PLingBuffer[ NumPLing ].Strength = Strength;
Expand All @@ -166,7 +170,7 @@ void UFluidSurfaceComponent::Pling( const FVector& Position, float Strength, flo
/** Get nearest index */
void UFluidSurfaceComponent::GetNearestIndex( const FVector& Pos, int& xIndex, int& yIndex )
{
FVector LocalPos = GetWorldToComponent( ).TransformPosition( Pos );
FVector LocalPos = GetComponentTransform( ).Inverse( ).TransformPosition( Pos );

xIndex = FMath::RoundToInt( ( LocalPos.X - FluidOrigin.X ) / FluidGridSpacing );
xIndex = FMath::Clamp( xIndex, 0, FluidXSize - 1 );
Expand Down Expand Up @@ -217,7 +221,7 @@ void UFluidSurfaceComponent::OnRegister( )
void UFluidSurfaceComponent::CreateRenderState_Concurrent()
{
/* Create render data */
RenderData = new FFluidSurfaceRenderData();
RenderData = MakeUnique< FFluidSurfaceRenderData >( );
RenderData->InitResources(this);

Super::CreateRenderState_Concurrent();
Expand Down Expand Up @@ -281,7 +285,7 @@ void UFluidSurfaceComponent::TickComponent( float DeltaTime, enum ELevelTick Tic
/* Dont care about self and modifiers */
if( Actor != NULL && !Actor->IsA( AFluidSurfaceActor::StaticClass( ) ) && !Actor->IsA( AFluidSurfaceModifier::StaticClass( ) ) )
{
FVector LocalVel = GetWorldToComponent( ).TransformVector( Actor->GetVelocity( ) );
FVector LocalVel = GetComponentTransform( ).Inverse( ).TransformVector( Actor->GetVelocity( ) );
float HorizVelMag = LocalVel.Size( );

Pling( Actor->GetActorLocation( ), RippleVelocityFactor * HorizVelMag, Actor->GetSimpleCollisionRadius( ) );
Expand All @@ -304,7 +308,7 @@ void UFluidSurfaceComponent::TickComponent( float DeltaTime, enum ELevelTick Tic
LocalRipplePos.Y = ( RippleRadius * FMath::Cos( TestRippleAng ) );
LocalRipplePos.Z = 0.f;

WorldRipplePos = ComponentToWorld.TransformPosition( LocalRipplePos );
WorldRipplePos = GetComponentTransform( ).Inverse( ).TransformPosition( LocalRipplePos );
Pling( WorldRipplePos, TestRippleStrength, TestRippleRadius );
}

Expand Down Expand Up @@ -339,24 +343,24 @@ void UFluidSurfaceComponent::ReceiveComponentDamage( float DamageAmount, FDamage
/* Spawn shoot effect emitter */
FRotator Rotation = FRotator( 0, 0, 0 );
AEmitter* Emitter = GetWorld( )->SpawnActor<AEmitter>( HitLocation, Rotation );
Emitter->ParticleSystemComponent->SetTemplate( ShootEffect );
Emitter->GetParticleSystemComponent( )->SetTemplate( ShootEffect );
}
}

/** Called when an object has overlapped this component */
void UFluidSurfaceComponent::ComponentTouched( AActor* Other, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult )
void UFluidSurfaceComponent::ComponentBeginOverlap( UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult )
{
if( !Other )
if( !OtherActor )
return;

FVector ActorLocation = Other->GetActorLocation( );
FVector ActorLocation = OtherActor->GetActorLocation( );

if( TouchEffect )
{
/* Spawn touch effect emitter */
FRotator Rotation = FRotator( 0, 0, 0 );
AEmitter* Emitter = GetWorld( )->SpawnActor<AEmitter>( ActorLocation, Rotation );
Emitter->ParticleSystemComponent->SetTemplate( TouchEffect );
Emitter->GetParticleSystemComponent( )->SetTemplate( TouchEffect );
}
}

Expand All @@ -374,7 +378,7 @@ void UFluidSurfaceComponent::UpdateBody( )
FVector BoxExtents = FluidBoundingBox.GetExtent( );
FKBoxElem& BoxElem = *new ( BodySetup->AggGeom.BoxElems ) FKBoxElem( BoxExtents.X * 2, BoxExtents.Y * 2, BoxExtents.Z * 2 );
BoxElem.Center = FVector::ZeroVector;
BoxElem.Orientation = GetComponentQuat( );
BoxElem.Rotation = FRotator( GetComponentQuat( ) );

BodySetup->ClearPhysicsMeshes( );
BodySetup->CreatePhysicsMeshes( );
Expand Down Expand Up @@ -446,18 +450,6 @@ void UFluidSurfaceComponent::BeginDestroy( )
Super::BeginDestroy( );
}

void UFluidSurfaceComponent::CreatePhysicsState( )
{
#if WITH_EDITOR
if( bPhysicsStateCreated )
DestroyPhysicsState( );

UpdateBody( );
#endif

return Super::CreatePhysicsState( );
}

UBodySetup* UFluidSurfaceComponent::GetBodySetup( )
{
return BodySetup;
Expand Down
12 changes: 0 additions & 12 deletions FluidSurface/Source/FluidSurface/Private/FluidSurfacePrivatePCH.h

This file was deleted.

53 changes: 37 additions & 16 deletions FluidSurface/Source/FluidSurface/Private/FluidSurfaceRender.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@

#include "FluidSurfacePrivatePCH.h"

#include "TessellationRendering.h"
#include "PhysicsEngine/BodySetup.h"
#include "FluidSurfaceRender.h"

#include "EngineGlobals.h"
#include "RHI.h"
#include "RenderResource.h"
#include "RenderingThread.h"
#include "VertexFactory.h"
#include "PackedNormal.h"
#include "LocalVertexFactory.h"
#include "PrimitiveViewRelevance.h"
#include "Materials/MaterialInterface.h"
#include "Materials/MaterialInstanceDynamic.h"
#include "PrimitiveSceneProxy.h"
#include "Engine/CollisionProfile.h"
#include "Curves/CurveFloat.h"
#include "SceneManagement.h"
#include "Engine/Engine.h"
#include "Engine/LevelStreaming.h"
#include "LevelUtils.h"
#include "ShowFlags.h"
#include "Camera/CameraTypes.h"
#include "Materials/MaterialInstanceDynamic.h"
#include "Engine/SceneCapture2D.h"
#include "Engine/Texture2DDynamic.h"
#include "Engine/TextureRenderTarget2D.h"
#include "DynamicMeshBuilder.h"
#include "Components/SceneCaptureComponent2D.h"
#include "StaticMeshResources.h"

#include "FluidSurfaceComponent.h"

/** Render Data */

FFluidSurfaceRenderData::FFluidSurfaceRenderData( )
: HasTessellationData( false )
{
}

/** Initialise render resources */
void FFluidSurfaceRenderData::InitResources( UFluidSurfaceComponent* Component )
{
Expand Down Expand Up @@ -578,7 +599,7 @@ FFluidSurfaceSceneProxy::FFluidSurfaceSceneProxy( UFluidSurfaceComponent* Compon
, Material( NULL )
, DynamicData( NULL )
, BodySetup( Component->BodySetup )
, RenderData( Component->RenderData )
, RenderData( Component->RenderData.Get( ) )
, MaterialRelevance( Component->GetMaterialRelevance( GetScene( ).GetFeatureLevel( ) ) )
, Time( 0.0f )
, LevelColor( 1,1,1 )
Expand All @@ -601,6 +622,12 @@ FFluidSurfaceSceneProxy::~FFluidSurfaceSceneProxy( )
if( DynamicData != NULL ) { delete DynamicData; }
}

SIZE_T FFluidSurfaceSceneProxy::GetTypeHash( ) const
{
static size_t UniquePointer;
return reinterpret_cast< size_t >( &UniquePointer );
}

/** Returns the view revelance */
FPrimitiveViewRelevance FFluidSurfaceSceneProxy::GetViewRelevance( const FSceneView* View )
{
Expand All @@ -613,12 +640,6 @@ FPrimitiveViewRelevance FFluidSurfaceSceneProxy::GetViewRelevance( const FSceneV
return Result;
}

/** Can mesh be occluded */
bool FFluidSurfaceSceneProxy::CanBeOccluded( ) const
{
return !MaterialRelevance.bDisableDepthTest;
}

/** Memory footprint */
uint32 FFluidSurfaceSceneProxy::GetMemoryFootprint( ) const
{
Expand Down
15 changes: 10 additions & 5 deletions FluidSurface/Source/FluidSurface/Private/FluidSurfaceRender.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

#pragma once

#include "FluidSurfaceEngine.h"

#include "TessellationRendering.h"
#include "PhysicsEngine/BodySetup.h"

#include "FluidSurfaceActor.h"

#define MAX_FLUID_PLINGS 1024

/** PLing Parameters */
Expand Down Expand Up @@ -67,9 +74,7 @@ struct FReadBufferStructured
class FFluidSurfaceRenderData
{
public:

/** Default constructor */
FFluidSurfaceRenderData( );
FFluidSurfaceRenderData( ) { }

/** Initialise required resources */
void InitResources( UFluidSurfaceComponent* Component );
Expand Down Expand Up @@ -139,11 +144,11 @@ class FFluidSurfaceSceneProxy : public FPrimitiveSceneProxy
virtual ~FFluidSurfaceSceneProxy( );

/* Begin UPrimitiveSceneProxy interface */
virtual SIZE_T GetTypeHash( ) const override;
virtual FPrimitiveViewRelevance GetViewRelevance( const FSceneView* View );
virtual bool CanBeOccluded( ) const override;
virtual uint32 GetMemoryFootprint( ) const;
uint32 GetAllocatedSize( ) const;
virtual void GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const override;
virtual void GetDynamicMeshElements( const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector ) const override;
/* End UPrimitiveSceneProxy interface */

/* Set data sent from the game thread */
Expand Down
Loading