Default ShouldCollide Method in Box2d Problem

BlitzMax Modules Forums/Brucey's Modules/Default ShouldCollide Method in Box2d Problem

I added this to the collisionfiltering example :
Type myfilter Extends b2ContactFilter
	Method ShouldCollide:Int(shape1:b2Shape, shape2:b2Shape)
	DebugLog "shape1 : " + (shape1 <> Null) + " : shape2 " + (shape2 <> Null)
	
	Local filter1:b2FilterData = shape1.GetFilterData()
Local filter2:b2FilterData = shape2.GetFilterData()
	
If filter1.GetGroupIndex() = filter2.GetGroupIndex() And filter1.GetGroupIndex() <> 0
      Return filter1.GetGroupIndex() > 0
End If
	
Local collide:Int = (filter1.GetMaskBits() & filter2.GetCategoryBits()) <> 0 And (filter1.GetCategoryBits() & filter2.GetMaskBits()) <> 0
Return collide

'		Return True
	End Method
End Type

with this line after the Init(20, 20)
m_world.SetFilter(New myfilter)


and it gave me this output :
Executing:collisionfiltering.debug
DebugLog:shape1 : 1 : shape2 1
DebugLog:shape1 : 1 : shape2 1
DebugLog:shape1 : 1 : shape2 1
DebugLog:shape1 : 1 : shape2 1
DebugLog:shape1 : 1 : shape2 1
DebugLog:shape1 : 1 : shape2 1
DebugLog:shape1 : 1 : shape2 1


and no crashing... on MacOS with the latest from SVN.

From what I can see looking through the source, shape2 should never be null. If it was, then you'd get an exception in the internal code.

One thing you might try is removing the .bmx folders from the module and doing a Build Modules. (or doing something like bmk makemods -a bah.box2d from the console), or Rebuild Modules (except that will do them all).

I'll try the same code on Win32 tomorrow morning.