Browse Source

updated with latest idl

ncannasse 7 years ago
parent
commit
411b247d45

+ 2 - 11
libs/bullet/Makefile

@@ -1,14 +1,5 @@
-SOURCES := haxe -lib webidl -main bullet.Generator --interp
-
 all:
 
 generate:
-	haxe -lib webidl --macro "bullet.Generator.buildHL()"
-
-genjs:
-	haxe -lib webidl --macro "bullet.Generator.buildJS()"
-
-.SUFFIXES : .cpp .bc
-
-.cpp.bc:
-	emcc -o $@ -c $<
+	haxe -lib webidl --macro "bullet.Generator.generateCpp()"
+	haxe -lib webidl --macro "bullet.Generator.generateJs()"

File diff suppressed because it is too large
+ 603 - 192
libs/bullet/bullet.cpp


File diff suppressed because it is too large
+ 512 - 512
libs/bullet/bullet.idl


+ 23 - 4
libs/bullet/bullet/Body.hx

@@ -19,6 +19,8 @@ class Body {
 		state = new Native.DefaultMotionState();
 		var inf = new Native.RigidBodyConstructionInfo(mass, state, @:privateAccess shape.getInstance(), inertia);
 		inst = new Native.RigidBody(inf);
+		inertia.delete();
+		inf.delete();
 		this.shape = shape;
 		this.mass = mass;
 		_tmp[6] = 0.;
@@ -26,22 +28,39 @@ class Body {
 
 	public function setTransform( p : h3d.col.Point, ?q : h3d.Quat ) {
 		var t = inst.getCenterOfMassTransform();
-		t.setOrigin(new Native.Vector3(p.x, p.y, p.z));
-		if( q != null ) t.setRotation(new Native.Quaternion(q.x, q.y, q.z, q.w));
+		var v = new Native.Vector3(p.x, p.y, p.z);
+		t.setOrigin(v);
+		v.delete();
+		if( q != null ) {
+			var qv = new Native.Quaternion(q.x, q.y, q.z, q.w);
+			t.setRotation(qv);
+			qv.delete();
+		}
 		inst.setCenterOfMassTransform(t);
+		t.delete();
+	}
+
+	public function delete() {
+		inst.delete();
+		state.delete();
 	}
 
 	function get_position() {
 		var t = inst.getCenterOfMassTransform();
 		var p = t.getOrigin();
 		_pos.set(p.x(), p.y(), p.z());
+		t.delete();
+		p.delete();
 		return _pos;
 	}
 
 	function get_rotation() {
 		var t = inst.getCenterOfMassTransform();
-		var q : Native.QuadWord = t.getRotation();
-		_q.set(q.x(), q.y(), q.z(), q.w());
+		var q = t.getRotation();
+		var qw : Native.QuadWord = q;
+		_q.set(qw.x(), qw.y(), qw.z(), qw.w());
+		q.delete();
+		t.delete();
 		return _q;
 	}
 

+ 7 - 7
libs/bullet/bullet/Generator.hx

@@ -23,8 +23,8 @@ class Generator {
 
 	static var options = { idl : "bullet.idl", libName : "bullet", includeCode : INCLUDE, autoGC : true };
 
-	public static function buildHL() {
-		webidl.HLGen.generate(options);
+	public static function generateCpp() {
+		webidl.Generate.generateCpp(options);
 	}
 
 	public static function getFiles() {
@@ -37,19 +37,19 @@ class Generator {
 					var fname = f.att.Include.split("\\").join("/");
 					sources.push(fname);
 				}
-		sources.remove("bullet.cpp");
 		return sources;
 	}
 
-	public static function buildJS() {
+	public static function generateJs() {
 		// ammo.js params
-		var defines = ["NO_EXIT_RUNTIME=1", "NO_FILESYSTEM=1", "AGGRESSIVE_VARIABLE_ELIMINATION=1", "ELIMINATE_DUPLICATE_FUNCTIONS=1", "NO_DYNAMIC_EXECUTION=1"];
-		var params = ["-O3", "--llvm-lto", "1", "-I", "../../include/bullet/src"];
+		var debug = false;
+		var defines = debug ? [] : ["NO_EXIT_RUNTIME=1", "NO_FILESYSTEM=1", "AGGRESSIVE_VARIABLE_ELIMINATION=1", "ELIMINATE_DUPLICATE_FUNCTIONS=1", "NO_DYNAMIC_EXECUTION=1"];
+		var params = ["-O"+(debug?0:3), "--llvm-lto", "1", "-I", "../../include/bullet/src"];
 		for( d in defines ) {
 			params.push("-s");
 			params.push(d);
 		}
-		webidl.JSGen.compile(options, getFiles(), params);
+		webidl.Generate.generateJs(options, getFiles(), params);
 	}
 
 }

+ 1 - 0
libs/bullet/sample/sample_js.hxml

@@ -4,3 +4,4 @@
 -lib heaps
 -lib hxbullet
 -D old-error-format
+-dce full

+ 1 - 1
libs/bullet/sample/sample_js.hxproj

@@ -24,7 +24,7 @@
     <option noInlineOnDebug="False" />
     <option mainClass="Main" />
     <option enabledebug="False" />
-    <option additional="-lib heaps&#xA;-lib hxbullet&#xA;-D old-error-format" />
+    <option additional="-lib heaps&#xA;-lib hxbullet&#xA;-D old-error-format&#xA;-dce full" />
   </build>
   <!-- haxelib libraries -->
   <haxelib>

Some files were not shown because too many files changed in this diff