Commit fc35916f authored by Jan Kremer's avatar Jan Kremer

Fixed scaling origin. Working on transparency...

parent 75b05553
......@@ -98,6 +98,8 @@ DoubleClickTime=0.200000
+AxisMappings=(AxisName="NonVR_LeftHand_Roll",Scale=-1.000000,Key=Gamepad_DPad_Right)
+AxisMappings=(AxisName="NonVR_LeftHand_Roll",Scale=1.000000,Key=Gamepad_DPad_Left)
+AxisMappings=(AxisName="NonVR_RightHand_Pitch",Scale=-1.000000,Key=Gamepad_FaceButton_Bottom)
+AxisMappings=(AxisName="NonVR_LeftHand_MoveX",Scale=1.000000,Key=NumPadFour)
+AxisMappings=(AxisName="NonVR_LeftHand_MoveX",Scale=-1.000000,Key=NumPadSix)
DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks
ConsoleKey=None
-ConsoleKeys=Tilde
......
No preview for this file type
......@@ -95,6 +95,8 @@ AxisMappings=(AxisName="NonVR_LeftHand_Pitch",Scale=-1.000000,Key=Gamepad_DPad_D
AxisMappings=(AxisName="NonVR_LeftHand_Roll",Scale=-1.000000,Key=Gamepad_DPad_Right)
AxisMappings=(AxisName="NonVR_LeftHand_Roll",Scale=1.000000,Key=Gamepad_DPad_Left)
AxisMappings=(AxisName="NonVR_RightHand_Pitch",Scale=-1.000000,Key=Gamepad_FaceButton_Bottom)
AxisMappings=(AxisName="NonVR_LeftHand_MoveX",Scale=1.000000,Key=NumPadFour)
AxisMappings=(AxisName="NonVR_LeftHand_MoveX",Scale=-1.000000,Key=NumPadSix)
ConsoleKey=None
ConsoleKeys=Tilde
ConsoleKeys=Caret
......
......@@ -9,6 +9,8 @@
#include "Engine/Texture2D.h"
#include "UObject/ConstructorHelpers.h"
#include "Logging/MessageLog.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
#include "Runtime/Engine/Classes/GameFramework/Pawn.h"
#define IS_PROPERTY(Name) PropertyChangedEvent.MemberProperty->GetName().Equals(#Name)
......@@ -423,7 +425,7 @@ int32 UPointCloud::GetPointCount(bool bCountOnlyEnabled) const
return bCountOnlyEnabled ? FPointCloudHelper::CountEnabledPoints(Points) : Points.Num();
}
void UPointCloud::Rebuild(bool bForced)
void UPointCloud::Rebuild(bool bForced, bool bForceRenderDataDirty)
{
if (bForced)
{
......@@ -435,6 +437,11 @@ void UPointCloud::Rebuild(bool bForced)
bTreeDirty |= bReductionDirty;
bool bBoundsDirty = bTransformDirty;
if (bForceRenderDataDirty)
{
bRenderDataDirty = true;
}
float MaxProgress = (2 * bTransformDirty) + (2 * bReductionDirty) + bTreeDirty + bMaterialDirty + bBoundsDirty + bRenderDataDirty + 1;
FScopedSlowTask Progress(MaxProgress, LOCTEXT("Rebuild", "Rebuilding Cloud..."));
......@@ -721,6 +728,52 @@ void UPointCloud::SetPointCloudData(TArray<FPointCloudPoint> &InPoints, bool bRe
}
}
void UPointCloud::SortPoints()
{
struct FCompareParticleOrderZ
{
FORCEINLINE bool operator()(const FVector& A, const FVector& B) const { return B.Z < A.Z; }
};
FVector CamLocation = UGameplayStatics::GetPlayerCameraManager(WorldContextObject, 0)->GetCameraLocation();
TArray<FVector> PointOrder = TArray<FVector>();
PointOrder.Init(FVector(0, 0, 0), Points.Num());
for (int32 PointIndex = 0; PointIndex < Points.Num(); PointIndex++)
{
FVector Location = Points[PointIndex].Location;
float InZ = (CamLocation - Location).SizeSquared();
PointOrder[PointIndex] = FVector(PointIndex, 0, InZ);
//PointOrder[PointIndex].X = PointIndex;
//PointOrder[PointIndex].Z = InZ;
}
Sort(&(PointOrder[0]), Points.Num(), FCompareParticleOrderZ());
TArray<FPointCloudPoint> NewPoints = TArray<FPointCloudPoint>();
NewPoints.Init(FPointCloudPoint(), Points.Num());
for (int32 i = 0; i < Points.Num(); i++)
{
int32 PointIndex = PointOrder[i].X;
NewPoints[PointIndex] = Points[i];
}
Points = NewPoints;
UE_LOG(LogTemp, Warning, TEXT("[0] %f"), PointOrder[0].Z);
UE_LOG(LogTemp, Warning, TEXT("[1] %f"), PointOrder[1].Z);
UE_LOG(LogTemp, Warning, TEXT("[2] %f"), PointOrder[2].Z);
UE_LOG(LogTemp, Warning, TEXT("[100] %f"), PointOrder[100].Z);
UE_LOG(LogTemp, Warning, TEXT("[400] %f"), PointOrder[400].Z);
Rebuild(false, true);
}
void UPointCloud::SetSettings(UPointCloudSettings *Settings)
{
if (Settings)
......
......@@ -3,6 +3,7 @@
#include "PointCloudComponent.h"
#include "Engine/CollisionProfile.h"
#include "PointCloud.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
UPointCloudComponent::UPointCloudComponent( const FObjectInitializer& ObjectInitializer )
: Super( ObjectInitializer )
......@@ -55,6 +56,9 @@ void UPointCloudComponent::SetPointCloud(UPointCloud *InPointCloud)
{
RemovePointCloudListener();
PointCloud = InPointCloud;
APawn* Pawn = UGameplayStatics::GetPlayerPawn(GetOwner(), 0);
UObject* Object = Cast<UObject>(Pawn);
PointCloud->WorldContextObject = Object;
AttachPointCloudListener();
OnPointCloudRebuilt();
}
......
......@@ -964,10 +964,11 @@ FBox FPointCloudHelper::CalculateBounds(const TArray<FPointCloudPoint>& Points)
for (int32 Index = 0; Index < Points.Num(); Index++)
{
/*
if (!Points[Index].IsEnabled())
{
continue;
}
}*/
BoundingBox += Points[Index].Location;
}
......
......@@ -307,12 +307,14 @@ struct FPointCloudProxy
TArray<FPointCloudIndexBuffer> IndexBuffers;
private:
UPointCloud *PointCloud;
UPointCloudComponent *Component;
FTransform CurrentTransform;
bool bDirty;
public:
UPointCloud *PointCloud;
FPointCloudProxy() : bDirty(true) {}
~FPointCloudProxy()
{
......@@ -442,6 +444,30 @@ public:
#endif
Collector.AddMesh(ViewIndex, MeshBatch);
/*
const FSceneView* View = Views[ViewIndex];
const FPointCloudSceneProxy* Proxy = this;
int32 ParticleCount = PointCloudProxy.IndexBuffers[LOD].NumPrimitives;
FParticleOrder* ParticleOrder = NULL;
ParticleOrder = (FParticleOrder*)FMemStack::Get().Alloc(sizeof(FParticleOrder)* ParticleCount, alignof(FParticleOrder));
SortSpriteParticles(ParticleCount, View, Proxy->GetLocalToWorld(), ParticleOrder, Proxy->PointCloudProxy.PointCloud);
FGlobalDynamicVertexBuffer::FAllocation Allocation;
// Allocate memory for render data.
int32 NumVerticesPerParticleInBuffer = 4;
int32 VertexStride = sizeof(FParticleSpriteVertex);
Allocation = FGlobalDynamicVertexBuffer::Get().Allocate(ParticleCount * VertexStride * NumVerticesPerParticleInBuffer);
// Fill vertex buffers.
GetVertexAndIndexData(Allocation.Buffer, ParticleOrder, ParticleCount, VertexStride);
// TODO
*/
}
}
}
......@@ -451,6 +477,71 @@ public:
}
}
/*
void SortSpriteParticles(int32 ParticleCount, const FSceneView* View, const FMatrix& LocalToWorld, FParticleOrder* ParticleOrder, UPointCloud * PointCloud) const
{
struct FCompareParticleOrderZ
{
FORCEINLINE bool operator()(const FParticleOrder& A, const FParticleOrder& B) const { return B.Z < A.Z; }
};
for (int32 ParticleIndex = 0; ParticleIndex < ParticleCount; ParticleIndex++)
{
//DECLARE_PARTICLE(Particle, ParticleData + ParticleStride * ParticleIndices[ParticleIndex]);
FVector Location = PointCloud->GetPointCloudData()[ParticleIndex].Location;
float InZ;
if (true)
{
InZ = View->ViewMatrices.GetViewProjectionMatrix().TransformPosition(LocalToWorld.TransformPosition(Location)).W;
}
else
{
InZ = View->ViewMatrices.GetViewProjectionMatrix().TransformPosition(Location).W;
}
ParticleOrder[ParticleIndex].ParticleIndex = ParticleIndex;
ParticleOrder[ParticleIndex].Z = InZ;
}
Sort(ParticleOrder, ParticleCount, FCompareParticleOrderZ());
}
bool GetVertexAndIndexData(void* VertexData, FParticleOrder* ParticleOrder, int32 ParticleCount, int32 VertexStride) const
{
// Pack the data
int32 ParticleIndex;
uint8* TempVert = (uint8*)VertexData;
FParticleSpriteVertex* FillVertex;
FVector ParticlePosition;
FVector ParticleOldPosition;
for (int32 i = 0; i < ParticleCount; i++)
{
ParticleIndex = ParticleOrder[i].ParticleIndex;
DECLARE_PARTICLE_CONST(Particle, ParticleData + Source.ParticleStride * ParticleIndices[ParticleIndex]);
if (i + 1 < ParticleCount)
{
int32 NextIndex = ParticleOrder[i + 1].ParticleIndex;
DECLARE_PARTICLE_CONST(NextParticle, ParticleData + Source.ParticleStride * ParticleIndices[NextIndex]);
FPlatformMisc::Prefetch(&NextParticle);
}
ParticlePosition = Particle.Location;
ParticleOldPosition = Particle.OldLocation;
FillVertex = (FParticleSpriteVertex*)TempVert;
FillVertex->Position = ParticlePosition;
FillVertex->Color = Particle.Color;
TempVert += VertexStride;
}
return true;
}*/
virtual FPrimitiveViewRelevance GetViewRelevance(const FSceneView* View) const override
{
FPrimitiveViewRelevance Result;
......
......@@ -451,7 +451,7 @@ public:
/** Rebuilds the cloud using current settings */
UFUNCTION(BlueprintCallable, Category = "Point Cloud")
void Rebuild(bool bForced = false);
void Rebuild(bool bForced = false, bool bForceRenderDataDirty = false);
/** Permanently strips all disabled points */
UFUNCTION(BlueprintCallable, Category = "Point Cloud")
......@@ -488,6 +488,9 @@ public:
UFUNCTION(BlueprintCallable, Category = "Point Cloud")
void SetPointCloudData(UPARAM(ref) TArray<FPointCloudPoint> &InPoints, bool bRebuildCloud = true);
UFUNCTION(BlueprintCallable, Category = "Point Cloud")
void SortPoints();
/** Bulk sets the new settings from the ones provided */
void SetSettings(UPointCloudSettings *Settings);
......@@ -495,6 +498,8 @@ public:
FORCEINLINE float GetDistanceThreshold(uint8 LOD) { return DistanceThresholds[LOD]; }
UObject* WorldContextObject;
private:
void CalculateDistanceThresholds();
void CacheAssetRegistryTags();
......
......@@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "PointCloud.h"
#include "PointCloudShared.h"
class UMaterial;
......
......@@ -5,6 +5,7 @@
#include "PointCloudComponent.h"
#include "Runtime/Engine/Classes/Kismet/KismetMathLibrary.h"
#include "Runtime/Core/Public/Async/ParallelFor.h"
#include "PointCloudHelper.h"
// Sets default values
APlot3D::APlot3D()
......@@ -85,7 +86,7 @@ void APlot3D::InitPoints()
void APlot3D::InitCloud()
{
PointCloud = NewObject<UPointCloud>();
PointCloud->Offset = EPointCloudOffset::None;
PointCloud->Offset = EPointCloudOffset::Center;
PointCloud->SetRenderingMethod(EPointCloudRenderMethod::Sprite_Lit_RGB, false);
PointCloud->SpriteMask = EPointCloudSpriteMask::Circle;
//PointCloud->SpriteTexture =
......@@ -111,12 +112,14 @@ FColor APlot3D::CalculateColorOfPoint(int32 Index, float Min, float Max)
void APlot3D::RebuildCloud()
{
PointCloud->SetPointCloudData(Points, true);
Center = FPointCloudHelper::CalculateBounds(Points).GetCenter();
}
FVector APlot3D::CalculateWorldLocOfPoint(FPointCloudPoint * Point)
{
FVector ActorScale = GetActorScale3D() * 100;
FVector Vec = FVector(ActorScale.X * Point->Location.X * -1, ActorScale.Y * Point->Location.Y, ActorScale.Z * Point->Location.Z);
FVector Vec = FVector(ActorScale.X * (Point->Location.X - Center.X) * -1, ActorScale.Y * (Point->Location.Y - Center.Y), ActorScale.Z * (Point->Location.Z - Center.Z));
FVector RotatedVec = GetActorRotation().RotateVector(Vec);
FVector SumVec = GetActorLocation() + RotatedVec;
return SumVec;
......
......@@ -29,6 +29,7 @@ private:
FColor CalculateColorOfPoint(int32 Index, float Min, float Max);
void RebuildCloud();
FVector CalculateWorldLocOfPoint(FPointCloudPoint* Point);
FVector Center;
UPROPERTY(Category = PointCloudActor, VisibleAnywhere, BlueprintReadOnly, meta = (ExposeFunctionCategories = "Rendering,Components|PointCloud", AllowPrivateAccess = "true"))
class UPointCloudComponent* PointCloudComponent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment