Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problems caused by Ammo update #43

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Sources/bullet/Bt.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,30 @@ enum abstract CollisionObjectActivationState(Int) from Int to Int {
#if hl
abstract BulletString(hl.Bytes) from hl.Bytes to hl.Bytes {
#else
abstract BulletString(String) from String to String {
abstract BulletString(Int) from Int to Int {
#end
public inline function toHaxeString(): String {
#if js
return js.Syntax.code("Ammo.UTF8ToString({0})", this);
// Not available in currently used version of ammo.js
// TODO remove custom utf8 conversion code when updating ammo
// return js.Syntax.code("Ammo.UTF8ToString({0})", this);

return js_UTF8ToString(this);
#elseif hl
return @:privateAccess String.fromUTF8(this);
#end
}

#if js
function js_UTF8ToString(heapOffset: Int) {
final heap: js.lib.Uint8Array = js.Syntax.code("Ammo.HEAPU8");
var end = heapOffset;
while (heap[end] != 0) {
end++;
}
return haxe.io.Bytes.ofData(heap.buffer).getString(heapOffset, end - heapOffset, UTF8);
}
#end
}

#if hl
Expand Down
1,600 changes: 657 additions & 943 deletions ammo/ammo.js

Large diffs are not rendered by default.

Loading