FPackedNormal to FVector Unreal 4.12 Issue

It looks like a couple of new items have been added to FPackedNormal:

void operator=(const FVector4& InVector);
operator FVector4() const;

So, when I call

FVector Test(SomeFPackedNormal);

I get this error thrown up:

error C2668: 'FVector::FVector': ambiguous call to overloaded function
note: could be 'FVector::FVector(FVector &&)'
note: or       'FVector::FVector(const FVector &)'
note: or       'FVector::FVector(EForceInit)'
note: or       'FVector::FVector(FIntPoint)'
note: or       'FVector::FVector(FIntVector)'
note: or       'FVector::FVector(const FLinearColor &)'
note: or       'FVector::FVector(const FVector4 &)'
 note: or       'FVector::FVector(float)'
 note: while trying to match the argument list '(FPackedNormal)'
error C2668: 'FVector::FVector': ambiguous call to overloaded function
 note: could be 'FVector::FVector(FVector &&)'
 note: or       'FVector::FVector(const FVector &)'
 note: or       'FVector::FVector(EForceInit)'
 note: or       'FVector::FVector(FIntPoint)'
 note: or       'FVector::FVector(FIntVector)'
 note: or       'FVector::FVector(const FVector4 &)'
 note: or       'FVector::FVector(float)'
 note: while trying to match the argument list '(FPackedNormal)'

This was also not the case before in 4.11. So, it seems like the new equality overloads make it unsure whether to convert to FVector or FVector4?

Hey Brandelan-

With

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Test)
FVector Rando;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Test)
FPackedNormal MoreRando;

in the header and Rando(MoreRando); in the constructor, I get the same error in 4.12.5 and 4.11.2 of “term does not evaluate to a function taking 1 arguments”. Can you provide the code you’re using to take advantage of FPackedNormal?

Sure. I’m pretty sure I just referenced code from the UProceduralMeshComponent already existing in the engine:

/** One vertex for the procedural mesh, used for storing data internally */
USTRUCT()
struct FDynamicMeshVertex
{
GENERATED_USTRUCT_BODY()

/** Vertex position */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Vertex)
FVector Position;

/** Vertex position */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Vertex)
FVector2D UV0;

/** Vertex tangent */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Vertex)
FPackedNormal TangentX;

/** Vertex tangent */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Vertex)
FPackedNormal TangentZ;

UPROPERTY()
FColor Color;


FDynamicMeshVertex()
: Position(0.f, 0.f, 0.f)
, TangentX(FVector(1.f, 0.f, 0.f))
, TangentZ(FVector(0.f, 0.f, 1.f)),
UV0(0.f, 0.f),
Color(FColor(255, 255, 255))
{}

FVector GetTangentY()
{
return (FVector(TangentZ) ^ FVector(TangentX)) * ((float)TangentZ.Vector.W / 127.5f - 1.0f);
}
};

That worked for me in 4.11 and 4.10 if I recall correctly. It’s just the GetTangentY function.

I tried to test this but did not get any compile error with my code. In my header file I declared my FPackedNormal as a

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Test)
FPackedNormal PackedNorm;

When I added the line FVector(PackedNorm); in my constructor I was able to compile successfully. Can you let me know if I missed anything in my setup as well as provide the exact error you’re getting? Are you getting this error in Visual Studio or the editor?If this is in the editor, what exactly are you doing to call the code?

Hey Brandelan-

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.

Cheers

I still have the issue. All I’ve been able to do is work around it. When I have code where I have to convert FPackedNormal back to an FVector:

	FPackedNormal newItem(FVector(1,1,1));

	FVector test2(newItem);

I get this error:

error C2668: 'FVector::FVector': ambiguous call to overloaded function
2>  c:\program files\epic games\4.12\engine\source\runtime\core\public\math\Vector.h(969): note: could be 'FVector::FVector(FVector &&)'
2>  c:\program files\epic games\4.12\engine\source\runtime\core\public\math\Vector.h(969): note: or       'FVector::FVector(const FVector &)'
2>  c:\program files\epic games\4.12\engine\source\runtime\core\public\math\Vector.h(1227): note: or       'FVector::FVector(EForceInit)'
2>  c:\program files\epic games\4.12\engine\source\runtime\core\public\math\Vector.h(1221): note: or       'FVector::FVector(FIntPoint)'
2>  c:\program files\epic games\4.12\engine\source\runtime\core\public\math\Vector.h(1215): note: or       'FVector::FVector(FIntVector)'
2>  c:\program files\epic games\4.12\engine\source\runtime\core\public\math\Vector.h(1209): note: or       'FVector::FVector(const FLinearColor &)'
2>  C:\Program Files\Epic Games\4.12\Engine\Source\Runtime\Core\Public\Math\UnrealMath.h(65): note: or       'FVector::FVector(const FVector4 &)'
2>  c:\program files\epic games\4.12\engine\source\runtime\core\public\math\Vector.h(1197): note: or       'FVector::FVector(float)'

I tried adding the two lines from your previous comment into the header file / constructor / and BeginPlay() functions of an actor class. Compiling with the code in the header file gave syntax errors and the other two both returned “Unresolved External” errors. I also tried this code in a 4.11 project with the same result. If possible, could you provide a sample project where you are receiving errors on compile?