Quellcode durchsuchen

Refactored to use some more structs. Resolves #2.

Fixed for macOS build.
Fixed examples.
Brucey vor 2 Jahren
Ursprung
Commit
33dbe263b5

+ 1 - 1
box2d.mod/Source/Common/b2Math.h

@@ -70,7 +70,7 @@ inline bool b2IsValid(float32 x)
 	return _finite(x) != 0;
 	return _finite(x) != 0;
 #else
 #else
 	
 	
-#ifdef TARGET_OS_IPHONE
+#if defined(TARGET_OS_IPHONE) || defined(__APPLE__)
 	return isfinite(x);
 	return isfinite(x);
 #else
 #else
 	return finite(x) != 0;
 	return finite(x) != 0;

+ 50 - 109
box2d.mod/box2d.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2008-2021 Bruce A Henderson
+' Copyright (c) 2008-2022 Bruce A Henderson
 ' 
 ' 
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' of this software and associated documentation files (the "Software"), to deal
 ' of this software and associated documentation files (the "Software"), to deal
@@ -25,11 +25,14 @@ bbdoc: Box2D
 End Rem
 End Rem
 Module Physics.Box2D
 Module Physics.Box2D
 
 
-ModuleInfo "Version: 1.06"
+ModuleInfo "Version: 1.07"
 ModuleInfo "License: MIT"
 ModuleInfo "License: MIT"
 ModuleInfo "Copyright: Box2D (c) 2006-2016 Erin Catto http://www.gphysics.com"
 ModuleInfo "Copyright: Box2D (c) 2006-2016 Erin Catto http://www.gphysics.com"
-ModuleInfo "Copyright: BlitzMax port - 2008-2021 Bruce A Henderson"
+ModuleInfo "Copyright: BlitzMax port - 2008-2022 Bruce A Henderson"
 
 
+ModuleInfo "History: 1.07"
+ModuleInfo "History: Fixed for macOS build."
+ModuleInfo "History: Refactored to use some more structs."
 ModuleInfo "History: 1.06"
 ModuleInfo "History: 1.06"
 ModuleInfo "History: Refactored to use structs where appropriate."
 ModuleInfo "History: Refactored to use structs where appropriate."
 ModuleInfo "History: 1.05"
 ModuleInfo "History: 1.05"
@@ -77,6 +80,8 @@ Import "common.bmx"
 ' NOTES :
 ' NOTES :
 '  b2Controller.h - Added userData fields/methods.
 '  b2Controller.h - Added userData fields/methods.
 '
 '
+'  b2Math.h - added __APPLE__ test for isfinite() use.
+'
 
 
 Rem
 Rem
 bbdoc: The world type manages all physics entities, dynamic simulation, and asynchronous queries. 
 bbdoc: The world type manages all physics entities, dynamic simulation, and asynchronous queries. 
@@ -90,6 +95,8 @@ Type b2World
 	Field contactListener:b2ContactListener
 	Field contactListener:b2ContactListener
 	Field boundaryListener:b2BoundaryListener
 	Field boundaryListener:b2BoundaryListener
 	Field destructionListener:b2DestructionListener
 	Field destructionListener:b2DestructionListener
+
+	Field groundBody:b2Body
 	
 	
 	Function _create:b2World(b2ObjectPtr:Byte Ptr)
 	Function _create:b2World(b2ObjectPtr:Byte Ptr)
 		If b2ObjectPtr Then
 		If b2ObjectPtr Then
@@ -292,7 +299,10 @@ Type b2World
 	about: You can use this to simplify the creation of joints and static shapes.
 	about: You can use this to simplify the creation of joints and static shapes.
 	End Rem
 	End Rem
 	Method GetGroundBody:b2Body()
 	Method GetGroundBody:b2Body()
-		Return b2Body._create(bmx_b2world_getgroundbody(b2ObjectPtr))
+		If Not groundBody Then
+			groundBody = b2Body._create(bmx_b2world_getgroundbody(b2ObjectPtr))
+		End If
+		Return groundBody
 	End Method
 	End Method
 
 
 	Rem
 	Rem
@@ -1082,6 +1092,7 @@ Type b2Body
 			If Not body Then
 			If Not body Then
 				body = New b2Body
 				body = New b2Body
 				body.b2ObjectPtr = b2ObjectPtr
 				body.b2ObjectPtr = b2ObjectPtr
+				bmx_b2body_setmaxbody(b2ObjectPtr, body)
 			End If
 			End If
 			Return body
 			Return body
 		End If
 		End If
@@ -1392,7 +1403,7 @@ Type b2Body
 	bbdoc: Get the list of all joints attached to this body.
 	bbdoc: Get the list of all joints attached to this body.
 	End Rem
 	End Rem
 	Method GetJointList:b2JointEdge()
 	Method GetJointList:b2JointEdge()
-		Return b2JointEdge._create(bmx_b2body_getjointlist(b2ObjectPtr))
+		Return New b2JointEdge(bmx_b2body_getjointlist(b2ObjectPtr))
 	End Method
 	End Method
 
 
 	Rem
 	Rem
@@ -1465,6 +1476,7 @@ Type b2Shape
 			If Not shape Then
 			If Not shape Then
 				shape = New b2Shape
 				shape = New b2Shape
 				shape.b2ObjectPtr = b2ObjectPtr
 				shape.b2ObjectPtr = b2ObjectPtr
+				bmx_b2shape_setmaxshape(b2ObjectPtr, shape)
 			Else
 			Else
 				If Not shape.b2ObjectPtr Then
 				If Not shape.b2ObjectPtr Then
 					shape.b2ObjectPtr = b2ObjectPtr
 					shape.b2ObjectPtr = b2ObjectPtr
@@ -1521,7 +1533,7 @@ Type b2Shape
 	bbdoc: Get the contact filtering data. 
 	bbdoc: Get the contact filtering data. 
 	End Rem
 	End Rem
 	Method GetFilterData:b2FilterData()
 	Method GetFilterData:b2FilterData()
-		Return b2FilterData._create(bmx_b2shape_getfilterdata(b2ObjectPtr))
+		Return bmx_b2shape_getfilterdata(b2ObjectPtr)
 	End Method
 	End Method
 	
 	
 	Rem
 	Rem
@@ -1529,7 +1541,7 @@ Type b2Shape
 	about: You must call b2World::Refilter to correct existing contacts/non-contacts. 
 	about: You must call b2World::Refilter to correct existing contacts/non-contacts. 
 	End Rem
 	End Rem
 	Method SetFilterData(data:b2FilterData)
 	Method SetFilterData(data:b2FilterData)
-		bmx_b2shape_setfilterdata(b2ObjectPtr, data.b2ObjectPtr)
+		bmx_b2shape_setfilterdata(b2ObjectPtr, data)
 	End Method
 	End Method
 
 
 	Rem
 	Rem
@@ -1953,17 +1965,13 @@ bbdoc: A joint edge is used to connect bodies and joints together in a joint gra
 about: A joint edge belongs to a doubly linked list maintained in each attached body. Each joint has two
 about: A joint edge belongs to a doubly linked list maintained in each attached body. Each joint has two
 joint nodes, one for each attached body.
 joint nodes, one for each attached body.
 End Rem
 End Rem
-Type b2JointEdge
+Struct b2JointEdge
 
 
 	Field b2ObjectPtr:Byte Ptr
 	Field b2ObjectPtr:Byte Ptr
 
 
-	Function _create:b2JointEdge(b2ObjectPtr:Byte Ptr)
-		If b2ObjectPtr Then
-			Local this:b2JointEdge = New b2JointEdge
-			this.b2ObjectPtr = b2ObjectPtr
-			Return this
-		End If
-	End Function
+	Method New(b2ObjectPtr:Byte Ptr)
+		Self.b2ObjectPtr = b2ObjectPtr
+	End Method
 
 
 	Rem
 	Rem
 	bbdoc: Provides quick access to the other body attached. 
 	bbdoc: Provides quick access to the other body attached. 
@@ -1983,17 +1991,17 @@ Type b2JointEdge
 	bbdoc: Returns the previous joint edge in the body's joint list.
 	bbdoc: Returns the previous joint edge in the body's joint list.
 	End Rem
 	End Rem
 	Method GetPrev:b2JointEdge()
 	Method GetPrev:b2JointEdge()
-		Return b2JointEdge._create(bmx_b2jointedge_getprev(b2ObjectPtr))
+		Return New b2JointEdge(bmx_b2jointedge_getprev(b2ObjectPtr))
 	End Method
 	End Method
 	
 	
 	Rem
 	Rem
 	bbdoc: Returns the next joint edge in the body's joint list.
 	bbdoc: Returns the next joint edge in the body's joint list.
 	End Rem
 	End Rem
 	Method GetNext:b2JointEdge()
 	Method GetNext:b2JointEdge()
-		Return b2JointEdge._create(bmx_b2jointedge_getnext(b2ObjectPtr))
+		Return new b2JointEdge(bmx_b2jointedge_getnext(b2ObjectPtr))
 	End Method
 	End Method
 	
 	
-End Type
+End Struct
 
 
 Rem
 Rem
 bbdoc: Holds the mass data computed for a shape.
 bbdoc: Holds the mass data computed for a shape.
@@ -2105,14 +2113,36 @@ Type b2ShapeDef
 	bbdoc: Sets the contact filtering data.
 	bbdoc: Sets the contact filtering data.
 	End Rem
 	End Rem
 	Method SetFilter(filter:b2FilterData)
 	Method SetFilter(filter:b2FilterData)
-		bmx_b2shapedef_setfilter(b2ObjectPtr, filter.b2ObjectPtr)
+		bmx_b2shapedef_setfilter(b2ObjectPtr, filter)
 	End Method
 	End Method
 	
 	
+	Rem
+	bbdoc: Sets the contact filtering group index.
+	End Rem
+	Method SetFilterGroupIndex(groupIndex:Int)
+		bmx_b2shapedef_setfilter_groupindex(b2ObjectPtr, groupIndex)
+	End Method
+
+	Rem
+	bbdoc: Sets the contact filtering category bits.
+	End Rem
+	Method SetFilterCategoryBits(categoryBits:Short)
+		bmx_b2shapedef_setfilter_categorybits(b2ObjectPtr, categoryBits)
+	End Method
+
+	Rem
+	bbdoc: Sets the contact filtering mask bits.
+	End Rem
+	Method SetFilterMaskBits(maskBits:Short)
+		bmx_b2shapedef_setfilter_maskbits(b2ObjectPtr, maskBits)
+	End Method
+
 	Rem
 	Rem
 	bbdoc: Returns the contact filtering data.
 	bbdoc: Returns the contact filtering data.
+	about: If you change the field values of the returned #b2FilterData, you will need to call #SetFilter() with the new data. 
 	End Rem
 	End Rem
 	Method GetFilter:b2FilterData()
 	Method GetFilter:b2FilterData()
-		Return b2FilterData._create(bmx_b2shapedef_getfilter(b2ObjectPtr))
+		Return bmx_b2shapedef_getfilter(b2ObjectPtr)
 	End Method
 	End Method
 	
 	
 	Rem
 	Rem
@@ -2139,95 +2169,6 @@ Type b2ShapeDef
 	
 	
 End Type
 End Type
 
 
-Rem
-bbdoc: This holds contact filtering data.
-End Rem
-Type b2FilterData
-
-	Field owner:Int
-	Field b2ObjectPtr:Byte Ptr
-
-	Function _create:b2FilterData(b2ObjectPtr:Byte Ptr)
-		If b2ObjectPtr Then
-			Local this:b2FilterData = New b2FilterData
-			this.Free()
-			this.owner = False
-			this.b2ObjectPtr = b2ObjectPtr
-			Return this
-		End If
-	End Function
-
-	Method New()
-		owner = True
-		b2ObjectPtr = bmx_b2filterdata_create()	
-	End Method
-	
-	Rem
-	bbdoc: Returns the collision category bits.
-	End Rem
-	Method GetCategoryBits:Short()
-		Return bmx_b2filterdata_getcategorybits(b2ObjectPtr)
-	End Method
-	
-	Rem
-	bbdoc: Sets the collision category bits.
-	about: Normally you would just set one bit.
-	End Rem
-	Method SetCategoryBits(categoryBits:Short)
-		bmx_b2filterdata_setcategorybits(b2ObjectPtr, categoryBits)
-	End Method
-	
-	Rem
-	bbdoc: Returns the collision mask bits.
-	about: This states the categories that this shape would accept for collision. 
-	End Rem
-	Method GetMaskBits:Short()
-		Return bmx_b2filterdata_getmaskbits(b2ObjectPtr)
-	End Method
-	
-	Rem
-	bbdoc: Sets the collision mask bits.
-	about: This states the categories that this shape would accept for collision. 
-	End Rem
-	Method SetMaskBits(maskBits:Short)
-		bmx_b2filterdata_setmaskbits(b2ObjectPtr, maskBits)
-	End Method
-	
-	Rem
-	bbdoc: Returns the collision group index.
-	about: Collision groups allow a certain group of objects to never collide (negative) or always collide (positive). 
-	<p>
-	Zero means no collision group. Non-zero group filtering always wins against the mask bits. 
-	</p>
-	End Rem
-	Method GetGroupIndex:Short()
-		Return bmx_b2filterdata_getgroupindex(b2ObjectPtr)
-	End Method
-	
-	Rem
-	bbdoc: Sets the collision group index.
-	about: Collision groups allow a certain group of objects to never collide (negative) or always collide (positive). 
-	<p>
-	Zero means no collision group. Non-zero group filtering always wins against the mask bits. 
-	</p>
-	End Rem
-	Method SetGroupIndex(index:Int)
-		bmx_b2filterdata_setgroupindex(b2ObjectPtr, index)
-	End Method
-
-	Method Free()
-		If b2ObjectPtr And owner Then
-			bmx_b2filterdata_delete(b2ObjectPtr)
-			b2ObjectPtr = Null
-		End If
-	End Method
-	
-	Method Delete()
-		Free()
-	End Method
-	
-End Type
-
 Rem
 Rem
 bbdoc: Convex polygon.
 bbdoc: Convex polygon.
 about: Vertices must be in CCW order.
 about: Vertices must be in CCW order.

+ 30 - 14
box2d.mod/common.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2008-2021 Bruce A Henderson
+' Copyright (c) 2008-2022 Bruce A Henderson
 ' 
 ' 
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' of this software and associated documentation files (the "Software"), to deal
 ' of this software and associated documentation files (the "Software"), to deal
@@ -74,13 +74,16 @@ Extern
 	Function bmx_b2shapedef_setfriction(handle:Byte Ptr, friction:Float)
 	Function bmx_b2shapedef_setfriction(handle:Byte Ptr, friction:Float)
 	Function bmx_b2shapedef_setrestitution(handle:Byte Ptr, restitution:Float)
 	Function bmx_b2shapedef_setrestitution(handle:Byte Ptr, restitution:Float)
 	Function bmx_b2shapedef_setdensity(handle:Byte Ptr, density:Float)
 	Function bmx_b2shapedef_setdensity(handle:Byte Ptr, density:Float)
-	Function bmx_b2shapedef_setfilter(handle:Byte Ptr, filter:Byte Ptr)
-	Function bmx_b2shapedef_getfilter:Byte Ptr(handle:Byte Ptr)
+	Function bmx_b2shapedef_setfilter(handle:Byte Ptr, filter:b2FilterData)
+	Function bmx_b2shapedef_getfilter:b2FilterData(handle:Byte Ptr)
 	Function bmx_b2shapedef_setissensor(handle:Byte Ptr, sensor:Int)
 	Function bmx_b2shapedef_setissensor(handle:Byte Ptr, sensor:Int)
 	Function bmx_b2shapedef_issensor:Int(handle:Byte Ptr)
 	Function bmx_b2shapedef_issensor:Int(handle:Byte Ptr)
 	Function bmx_b2shapedef_getfriction:Float(handle:Byte Ptr)
 	Function bmx_b2shapedef_getfriction:Float(handle:Byte Ptr)
 	Function bmx_b2shapedef_getrestitution:Float(handle:Byte Ptr)
 	Function bmx_b2shapedef_getrestitution:Float(handle:Byte Ptr)
 	Function bmx_b2shapedef_getdensity:Float(handle:Byte Ptr)
 	Function bmx_b2shapedef_getdensity:Float(handle:Byte Ptr)
+	Function bmx_b2shapedef_setfilter_groupindex(handle:Byte Ptr, groupIndex:Int)
+	Function bmx_b2shapedef_setfilter_categorybits(handle:Byte Ptr, categoryBits:Short)
+	Function bmx_b2shapedef_setfilter_maskbits(handle:Byte Ptr, maskBits:Short)
 
 
 	Function bmx_b2polygondef_create:Byte Ptr()
 	Function bmx_b2polygondef_create:Byte Ptr()
 	Function bmx_b2polygondef_setasbox(handle:Byte Ptr, hx:Float, hy:Float)
 	Function bmx_b2polygondef_setasbox(handle:Byte Ptr, hx:Float, hy:Float)
@@ -91,6 +94,7 @@ Extern
 	Function bmx_b2body_setmassfromshapes(handle:Byte Ptr)
 	Function bmx_b2body_setmassfromshapes(handle:Byte Ptr)
 	Function bmx_b2body_getangle:Float(handle:Byte Ptr)
 	Function bmx_b2body_getangle:Float(handle:Byte Ptr)
 	Function bmx_b2body_getmaxbody:Object(handle:Byte Ptr)
 	Function bmx_b2body_getmaxbody:Object(handle:Byte Ptr)
+	Function bmx_b2body_setmaxbody(handle:Byte Ptr, body:Object)
 	Function bmx_b2body_getnext:Byte Ptr(handle:Byte Ptr)
 	Function bmx_b2body_getnext:Byte Ptr(handle:Byte Ptr)
 	Function bmx_b2body_getshapelist:Byte Ptr(handle:Byte Ptr)
 	Function bmx_b2body_getshapelist:Byte Ptr(handle:Byte Ptr)
 	Function bmx_b2body_isstatic:Int(handle:Byte Ptr)
 	Function bmx_b2body_isstatic:Int(handle:Byte Ptr)
@@ -125,13 +129,14 @@ Extern
 	Function bmx_b2shape_issensor:Int(handle:Byte Ptr)
 	Function bmx_b2shape_issensor:Int(handle:Byte Ptr)
 	Function bmx_b2shape_getbody:Byte Ptr(handle:Byte Ptr)
 	Function bmx_b2shape_getbody:Byte Ptr(handle:Byte Ptr)
 	Function bmx_b2shape_getmaxshape:Object(handle:Byte Ptr)
 	Function bmx_b2shape_getmaxshape:Object(handle:Byte Ptr)
+	Function bmx_b2shape_setmaxshape(handle:Byte Ptr, shape:Object)
 	Function bmx_b2shape_getnext:Byte Ptr(handle:Byte Ptr)
 	Function bmx_b2shape_getnext:Byte Ptr(handle:Byte Ptr)
 	Function bmx_b2shape_getsweepradius:Float(handle:Byte Ptr)
 	Function bmx_b2shape_getsweepradius:Float(handle:Byte Ptr)
 	Function bmx_b2shape_getfriction:Float(handle:Byte Ptr)
 	Function bmx_b2shape_getfriction:Float(handle:Byte Ptr)
 	Function bmx_b2shape_getrestitution:Float(handle:Byte Ptr)
 	Function bmx_b2shape_getrestitution:Float(handle:Byte Ptr)
 	Function bmx_b2shape_computemass(handle:Byte Ptr, data:Byte Ptr)
 	Function bmx_b2shape_computemass(handle:Byte Ptr, data:Byte Ptr)
-	Function bmx_b2shape_getfilterdata:Byte Ptr(handle:Byte Ptr)
-	Function bmx_b2shape_setfilterdata(handle:Byte Ptr, data:Byte Ptr)
+	Function bmx_b2shape_getfilterdata:b2FilterData(handle:Byte Ptr)
+	Function bmx_b2shape_setfilterdata(handle:Byte Ptr, data:b2FilterData)
 	Function bmx_b2shape_setfriction(handle:Byte Ptr, friction:Float)
 	Function bmx_b2shape_setfriction(handle:Byte Ptr, friction:Float)
 	Function bmx_b2shape_setrestitution(handle:Byte Ptr, restitution:Float)
 	Function bmx_b2shape_setrestitution(handle:Byte Ptr, restitution:Float)
 	Function bmx_b2shape_getdensity:Float(handle:Byte Ptr)
 	Function bmx_b2shape_getdensity:Float(handle:Byte Ptr)
@@ -252,15 +257,6 @@ Extern
 	Function bmx_b2contact_issolid:Int(handle:Byte Ptr)
 	Function bmx_b2contact_issolid:Int(handle:Byte Ptr)
 	Function bmx_b2contact_getmanifoldcount:Int(handle:Byte Ptr)
 	Function bmx_b2contact_getmanifoldcount:Int(handle:Byte Ptr)
 
 
-	Function bmx_b2filterdata_create:Byte Ptr()
-	Function bmx_b2filterdata_getcategorybits:Short(handle:Byte Ptr)
-	Function bmx_b2filterdata_setcategorybits(handle:Byte Ptr, categoryBits:Short)
-	Function bmx_b2filterdata_getmaskbits:Short(handle:Byte Ptr)
-	Function bmx_b2filterdata_setmaskbits(handle:Byte Ptr, maskBits:Short)
-	Function bmx_b2filterdata_getgroupindex:Short(handle:Byte Ptr)
-	Function bmx_b2filterdata_setgroupindex(handle:Byte Ptr, index:Int)
-	Function bmx_b2filterdata_delete(handle:Byte Ptr)
-
 	Function bmx_b2gearjointdef_new:Byte Ptr()
 	Function bmx_b2gearjointdef_new:Byte Ptr()
 	Function bmx_b2gearjointdef_setjoint1(handle:Byte Ptr, joint:Byte Ptr)
 	Function bmx_b2gearjointdef_setjoint1(handle:Byte Ptr, joint:Byte Ptr)
 	Function bmx_b2gearjointdef_setjoint2(handle:Byte Ptr, joint:Byte Ptr)
 	Function bmx_b2gearjointdef_setjoint2(handle:Byte Ptr, joint:Byte Ptr)
@@ -443,3 +439,23 @@ Const e_tensorDampingController:Int = 3
 Const e_gravityController:Int = 4
 Const e_gravityController:Int = 4
 Const e_constantForceController:Int = 5
 Const e_constantForceController:Int = 5
 
 
+Rem
+bbdoc: This holds contact filtering data
+End Rem
+Struct b2FilterData
+	Rem
+	bbdoc: The collision category bits.
+	about: Normally you would just set one bit.
+	End Rem
+	Field categoryBits:Short
+	Rem
+	bbdoc: The collision mask bits.
+	about: This states the categories that this shape would accept for collision.
+	End Rem
+	Field maskBits:Short
+	Rem
+	bbdoc: Collision groups allow a certain group of objects to never collide (negative) or always collide (positive). 
+	about: Zero means no collision group. Non-zero group filtering always wins against the mask bits.
+	End Rem
+	Field groupIndex:Int
+End Struct

+ 2 - 2
box2d.mod/examples/applyforce.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 Import brl.standardio
 Import brl.standardio

+ 2 - 2
box2d.mod/examples/bridge.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 2 - 2
box2d.mod/examples/buoyancy.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 7 - 7
box2d.mod/examples/car.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 
@@ -38,11 +38,11 @@ Type SliderCrank Extends Test
 		vertices[1] = Vec2(2.2,-0.2)
 		vertices[1] = Vec2(2.2,-0.2)
 		vertices[0] = Vec2(2.2,-0.74)
 		vertices[0] = Vec2(2.2,-0.74)
 		poly1.SetVertices(vertices)
 		poly1.SetVertices(vertices)
-		poly1.GetFilter().SetGroupIndex(-1)
+		poly1.SetFilterGroupIndex(-1)
 		
 		
 		poly1.SetDensity(20.0)
 		poly1.SetDensity(20.0)
 		poly1.SetFriction(0.68)
 		poly1.SetFriction(0.68)
-		poly1.GetFilter().SetGroupIndex(-1)
+		poly1.SetFilterGroupIndex(-1)
 		
 		
 		' top half
 		' top half
 		vertices = New b2Vec2[4]
 		vertices = New b2Vec2[4]
@@ -51,11 +51,11 @@ Type SliderCrank Extends Test
 		vertices[1] = Vec2(0.5,0.74)
 		vertices[1] = Vec2(0.5,0.74)
 		vertices[0] = Vec2(1.0,0)
 		vertices[0] = Vec2(1.0,0)
 		poly2.SetVertices(vertices)
 		poly2.SetVertices(vertices)
-		poly2.GetFilter().SetGroupIndex(-1)
+		poly2.SetFilterGroupIndex(-1)
 		
 		
 		poly2.SetDensity(5.0)
 		poly2.SetDensity(5.0)
 		poly2.SetFriction(0.68)
 		poly2.SetFriction(0.68)
-		poly2.GetFilter().SetGroupIndex(-1)
+		poly2.SetFilterGroupIndex(-1)
 		
 		
 		Local bd:b2BodyDef = New b2BodyDef
 		Local bd:b2BodyDef = New b2BodyDef
 		bd.SetPositionXY(-35.0, 2.8)
 		bd.SetPositionXY(-35.0, 2.8)
@@ -70,7 +70,7 @@ Type SliderCrank Extends Test
 		circ.SetDensity(40.0)
 		circ.SetDensity(40.0)
 		circ.SetRadius(0.38608)
 		circ.SetRadius(0.38608)
 		circ.SetFriction(0.8)
 		circ.SetFriction(0.8)
-		circ.GetFilter().SetGroupIndex(-1)
+		circ.SetFilterGroupIndex(-1)
 		
 		
 		bd = New b2BodyDef
 		bd = New b2BodyDef
 		bd.SetAllowSleep(False)
 		bd.SetAllowSleep(False)

+ 2 - 2
box2d.mod/examples/ccdtest.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 2 - 2
box2d.mod/examples/chain.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 19 - 20
box2d.mod/examples/collisionfiltering.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 
@@ -9,7 +9,6 @@ Import "test.bmx"
 Graphics 800,600, 0
 Graphics 800,600, 0
 SetBlend alphablend
 SetBlend alphablend
 
 
-
 Run(New CollisionFiltering.Create(), New TSettings)
 Run(New CollisionFiltering.Create(), New TSettings)
 
 
 
 
@@ -61,9 +60,9 @@ Type CollisionFiltering Extends Test
 		triangleShapeDef.SetDensity(1.0)
 		triangleShapeDef.SetDensity(1.0)
 
 
 		' modify the def's filter
 		' modify the def's filter
-		triangleShapeDef.GetFilter().SetGroupIndex(k_smallGroup)
-		triangleShapeDef.GetFilter().SetCategoryBits(k_triangleCategory)
-		triangleShapeDef.GetFilter().SetMaskBits(k_triangleMask)
+		triangleShapeDef.SetFilterGroupIndex(k_smallGroup)
+		triangleShapeDef.SetFilterCategoryBits(k_triangleCategory)
+		triangleShapeDef.SetFilterMaskBits(k_triangleMask)
 
 
 		Local triangleBodyDef:b2BodyDef = New b2BodyDef
 		Local triangleBodyDef:b2BodyDef = New b2BodyDef
 		triangleBodyDef.SetPositionXY(-5.0, 2.0)
 		triangleBodyDef.SetPositionXY(-5.0, 2.0)
@@ -79,7 +78,7 @@ Type CollisionFiltering Extends Test
 		vertices[2].Multiply(2.0)
 		vertices[2].Multiply(2.0)
 		triangleShapeDef.SetVertices(vertices)
 		triangleShapeDef.SetVertices(vertices)
 		
 		
-		triangleShapeDef.GetFilter().SetGroupIndex(k_largeGroup)
+		triangleShapeDef.SetFilterGroupIndex(k_largeGroup)
 		triangleBodyDef.SetPositionXY(-5, 6.0)
 		triangleBodyDef.SetPositionXY(-5, 6.0)
 		triangleBodyDef.SetFixedRotation(True) ' look at me!
 		triangleBodyDef.SetFixedRotation(True) ' look at me!
 
 
@@ -95,9 +94,9 @@ Type CollisionFiltering Extends Test
 
 
 		' create our own filter object
 		' create our own filter object
 		Local filter:b2FilterData = New b2FilterData
 		Local filter:b2FilterData = New b2FilterData
-		filter.SetGroupIndex(k_smallGroup)
-		filter.SetCategoryBits(k_boxCategory)
-		filter.SetMaskBits(k_boxMask)
+		filter.groupIndex = k_smallGroup
+		filter.categoryBits = k_boxCategory
+		filter.maskBits = k_boxMask
 
 
 		boxShapeDef.SetFilter(filter)
 		boxShapeDef.SetFilter(filter)
 		
 		
@@ -111,7 +110,7 @@ Type CollisionFiltering Extends Test
 		
 		
 		' Large box (recycle definitions)
 		' Large box (recycle definitions)
 		boxShapeDef.SetAsBox(2.0, 1.0)
 		boxShapeDef.SetAsBox(2.0, 1.0)
-		boxShapeDef.GetFilter().SetGroupIndex(k_largeGroup)
+		boxShapeDef.SetFilterGroupIndex(k_largeGroup)
 		boxBodyDef.SetPositionXY(0.0, 6.0)
 		boxBodyDef.SetPositionXY(0.0, 6.0)
 
 
 		Local body4:b2Body = m_world.CreateBody(boxBodyDef)
 		Local body4:b2Body = m_world.CreateBody(boxBodyDef)
@@ -125,9 +124,9 @@ Type CollisionFiltering Extends Test
 		circleShapeDef.SetDensity(1.0)
 		circleShapeDef.SetDensity(1.0)
 
 
 		filter = New b2FilterData
 		filter = New b2FilterData
-		filter.SetGroupIndex(k_smallGroup)
-		filter.SetCategoryBits(k_circleCategory)
-		filter.SetMaskBits(k_circleMask)
+		filter.groupIndex = k_smallGroup
+		filter.categoryBits = k_circleCategory
+		filter.maskBits = k_circleMask
 		
 		
 		circleShapeDef.SetFilter(filter)
 		circleShapeDef.SetFilter(filter)
 
 
@@ -141,7 +140,7 @@ Type CollisionFiltering Extends Test
 		
 		
 		' Large circle
 		' Large circle
 		circleShapeDef.SetRadius(circleShapeDef.GetRadius() * 2.0)
 		circleShapeDef.SetRadius(circleShapeDef.GetRadius() * 2.0)
-		circleShapeDef.GetFilter().SetGroupIndex(k_largeGroup)
+		circleShapeDef.SetFilterGroupIndex(k_largeGroup)
 		circleBodyDef.SetPositionXY(5.0, 6.0)
 		circleBodyDef.SetPositionXY(5.0, 6.0)
 
 
 		Local body6:b2Body = m_world.CreateBody(circleBodyDef)
 		Local body6:b2Body = m_world.CreateBody(circleBodyDef)
@@ -178,12 +177,12 @@ Type myfilter Extends b2ContactFilter
 
 
 		Local filter1:b2FilterData = shape1.GetFilterData()
 		Local filter1:b2FilterData = shape1.GetFilterData()
 		Local filter2:b2FilterData = shape2.GetFilterData()
 		Local filter2:b2FilterData = shape2.GetFilterData()
-
-		If filter1.GetGroupIndex() = filter2.GetGroupIndex() And filter1.GetGroupIndex() <> 0
- 			Return filter1.GetGroupIndex() < $7FFF
+		If filter1.groupIndex = filter2.groupIndex And filter1.groupIndex <> 0
+ 			Return filter1.groupIndex < $7FFF
 		End If
 		End If
-	
-		Local collide:Int = (filter1.GetMaskBits() & filter2.GetCategoryBits()) <> 0 And (filter1.GetCategoryBits() & filter2.GetMaskBits()) <> 0
+
+		Local collide:Int = (filter1.maskBits & filter2.categoryBits) <> 0 And (filter1.categoryBits & filter2.maskBits) <> 0
+
 		Return collide
 		Return collide
 
 
 	End Method
 	End Method

+ 2 - 2
box2d.mod/examples/dominos.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 4 - 4
box2d.mod/examples/dynamicedges.bmx

@@ -1,8 +1,8 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
-Import BRL.RandomDefault
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
+Import BRL.Random
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 
@@ -252,7 +252,7 @@ Type DynamicEdges Extends Test
 		body = m_world.CreateBody(bd)
 		body = m_world.CreateBody(bd)
 		
 		
 		Local weight:b2CircleDef = New b2CircleDef
 		Local weight:b2CircleDef = New b2CircleDef
-		weight.GetFilter().SetMaskBits(0)
+		weight.SetFilterMaskBits(0)
 		weight.SetDensity(4.0)
 		weight.SetDensity(4.0)
 		weight.SetRadius(0.5)
 		weight.SetRadius(0.5)
 		weight.SetLocalPosition(Vec2(8.9, 5.75))
 		weight.SetLocalPosition(Vec2(8.9, 5.75))

+ 2 - 2
box2d.mod/examples/gears.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 1 - 1
box2d.mod/examples/helloworld.bmx

@@ -3,7 +3,7 @@ SuperStrict
 ' This is a simple example of building and running a simulation
 ' This is a simple example of building and running a simulation
 ' using Box2D. Here we create a large ground box and a small dynamic box.
 ' using Box2D. Here we create a large ground box and a small dynamic box.
 
 
-Framework BaH.Box2D
+Framework Physics.Box2d
 Import BRL.StandardIO
 Import BRL.StandardIO
 
 
 ' Define the size of the world. Simulation will still work
 ' Define the size of the world. Simulation will still work

+ 2 - 2
box2d.mod/examples/motorsandlimits.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 2 - 2
box2d.mod/examples/pulleys.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 2 - 2
box2d.mod/examples/pyramid.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 2 - 2
box2d.mod/examples/pyramidstaticedges.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 2 - 2
box2d.mod/examples/raycast.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 4 - 4
box2d.mod/examples/render.bmx

@@ -3,7 +3,7 @@
 '
 '
 SuperStrict
 SuperStrict
 
 
-Import BRL.GLMax2D
+Import SDL.SDLRenderMax2D
 
 
 Global xScale:Float = 8
 Global xScale:Float = 8
 Global yScale:Float = 8
 Global yScale:Float = 8
@@ -86,12 +86,12 @@ Type debugDraw Extends b2DebugDraw
 	End Method
 	End Method
 
 
 	Method DrawPoint(p:b2Vec2, size:Float, color:b2Color)
 	Method DrawPoint(p:b2Vec2, size:Float, color:b2Color)
-		glPointSize(size)
-		
+		'glPointSize(size)
+		'
 		SetColor(color.red, color.green, color.blue)
 		SetColor(color.red, color.green, color.blue)
 		Plot(p.x * xScale, p.y * (-yScale))
 		Plot(p.x * xScale, p.y * (-yScale))
 		
 		
-		glPointSize(1.0)
+		'glPointSize(1.0)
 	End Method
 	End Method
 
 
 End Type
 End Type

+ 2 - 2
box2d.mod/examples/revolute.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 2 - 2
box2d.mod/examples/slidercrank.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 4 - 4
box2d.mod/examples/staticedges.bmx

@@ -1,8 +1,8 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
-Import BRL.RandomDefault
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
+Import BRL.Random
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 
@@ -252,7 +252,7 @@ Type StaticEdges Extends Test
 		body = m_world.CreateBody(bd)
 		body = m_world.CreateBody(bd)
 		
 		
 		Local weight:b2CircleDef = New b2CircleDef
 		Local weight:b2CircleDef = New b2CircleDef
-		weight.GetFilter().SetMaskBits(0)
+		weight.SetFilterMaskBits(0)
 		weight.SetDensity(4.0)
 		weight.SetDensity(4.0)
 		weight.SetRadius(0.5)
 		weight.SetRadius(0.5)
 		weight.SetLocalPosition(Vec2(8.9, 5.75))
 		weight.SetLocalPosition(Vec2(8.9, 5.75))

+ 6 - 6
box2d.mod/examples/theojansen.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 
@@ -65,7 +65,7 @@ Type TheoJansen Extends Test
 		sd = New b2PolygonDef
 		sd = New b2PolygonDef
 		sd.SetDensity(1.0)
 		sd.SetDensity(1.0)
 		sd.SetAsBox(2.5, 1.0)
 		sd.SetAsBox(2.5, 1.0)
-		sd.GetFilter().SetGroupIndex(-1)
+		sd.SetFilterGroupIndex(-1)
 		bd = New b2BodyDef
 		bd = New b2BodyDef
 		bd.SetPosition(pivot.Plus(m_offset))
 		bd.SetPosition(pivot.Plus(m_offset))
 		m_chassis = m_world.CreateBody(bd)
 		m_chassis = m_world.CreateBody(bd)
@@ -76,7 +76,7 @@ Type TheoJansen Extends Test
 		Local sd1:b2CircleDef = New b2CircleDef
 		Local sd1:b2CircleDef = New b2CircleDef
 		sd1.SetDensity(1.0)
 		sd1.SetDensity(1.0)
 		sd1.SetRadius(1.6)
 		sd1.SetRadius(1.6)
-		sd1.GetFilter().SetGroupIndex(-1)
+		sd1.SetFilterGroupIndex(-1)
 		bd = New b2BodyDef
 		bd = New b2BodyDef
 		bd.SetPosition(pivot.Plus(m_offset))
 		bd.SetPosition(pivot.Plus(m_offset))
 		m_wheel = m_world.CreateBody(bd)
 		m_wheel = m_world.CreateBody(bd)
@@ -125,8 +125,8 @@ Type TheoJansen Extends Test
 		Local sd1Vertices:b2Vec2[] = New b2Vec2[3]
 		Local sd1Vertices:b2Vec2[] = New b2Vec2[3]
 		Local sd2Vertices:b2Vec2[] = New b2Vec2[3]
 		Local sd2Vertices:b2Vec2[] = New b2Vec2[3]
 
 
-		sd1.GetFilter().SetGroupIndex(-1)
-		sd2.GetFilter().SetGroupIndex(-1)
+		sd1.SetFilterGroupIndex(-1)
+		sd2.SetFilterGroupIndex(-1)
 		sd1.SetDensity(1.0)
 		sd1.SetDensity(1.0)
 		sd2.SetDensity(1.0)
 		sd2.SetDensity(1.0)
 
 

+ 2 - 2
box2d.mod/examples/varyingrestitution.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 2 - 2
box2d.mod/examples/verticalstack.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 2 - 2
box2d.mod/examples/web.bmx

@@ -1,7 +1,7 @@
 SuperStrict
 SuperStrict
 
 
-Framework BaH.Box2d
-Import BRL.GLMax2D
+Framework Physics.Box2d
+Import SDL.SDLRenderMax2D
 
 
 Import "test.bmx"
 Import "test.bmx"
 
 

+ 56 - 112
box2d.mod/glue.cpp

@@ -1,5 +1,5 @@
 /*
 /*
-  Copyright (c) 2008-2021 Bruce A Henderson
+  Copyright (c) 2008-2022 Bruce A Henderson
  
  
   Permission is hereby granted, free of charge, to any person obtaining a copy
   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   of this software and associated documentation files (the "Software"), to deal
@@ -27,7 +27,6 @@ class MaxDebugDraw;
 class MaxContactFilter;
 class MaxContactFilter;
 class MaxContactListener;
 class MaxContactListener;
 class MaxBoundaryListener;
 class MaxBoundaryListener;
-class MaxFilterData;
 class MaxDestructionListener;
 class MaxDestructionListener;
 class Maxb2EdgeChainDef;
 class Maxb2EdgeChainDef;
 
 
@@ -94,6 +93,13 @@ extern "C" {
 		Maxb2Vec2 p2;
 		Maxb2Vec2 p2;
 	} Maxb2Segment;
 	} Maxb2Segment;
 
 
+	typedef struct Maxb2FilterData
+	{
+		uint16 categoryBits;
+		uint16 maskBits;
+		int groupIndex;
+	} Maxb2FilterData;
+
 	void bmx_Maxb2AABBtob2AABB(Maxb2AABB * m, b2AABB * b) {
 	void bmx_Maxb2AABBtob2AABB(Maxb2AABB * m, b2AABB * b) {
 		b->lowerBound = b2Vec2(m->lowerBound.x, m->lowerBound.y);
 		b->lowerBound = b2Vec2(m->lowerBound.x, m->lowerBound.y);
 		b->upperBound = b2Vec2(m->upperBound.x, m->upperBound.y);
 		b->upperBound = b2Vec2(m->upperBound.x, m->upperBound.y);
@@ -203,13 +209,16 @@ extern "C" {
 	void bmx_b2shapedef_setfriction(b2ShapeDef * def, float32 friction);
 	void bmx_b2shapedef_setfriction(b2ShapeDef * def, float32 friction);
 	void bmx_b2shapedef_setrestitution(b2ShapeDef * def, float32 restitution);
 	void bmx_b2shapedef_setrestitution(b2ShapeDef * def, float32 restitution);
 	void bmx_b2shapedef_setdensity(b2ShapeDef * def, float32 density);
 	void bmx_b2shapedef_setdensity(b2ShapeDef * def, float32 density);
-	void bmx_b2shapedef_setfilter(b2ShapeDef * def, MaxFilterData* filterData);
-	MaxFilterData* bmx_b2shapedef_getfilter(b2ShapeDef * def);
+	void bmx_b2shapedef_setfilter(b2ShapeDef * def, Maxb2FilterData filterData);
+	Maxb2FilterData bmx_b2shapedef_getfilter(b2ShapeDef * def);
 	void bmx_b2shapedef_setissensor(b2ShapeDef * def, int sensor);
 	void bmx_b2shapedef_setissensor(b2ShapeDef * def, int sensor);
 	int bmx_b2shapedef_issensor(b2ShapeDef * def);
 	int bmx_b2shapedef_issensor(b2ShapeDef * def);
 	float32 bmx_b2shapedef_getfriction(b2ShapeDef * def);
 	float32 bmx_b2shapedef_getfriction(b2ShapeDef * def);
 	float32 bmx_b2shapedef_getrestitution(b2ShapeDef * def);
 	float32 bmx_b2shapedef_getrestitution(b2ShapeDef * def);
 	float32 bmx_b2shapedef_getdensity(b2ShapeDef * def);
 	float32 bmx_b2shapedef_getdensity(b2ShapeDef * def);
+	void bmx_b2shapedef_setfilter_groupindex(b2ShapeDef * def, int groupIndex);
+	void bmx_b2shapedef_setfilter_categorybits(b2ShapeDef * def, BBSHORT categoryBits);
+	void bmx_b2shapedef_setfilter_maskbits(b2ShapeDef * def, BBSHORT maskBits);
 
 
 	b2PolygonDef * bmx_b2polygondef_create();
 	b2PolygonDef * bmx_b2polygondef_create();
 	void bmx_b2polygondef_setasbox(b2PolygonDef * def, float32 hx, float32 hy);
 	void bmx_b2polygondef_setasbox(b2PolygonDef * def, float32 hx, float32 hy);
@@ -223,6 +232,7 @@ extern "C" {
 	Maxb2Vec2 bmx_b2body_getposition(b2Body * body);
 	Maxb2Vec2 bmx_b2body_getposition(b2Body * body);
 	float32 bmx_b2body_getangle(b2Body * body);
 	float32 bmx_b2body_getangle(b2Body * body);
 	BBObject * bmx_b2body_getmaxbody(b2Body * body);
 	BBObject * bmx_b2body_getmaxbody(b2Body * body);
+	void bmx_b2body_setmaxbody(b2Body * body, BBObject * obj);
 	b2Body * bmx_b2body_getnext(b2Body * body);
 	b2Body * bmx_b2body_getnext(b2Body * body);
 	b2Shape * bmx_b2body_getshapelist(b2Body * body);
 	b2Shape * bmx_b2body_getshapelist(b2Body * body);
 	int bmx_b2body_isstatic(b2Body * body);
 	int bmx_b2body_isstatic(b2Body * body);
@@ -271,6 +281,7 @@ extern "C" {
 	int bmx_b2shape_issensor(b2Shape * shape);
 	int bmx_b2shape_issensor(b2Shape * shape);
 	b2Body * bmx_b2shape_getbody(b2Shape * shape);
 	b2Body * bmx_b2shape_getbody(b2Shape * shape);
 	BBObject * bmx_b2shape_getmaxshape(b2Shape * shape);
 	BBObject * bmx_b2shape_getmaxshape(b2Shape * shape);
+	void bmx_b2shape_setmaxshape(b2Shape * shape, BBObject * obj);
 	b2Shape * bmx_b2shape_getnext(b2Shape * shape);
 	b2Shape * bmx_b2shape_getnext(b2Shape * shape);
 	int bmx_b2shape_testpoint(b2Shape * shape, Maxb2XForm * xf, Maxb2Vec2 * p);
 	int bmx_b2shape_testpoint(b2Shape * shape, Maxb2XForm * xf, Maxb2Vec2 * p);
 	float32 bmx_b2shape_getsweepradius(b2Shape * shape);
 	float32 bmx_b2shape_getsweepradius(b2Shape * shape);
@@ -279,8 +290,8 @@ extern "C" {
 	void bmx_b2shape_computeaabb(b2Shape * shape, Maxb2AABB * aabb, Maxb2XForm * xf);
 	void bmx_b2shape_computeaabb(b2Shape * shape, Maxb2AABB * aabb, Maxb2XForm * xf);
 	void bmx_b2shape_computesweptaabb(b2Shape * shape, Maxb2AABB * aabb, Maxb2XForm * xf1, Maxb2XForm * xf2);
 	void bmx_b2shape_computesweptaabb(b2Shape * shape, Maxb2AABB * aabb, Maxb2XForm * xf1, Maxb2XForm * xf2);
 	void bmx_b2shape_computemass(b2Shape * shape, b2MassData * data);
 	void bmx_b2shape_computemass(b2Shape * shape, b2MassData * data);
-	MaxFilterData * bmx_b2shape_getfilterdata(b2Shape * shape);
-	void bmx_b2shape_setfilterdata(b2Shape * shape, MaxFilterData * data);
+	Maxb2FilterData bmx_b2shape_getfilterdata(b2Shape * shape);
+	void bmx_b2shape_setfilterdata(b2Shape * shape, Maxb2FilterData data);
 	void bmx_b2shape_setfriction(b2Shape * shape, float32 friction);
 	void bmx_b2shape_setfriction(b2Shape * shape, float32 friction);
 	void bmx_b2shape_setrestitution(b2Shape * shape, float32 restitution);
 	void bmx_b2shape_setrestitution(b2Shape * shape, float32 restitution);
 	float32 bmx_b2shape_getdensity(b2Shape * shape);
 	float32 bmx_b2shape_getdensity(b2Shape * shape);
@@ -433,15 +444,6 @@ extern "C" {
 	int bmx_b2contact_issolid(b2Contact * contact);
 	int bmx_b2contact_issolid(b2Contact * contact);
 	int32 bmx_b2contact_getmanifoldcount(b2Contact * contact);
 	int32 bmx_b2contact_getmanifoldcount(b2Contact * contact);
 
 
-	MaxFilterData* bmx_b2filterdata_create();
-	uint16  bmx_b2filterdata_getcategorybits(MaxFilterData * filterData);
-	void bmx_b2filterdata_setcategorybits(MaxFilterData * filterData, uint16 categoryBits);
-	uint16  bmx_b2filterdata_getmaskbits(MaxFilterData * filterData);
-	void bmx_b2filterdata_setmaskbits(MaxFilterData * filterData, uint16 maskBits);
-	int16 bmx_b2filterdata_getgroupindex(MaxFilterData * filterData);
-	void bmx_b2filterdata_setgroupindex(MaxFilterData * filterData, int index);
-	void bmx_b2filterdata_delete(MaxFilterData * filterData);
-
 	b2GearJointDef * bmx_b2gearjointdef_new();
 	b2GearJointDef * bmx_b2gearjointdef_new();
 	void bmx_b2gearjointdef_setjoint1(b2GearJointDef * def, b2Joint * joint);
 	void bmx_b2gearjointdef_setjoint1(b2GearJointDef * def, b2Joint * joint);
 	void bmx_b2gearjointdef_setjoint2(b2GearJointDef * def, b2Joint * joint);
 	void bmx_b2gearjointdef_setjoint2(b2GearJointDef * def, b2Joint * joint);
@@ -694,60 +696,6 @@ extern "C" {
 
 
 }
 }
 
 
-class MaxFilterData
-{
-public:
-	MaxFilterData(b2FilterData& fd)
-	{
-		data = &fd;
-		owner = false;
-	}
-
-	MaxFilterData(const b2FilterData& fd)
-	{
-		data = const_cast<b2FilterData *>(&fd);
-		owner = false;
-	}
-
-	MaxFilterData()
-	{
-		data = new b2FilterData;
-		owner = true;
-	}
-
-	~MaxFilterData()
-	{
-		if (owner) {
-			delete data;
-		}
-	}
-	
-	const b2FilterData& getData() {
-		return *data;
-	}
-	
-	void setCategoryBits(uint16 categoryBits) {
-		data->categoryBits = categoryBits;
-	}
-	
-	void setMaskBits(uint16 maskBits) {
-		data->maskBits = maskBits;
-	}
-	
-	void setGroupIndex(int16 index) {
-		data->groupIndex = index;
-	}
-	
-	int16 getGroupIndex() {
-		return data->groupIndex;
-	}
-	
-private:
-	b2FilterData * data;
-	int owner;
-};
-
-
 // *****************************************************
 // *****************************************************
 
 
 class Maxb2EdgeChainDef
 class Maxb2EdgeChainDef
@@ -929,7 +877,7 @@ int32 bmx_b2world_query(b2World * world, Maxb2AABB * aabb, BBArray * shapes) {
 		CB_PREF(physics_box2d_b2World__setShape)(shapes, i, _shapes[i]);
 		CB_PREF(physics_box2d_b2World__setShape)(shapes, i, _shapes[i]);
 	}
 	}
 
 
-	return ret;
+	return count;
 }
 }
 
 
 void bmx_b2world_free(b2World * world) {
 void bmx_b2world_free(b2World * world) {
@@ -1114,12 +1062,15 @@ void bmx_b2shapedef_setdensity(b2ShapeDef * def, float32 density) {
 	def->density = density;
 	def->density = density;
 }
 }
 
 
-void bmx_b2shapedef_setfilter(b2ShapeDef * def, MaxFilterData * filterData) {
-	def->filter = filterData->getData();
+void bmx_b2shapedef_setfilter(b2ShapeDef * def, Maxb2FilterData filterData) {
+	def->filter.categoryBits = filterData.categoryBits;
+	def->filter.groupIndex = filterData.groupIndex;
+	def->filter.maskBits = filterData.maskBits;
 }
 }
 
 
-MaxFilterData* bmx_b2shapedef_getfilter(b2ShapeDef * def) {
-	return new MaxFilterData(def->filter);
+Maxb2FilterData bmx_b2shapedef_getfilter(b2ShapeDef * def) {
+	Maxb2FilterData data = {def->filter.categoryBits, def->filter.maskBits, def->filter.groupIndex};
+	return data;
 }
 }
 
 
 void bmx_b2shapedef_setissensor(b2ShapeDef * def, int sensor) {
 void bmx_b2shapedef_setissensor(b2ShapeDef * def, int sensor) {
@@ -1142,6 +1093,17 @@ float32 bmx_b2shapedef_getdensity(b2ShapeDef * def) {
 	return def->density;
 	return def->density;
 }
 }
 
 
+void bmx_b2shapedef_setfilter_groupindex(b2ShapeDef * def, int groupIndex) {
+	def->filter.groupIndex = (int16)groupIndex;
+}
+
+void bmx_b2shapedef_setfilter_categorybits(b2ShapeDef * def, BBSHORT categoryBits) {
+	def->filter.categoryBits = categoryBits;
+}
+
+void bmx_b2shapedef_setfilter_maskbits(b2ShapeDef * def, BBSHORT maskBits) {
+	def->filter.maskBits = maskBits;
+}
 
 
 // *****************************************************
 // *****************************************************
 
 
@@ -1231,6 +1193,11 @@ BBObject * bmx_b2body_getmaxbody(b2Body * body) {
 	return &bbNullObject;
 	return &bbNullObject;
 }
 }
 
 
+void bmx_b2body_setmaxbody(b2Body * body, BBObject * obj) {
+	body->SetUserData(obj);
+	BBRETAIN(obj);
+}
+
 b2Body * bmx_b2body_getnext(b2Body * body) {
 b2Body * bmx_b2body_getnext(b2Body * body) {
 	return body->GetNext();
 	return body->GetNext();
 }
 }
@@ -1503,6 +1470,11 @@ BBObject * bmx_b2shape_getmaxshape(b2Shape * shape) {
 	return &bbNullObject;
 	return &bbNullObject;
 }
 }
 
 
+void bmx_b2shape_setmaxshape(b2Shape * shape, BBObject * obj) {
+	shape->SetUserData(obj);
+	BBRETAIN(obj);
+}
+
 b2Shape * bmx_b2shape_getnext(b2Shape * shape) {
 b2Shape * bmx_b2shape_getnext(b2Shape * shape) {
 	return shape->GetNext();
 	return shape->GetNext();
 }
 }
@@ -1554,12 +1526,18 @@ void bmx_b2shape_computemass(b2Shape * shape, b2MassData * data) {
 	shape->ComputeMass(data);
 	shape->ComputeMass(data);
 }
 }
 
 
-MaxFilterData * bmx_b2shape_getfilterdata(b2Shape * shape) {
-	return new MaxFilterData(shape->GetFilterData());
+Maxb2FilterData bmx_b2shape_getfilterdata(b2Shape * shape) {
+	b2FilterData filter = shape->GetFilterData();
+	Maxb2FilterData data = {filter.categoryBits, filter.maskBits, filter.groupIndex};
+	return data;
 }
 }
 
 
-void bmx_b2shape_setfilterdata(b2Shape * shape, MaxFilterData * data) {
-	shape->SetFilterData(data->getData());
+void bmx_b2shape_setfilterdata(b2Shape * shape, Maxb2FilterData data) {
+	b2FilterData filter;
+	filter.categoryBits = data.categoryBits;
+	filter.maskBits = data.maskBits;
+	filter.groupIndex = data.groupIndex;
+	shape->SetFilterData(filter);
 }
 }
 
 
 void bmx_b2shape_setfriction(b2Shape * shape, float32 friction) {
 void bmx_b2shape_setfriction(b2Shape * shape, float32 friction) {
@@ -2308,40 +2286,6 @@ int32 bmx_b2contact_getmanifoldcount(b2Contact * contact) {
 
 
 // *****************************************************
 // *****************************************************
 
 
-MaxFilterData * bmx_b2filterdata_create() {
-	return new MaxFilterData();
-}
-
-uint16  bmx_b2filterdata_getcategorybits(MaxFilterData * filterData) {
-	return filterData->getData().categoryBits;
-}
-
-void bmx_b2filterdata_setcategorybits(MaxFilterData * filterData, uint16 categoryBits) {
-	filterData->setCategoryBits(categoryBits);
-}
-
-uint16  bmx_b2filterdata_getmaskbits(MaxFilterData * filterData) {
-	return filterData->getData().maskBits;
-}
-
-void bmx_b2filterdata_setmaskbits(MaxFilterData * filterData, uint16 maskBits) {
-	filterData->setMaskBits(maskBits);
-}
-
-int16 bmx_b2filterdata_getgroupindex(MaxFilterData * filterData) {
-	return filterData->getData().groupIndex;
-}
-
-void bmx_b2filterdata_setgroupindex(MaxFilterData * filterData, int index) {
-	filterData->setGroupIndex(index);
-}
-
-void bmx_b2filterdata_delete(MaxFilterData * filterData) {
-	delete filterData;
-}
-
-// *****************************************************
-
 b2GearJointDef * bmx_b2gearjointdef_new() {
 b2GearJointDef * bmx_b2gearjointdef_new() {
 	return new b2GearJointDef;
 	return new b2GearJointDef;
 }
 }

+ 1 - 1
box2d.mod/source.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2008-2021 Bruce A Henderson
+' Copyright (c) 2008-2022 Bruce A Henderson
 ' 
 ' 
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' Permission is hereby granted, free of charge, to any person obtaining a copy
 ' of this software and associated documentation files (the "Software"), to deal
 ' of this software and associated documentation files (the "Software"), to deal