Hello Everyone.
I’ve been trying to integrate VTK into Unreal Engine for months.
I wrote a plugin to wrap VTK using as a thirdparty library.
The plugin module built with RTTI enabled due to compiling VTK on Linux.
But everything else follows Unreal Rules by turning off RTTI.
Almost VTK works pretty, but there is critical problems.
That’s what vtk array doesn’t correctly map internal memory layout for component and tuple.
Here is simple c++ codes,
float colorMap[8][4] =
{
{ 0.0, 0.0, 0.0, 1.0 },
{ 0.3, 0.0, 0.0, 1.0 },
{ 0.6, 0.0, 0.0, 1.0 },
{ 0.9, 0.0, 0.0, 1.0 },
{ 0.9, 0.3, 0.3, 1.0 },
{ 0.9, 0.6, 0.6, 1.0 },
{ 0.9, 0.9, 0.9, 1.0 },
{ 1.0, 1.0, 1.0, 1.0 }
};
vtkNew < vtkFloatArray > array; // (e.g almost arrays is derived from vtkAOSDataArrayTemplate)
array->SetNumberOfComponents(4);
for (int i=0;i<8;i++) {
array->InsertNextTuple(colorMap[i]);
}
int numComps = array->GetNumberOfComponents();
int numTuples = array->GetNumberOfTuples();
At results, console program print 4 number of components and 8’s tuples, that works correctly as expect.
At Unreal side, that always print 31 number of components and only 1’s tuple.
It’s definitely incorrect.
[EDIT] There is a little bit mistake. number of components is constantly 31 not 33 for the colorMap.
I have frequently cross checked in some scenarios.
First, checked out if there is no stdc++ runtime compatible issues,
because both implement each diffrent memory allocators, vtk use standard c++'s malloc, new, delete but Unreal use FMalloc which implements mimalloc internaly.
Resulty both use the same version’s stdc++ runtime in Linux so there is no problems.
Second, I tested with two VTK build versions, one is built with gcc 14 or later in Linux, other is built by compiler clang++18 Unreal Engine provide byself.
Unfortunately that result same thing.
Finally, there is another issue,VTK Polydata Reader get failed to read cell data such normals, scalars via vtkCellData in Unreal but works in the console app.
I’m not sure this issue coming from array issue first said.
I use VTK 9.4.1 or 9.4.2, and with Unreal 5.5.4.
Have anyone same experience?
Welcome anyone help me.