Download

Why is my identity transform not valid?

In my setup code I have this:



newTile->Transform = FTransform();
newTile->Transform.NormalizeRotation();
newTile->Dirty = true;
newTile->Valid = true;


And later on I am adding that tile to a Hierarchical Static Mesh Instance (HISM):



if (TileMeshInstances.Contains(tileMesh))
{
	UHierarchicalInstancedStaticMeshComponent* hism = TileMeshInstances[tileMesh];
	hism->AddInstance(tile->Transform);
}
else
{
	int32 hismCount = TileMeshInstances.Num();
	FString hismName = FString::Printf(TEXT("TileMeshInstance_%d"), hismCount);
	UHierarchicalInstancedStaticMeshComponent* hism = NewObject<UHierarchicalInstancedStaticMeshComponent>(this, UHierarchicalInstancedStaticMeshComponent::StaticClass(), *hismName);
	hism->RegisterComponent();
	hism->AttachTo(RootComponent);
	hism->AddInstance(tile->Transform);
	TileMeshInstances.Add(tileMesh, hism);
}


However whenever I try to add a new Instance to the HISM, I get an exception complaining that my rotation is not normalized. So as you can see in the setup code I very specifically added a second call after adding the transform, to normalize the rotation (whatever the heck that means) but it still won’t work and says it isn’t normalized.

Hmm ok it looks like I have a bug somewhere. I just printed out my transform at the time of adding it, and its not correct. It has been set to all 0’s, no matter what it was originally.

Try doing FTransform::Identity();

The normal constructor gives you a proper identity. I had a logic error in my code.