After farther investigation, the CreateStaticTerrainBody actually creates 2 bodies. The code is:
Dim landStatic as TVLandScape
Dim bdyStatic as integer
landStatic= Scene.CreateLandScape("StaticLand")
landStatic.CreateEmptyTerrain(CONST_TV_LANDSCAPE_PRECISION.TV_PRECISION_HIGH, 1, 1, -128, -32, -128)
For y As Single = -127 To 127 Step 0.25
For x As Single = -127 To 127 Step 0.25
landStatic.SetHeight(x, y, (-8 * Rnd()) - 32)
Next x
Next y
landStatic.ComputeNormals(True)
landStatic.SetMaterial(mat)
landStatic.SetLightingMode(cstLightingmode)
bdyStatic = Physics.CreateStaticTerrainBody(landStatic)
Physics.GetBodyCount before
bdyStatic = Physics.CreateStaticTerrainBody(landStatic)
returns 0. Physics.GetBodyCount after
bdyStatic = Physics.CreateStaticTerrainBody(landStatic)
return 2. bdyStatic is equal to 0 after
bdyStatic = Physics.CreateStaticTerrainBody(landStatic)
.
When a body collides with the static body, the body ID shows up as 1, never 0.
TestCollision with either 0 or 1 seems to return false. TestCollision never generates any events.
The numbers 0 and 1 result when I create the landscape static body before creating any other body. If I create other bodies before the static body, 4 for example, then the numbers are 4 and 5. So Physics.CreateStaticTerrainBody seems to be generating valid ID's (i.e. not 0). It just generates multiple bodies and seems to return the index of the first body it created for it.
My first concern is that it is creating 2 bodies for 1 landscape with only 1 chunk. My second concern is that the first ID never comes up in a collision regardless of where the body collides with the land. My third concern is that events are being generated for one body index during number runtime collisions, but not the other, yet TestCollision does not generate events for either body ID, nor returns anything but false for either ID.
So this looks like TestCollision is mixing up the IDs, either by a bug with the CreateStaticTerrainBody function creating two many body IDs, or TestCollision not taking into account that the static body has multiple IDs.