Toward the goal of Havok providing low level data on lines ancolors, it would be great to know how Havok provides that data over its debug interface. Until we have that, it might be useful to speculate.
On the other “side” of the interface, what BABYLON features can we take advantage of for visualization? I suggest the best candidate is a LinesSystem. In particular, the VertexData for a LinesSystem is likely the lowest level BABYLON data structure that would be useful. VertexData could be seamlessly visualized with vertexdata.applyToMesh(). One level above that would be Vector3 data as parameters to CreateLineSystemVertexData() which is of the form
{ colors?: Nullable<Color4[][]>;
lines: Vector3[][];
}
Knowing that low-level havok uses heaps and consecutive floating point values, conversion to the above lines/colors structure might involve copying data around. It also might be inefficient for Havok to repeat the color information implied by the above structure, which is an indicator (at least to me) on whether Havok might supply the color information that way.
The most efficient way that I can think of is Havok to supply a Float32Array for lines to be interpreted as Float32Array[3][2]. And a color array as either Float32Array[3][1] or (slightly less space efficient) Float32Array[3][2], the latter at least matching the size of the line array, and matching color index to line vertex index wherein each color index is repeated for each of two line vetices.
It’s unclear to me now what the output of CreateLineSystemVertexData() exactly is. Given that mesh vertex data is generally in triangles, I’m not sure what VertexData from lines actually looks like. Is it possible Havok might produce that directly? Maybe, but I (without evidence) doubt it.
I’ll dig more into that when I have time.
For contact points implemented with thinInstance, the most useful low level data structure is a Float32Array containing 4x4 matrices, one for each translation point. One step above that (and much more likely, IMO) is as a Float32Array interpreted as Float32Array[3] or, above that, Vector3.
Edit: good news! CreateLineSystemVertexData() generates a linear array of numbers, sort of ignoring the “array of arrays” in the specified lines parameter. Additionally, VertexData allows number[ ] or Float32Array. My primary concern of somehow a mesh being triangles is now not a concern. I have confidence that if Havok produced a Float32Array of line segments each with two points, it can be used directly in VertexData and subsequently .applyToMesh.
CreateLineSystemVertexData() additionally creates a consecutive list of indices, which I think could be ignored (or easily created). The last bit is a list of colors in a Color4 array of similar construction, thus requiring a pair of Color4 objects per line segment. If Havok creates this natively, great! If not, creating it from a list of single colors or Color3 objects per line segment would be straightforward at some performance cost.