Need some help with Haxe, hl and webidl

The SoftBody trait has implementations of creating a SoftBody for both js and hl targets. However, the hl one currently does not compile.

characters 47-60 : Array<Float> should be webidl.NativePtr<Single>

characters 47-60 : For function argument 'vertices'

I believe this is due to the incorrect passing of arguments.

In my case, The Haxe code looks like so:

#if js
		body = helpers.CreateFromTriMesh(worldInfo, cast positions, cast vecind, numtri, true);
		var positionArray : Array<Float>; 
		positionArray = cast positions; //positions: Float32Array
		body = helpers.CreateFromTriMesh(worldInfo, positionArray, cast vecind, numtri, true);

The bullet.idl looks like so:

btSoftBody CreateFromTriMesh([Ref] btSoftBodyWorldInfo worldInfo, float[] vertices, long[] triangles, long ntriangles, boolean randomizeConstraints);

And my bullet.cpp looks like so:

HL_PRIM _ref(btSoftBody)* HL_NAME(btSoftBodyHelpers_CreateFromTriMesh5)(_ref(btSoftBodyHelpers)* _this, _ref(btSoftBodyWorldInfo)* worldInfo, float* vertices, int* triangles, int ntriangles, bool randomizeConstraints) {
	return alloc_ref((_unref(_this)->CreateFromTriMesh(*_unref(worldInfo), vertices, triangles, ntriangles, randomizeConstraints)),btSoftBody);
DEFINE_PRIM(_IDL, btSoftBodyHelpers_CreateFromTriMesh5, _IDL _IDL _BYTES _BYTES _I32 _BOOL);

Now, I would like to know what changes must I make to my Haxe code to resolve this issue. Any help regarding this would be great.

Best Regards,

I never really used hl directly, but maybe using hl.types.ArrayF32 might help you? Do you get the same error when using a Float32Array without casting?

If not, you could try to get some help on the Haxe or Kha discord channels, likely there are many people who know a lot about hl.

1 Like

Yes, I get a similar error when using Float32Array:

characters 47-56 : kha.arrays.Float32Array should be webidl.NativePtr<Single>

characters 47-56 : For function argument 'vertices'

This error is more in the lines of “Bullet needs a pointer to an array but you are passing an array” I guess.

1 Like