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


#1

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


#2

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


#3

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.


#4

@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.


#5

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.


#6

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


#7

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


#8

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.


#9

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