hello,
Im creating a custom distribution vector parameter based on “UDistributionVectorConstantCurve” for a Particle system.
I already implemented one based on “UDistributionVectorConstant” without any major problem.
however when Implementing this , the override of the function GetValue comes with all the parameters as null and therefore I cant manipulate the data.
Any clues of what Im doing wrong?
or am I missing something?
here`s the code
DistributionCurveParameter.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Distributions/DistributionVectorConstantCurve.h"
#include "DistributionCurveParameter.generated.h"
/**
*
*/
UCLASS()
class RAILTEST_API UDistributionCurveParameter : public UDistributionVectorConstantCurve
{
GENERATED_BODY()
UDistributionCurveParameter();
UPROPERTY(EditAnywhere)
float numPointsParam;
UPROPERTY(EditAnywhere)
int numKeysCreated;
UPROPERTY(EditAnywhere)
int numSubCurves;
UPROPERTY(EditAnywhere)
FName numPiointsName;
virtual bool IsPostLoadThreadSafe() const override;
virtual FVector GetValue(float F = 0.f, UObject* Data = NULL, int32 LastExtreme = 0, struct FRandomStream* InRandomStream = NULL) const override;
private:
bool GetParamValue(UObject* Data, FName ParamName, float& OutVector) const;
};
DistributionCurveParameter.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "../Public/DistributionCurveParameter.h"
#include "Particles/ParticleSystemComponent.h"
UDistributionCurveParameter::UDistributionCurveParameter()
{
numPiointsName = "numPoints";
numPointsParam=GetParamValue(this,numPiointsName,numPointsParam);
numSubCurves = GetNumSubCurves();
}
bool UDistributionCurveParameter::IsPostLoadThreadSafe() const
{
return true;
}
FVector UDistributionCurveParameter::GetValue(float F, UObject * Data, int32 LastExtreme, FRandomStream * InRandomStream) const
{
if (!Data)
return FVector(0, 0, 0);
else
return FVector(0, -555, -999);
}
bool UDistributionCurveParameter::GetParamValue(UObject * Data, FName ParamName, float & OutVector) const
{
bool bFoundParam = false;
UParticleSystemComponent* ParticleComp = Cast<UParticleSystemComponent>(Data);
if (ParticleComp)
{
bFoundParam = ParticleComp->GetFloatParameter(ParamName, OutVector);
}
return bFoundParam;
}