Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Physics TestCollision doesn't check terrain  (Read 1537 times)
Aki
Customers
Community Member
*****
Posts: 82


« on: December 15, 2009, 01:30:11 PM »

Pretty self explanatory, isn't it? TestCollision doesn't check for bodies created with CreateStaticTerrainBody. This is a pretty important bug. Latest TV version, and all normal static bodies work but not terrain.
« Last Edit: December 15, 2009, 07:40:09 PM by Aki » Logged

Icare
Customers
Community Member
*****
Posts: 107


« Reply #1 on: December 15, 2009, 04:48:51 PM »

I confirm that staticbody not generate event of a collision.

Nicolas
Logged
jviper
Community Member
*
Posts: 2127

Discipline in training


« Reply #2 on: December 16, 2009, 11:48:53 AM »

After farther investigation, the CreateStaticTerrainBody actually creates 2 bodies. The code is:
Code:
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
Code:
bdyStatic = Physics.CreateStaticTerrainBody(landStatic)
returns 0. Physics.GetBodyCount after
Code:
bdyStatic = Physics.CreateStaticTerrainBody(landStatic)
return 2. bdyStatic is equal to 0 after
Code:
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.
« Last Edit: December 16, 2009, 01:07:13 PM by jviper » Logged

JAbstract.....Don't just imagine, make it happen!
SylvainTV
Administrator
Community Member
*****
Posts: 4944


WWW
« Reply #3 on: January 12, 2010, 08:04:35 AM »

Well I will check this.
About the number of body created. There are actually  lots of bodies created for optimization purpose. One per terrain chunk ! But they are hidden to you and only used internally.
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
John Wise
Community Member
*
Posts: 6


« Reply #4 on: January 13, 2010, 01:46:35 PM »

small question:

It seems that you are using the generation model collision polygons for the terrain (chunk by chunk).
The use of NewtonCreateHeightFieldCollision he posed too many problems?

« Last Edit: January 13, 2010, 04:21:15 PM by John Wise » Logged
xavram
Community Member
*
Posts: 525


« Reply #5 on: March 23, 2010, 10:34:36 AM »

Does this mean that if you're trying to check to see if a physics body is in contact with the landscape, you have to check the body vs each id for each chunk?  For example...


Dim CollTyp As Integer
            Dim Coll As TV_EVENT_PHYSICSCOLLISION
            Dim CollCount As Integer = Physics.PollEvents()
           
            For i As Integer = 0 To CollCount - 1
                Coll = Physics.GetEventCollisionDesc(i)
                CollTyp = Physics.GetEventType(i)
                If Coll.iBody1 = dTank.pPropulsionId and Coll.iBody2 = (one of the landscape physics ids) Then dTank.OnGround = True
            Next i
Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4944


WWW
« Reply #6 on: March 27, 2010, 04:33:00 PM »

Exactly.

Might be eaier to use -1 for the second body id in test collision so that it tests with everything.

If you want to know the bodyid of the terrain chunks, it's "bodyofterrain + chunkId"
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
xavram
Community Member
*
Posts: 525


« Reply #7 on: March 30, 2010, 12:47:31 PM »

Yeah, still doesn't seem like it works.

I changed the if  to look like...

If Coll.iBody1 = dTank.pPropulsionId Or Coll.iBody2 = dTank.pPropulsionId Then dTank.OnGround = True

Basically, if the treads physic object (pPropulsionId) is colliding with ANYTHING, assume the tank is "grounded".

But this does not return true on every frame, even if the tank is just sitting still on the ground, not moving.  It returns true/false intermittently.

I tried JVipers suggestion about disabling AutoFreeze on the body but it didn't change the results.
Logged
jviper
Community Member
*
Posts: 2127

Discipline in training


« Reply #8 on: April 04, 2010, 10:27:03 AM »

Well....I wanted to post an sample that confirms this feature was broken. But instead I will post a sample that confirms this feature is not broken. Sorry about that. Anyway, the sample is attached to this post. The source is VB.NET 2008 with binaries in the bin/x86 folder. Again, the MTV3D65.DLL is not included to conserve upload space.

To xavram: To enable the constant collision thingy, disable autofreeze by changing this line:
Code:
Private bolAUTOFREEZE As Boolean = True
to false.

Logged

JAbstract.....Don't just imagine, make it happen!
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks