Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Feb 23, 2016 4:33 am 
Offline

Joined: Sun Jul 05, 2015 12:55 am
Posts: 16
I have been trying to understand how the btHeightfieldTerrainShape works. I think my main problem is I don't understand what coordinate space the various input and output elements are in.

I am using the following constructor:

Code:
btHeightfieldTerrainShape::btHeightfieldTerrainShape   (   int    heightStickWidth,
int    heightStickLength,
const void *    heightfieldData,
btScalar    heightScale,
btScalar    minHeight,
btScalar    maxHeight,
int    upAxis,
PHY_ScalarType    heightDataType,
bool    flipQuadEdges
)   


I read the following note from: http://www.bulletphysics.com/Bullet/Bul ... Shape.html

Quote:
NOTE: be careful with coordinates. If you have a heightfield with a local min height of -100m, and a max height of +500m, you may be tempted to place it at the origin (0,0) and expect the heights in world coordinates to be -100 to +500 meters. Actually, the heights will be -300 to +300m, because bullet will re-center the heightfield based on its AABB (which is determined by the min/max heights). So keep in mind that once you create a btHeightfieldTerrainShape object, the heights will be adjusted relative to the center of the AABB.


Really? Then how come when I pass larger or smaller values into the minHeight/maxHeight parameters of the constructor, it changes the bounding box but seems to have no effect on where the actual collision boundary is created? For example, I created a btHeightfieldTerrainShape, I used the float data type and passed in an array of floats all with value 0.7. I tried various min and max heights (-5 and 2), (0.6 and 0.8 ), even (0.4 to 0.6 which doesn't even contain 0.7) and the objects in my scene still collided at the exact same location (I had a graphical object drawn at 0.7 units above the ground to inspect).

So... what exactly is this 're-centering' doing? And for the 2d array of height values being passed in.. what space should they be in? So in the example described above (where it gets recentered from (-100,500) to (-300,300).. do I pass in height values within the (-100,500) range or within the (-300,300) range?

Any help in understanding this would be much appreciated.


Top
 Profile  
 
PostPosted: Fri Feb 26, 2016 9:24 pm 
Offline

Joined: Sun Jul 05, 2015 12:55 am
Posts: 16
Is there any more information I could give that would allow someone to better answer my question?


Top
 Profile  
 
PostPosted: Sat Feb 27, 2016 12:18 pm 
Offline

Joined: Sun Jan 03, 2016 4:22 pm
Posts: 15
I'm not sure what you would like to do differently?

We find the min and max heights, then position the shape at the center location between the two extremes.
Just offset your heightfield data to start with (when generating or importing) if you want everything non-zero origin.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Exabot [Bot] and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group