[Solved] How to extend haxebullet (Bullet.hx) within Armory3D

Update the title + include version to be more description (after study, it seem it pulls the haxebullet repo)
Update (11/04/2018) The solution is in the second reply.

Hello,

Following is my current test version:
Armory 0.5 with Blender 2.7b
Target for Krom

Windows 10 Build

I was struggle to find a way to extend the haxebullet (Bullet.hx) within Armory3D

I updated Bullet.hx, but when using them in the vehicle.hx, specially following btWheelInfo class, newly added attributes are not populated with values (return null).

But base on native Bullet (c++), it should be populated, and the ammon.js also have that attribute.

Following BOLD letters are new attributes.

Following are my test codes

    var wheelInfo:BtWheelInfo = vehicle.getWheelInfo(0);
  	trace("wheel 0" );
  	trace(wheelInfo.m_suspensionStiffness);
  	trace(wheelInfo.m_bIsFrontWheel);
  	trace(wheelInfo.m_deltaRotation);
  	trace(wheelInfo.m_wheelsRadius);

The original attribute m_suspensionStiffness will populate to 40.

While the other ones like
m_bIsFrontWheel
m_deltaRotation
m_wheelsRadius

are all null

in the trace

arm.VehicleBody:378: wheel 0
arm.VehicleBody:379: 40
arm.VehicleBody:380: null
arm.VehicleBody:381: null
arm.VehicleBody:382: null

For example:

like adding

public var m_rotation:BtScalar;
public var m_deltaRotation:BtScalar;

to Bullet.hx

#if js
@:native(‘Ammo.btWheelInfo’)
#elseif cpp
@:include(“BulletDynamics/Vehicle/btWheelInfo.h”)

public static function create(ci:BtWheelInfoConstructionInfo):BtWheelInfo;

#end

public var m_wheelsRadius:BtScalar;
public var m_suspensionStiffness:BtScalar;
public var m_wheelsDampingCompression:BtScalar;
public var m_wheelsDampingRelaxation:BtScalar;

public var m_frictionSlip:BtScalar;
public var m_steering:BtScalar;

public var m_rotation:BtScalar;
public var m_deltaRotation:BtScalar;
public var m_rollInfluence:BtScalar;
public var m_maxSuspensionForce:BtScalar;
public var m_engineForce:BtScalar;
public var m_brake:BtScalar;
public var m_bIsFrontWheel:Bool;

}

The new addition is like m_frictionSlip where it is public method in existing Bullet Physics h header file
BulletDynamics/Vehicle/btWheelInfo.h

https://github.com/armory3d/haxebullet/blob/master/cpp/bullet/BulletDynamics/Vehicle/btWheelInfo.h

After discussion with others on Discord (especially thanks to Lana Del DK), found the solution:

So the process is following in case others are interested:

need to update the ammo.js and other libs from latest build inside

armorysdk/armsdk/lib/haxebullet/js/ammo/

need to update the Bullet.hx with necessary changes inside

armorysdk/armsdk/lib/haxebullet/Sources/haxeBullet/Bullet.hx

, ensure in the Blender/Amorary Add On, click “clean project” and then restart blender (not sure if the restart is needed). Afterward, the new properties should be showing up

For the initial problem on this (about btWheelInfo extensions), a pull request is opened

1 Like

Awesome, thanks for the pull request. :slight_smile: Will add this to the docs. Blender restart should not be necessary, only needs that to register python changes.

@lubos Thanks for the feedback. I tested again without restart, and it works, so maybe I had something going on with Armory and Blender.

The clean step alone seem to be good enough to force the update.

If you work on the engine / library sources and get tired of cleaning you can also un-check Cache Compiler in the Armory Project panel. That will force it to recompile whenever project is played. :gear:

By default Armory attempts to run the project as fast as possible, which can cause these annoyances with cleaning the project. But it’s getting better as we go.

2 Likes

Thanks for the info.

I can try to draft up a documentation for it and create a pull request if it is okay with you.

Should I just add a section like “Engine Development” under

Or just create a new markdown file called engine_development.md and add to the main doc?

Thanks

3 Likes

That would be super cool. There is ‘Engine Development’ section in the manual, please feel welcome to edit / reorganize / add more stuff to it.

I just realized we might be able to automatically generate the Bullet externs for Haxe if there is some kind of machine readable API documentation. Just like we were trying to do with the Blender externs.

1 Like

For ammo.js there is also .idl file (ammo.js does not expose full bullet):

1 Like

Hello,

Sorry for the delay, was busy with day time jobs and finally have a chance to do the docs update.

Following is the pull request:

One small thing about the ammo idl, I did use it as reference for the bullet physics/wheel update, but one thing is maybe just my newbine to haxe on how to implement some of javascript object like “any” type

Thanks.

4 Likes

Wow, that really cool and goodly detailed documentation!

1 Like

I am late to the party. Could you explain what these pull requests add to Armory? Is this an attempt to fix issues with the physics in Armory?

Above pull is of documentation of haxebullet usage in armory. and this thread is about making armory physics better.

Hello,

Like previous reply.

The first patch is extended additional API support for bullet (for vehicle), and also updated javascript implementation to newer version (so it is closer to the C++ implementation)

The second patch is around documentation around how to extend HaxeBullet (one of Armory’s implementation)

Thanks.

2 Likes

I hope the improvements in the physics will eventually address issues that I mentioned in the threads below:

Amazed to see armory is getting contribution toward physics.