Skip to content

How does HeightFieldShape create width and height? #309

Answered by anugentc
anugentc asked this question in Q&A
Discussion options

You must be logged in to vote

Alright I think I found something.
So when you create the HeightFieldShape, you subtract 1 from it and divide by 2 to get widths and heights.

mWidth(static_cast<decimal>(nbGridColumns - 1)), mLength(static_cast<decimal>(nbGridRows - 1))

My image is 200 x 200. So 200 gets put in for the width and height. Subtracting 1 makes it 199.

mAABB.setMin(Vector3(-mWidth * decimal(0.5), -halfHeight, -mLength * decimal(0.5))); mAABB.setMax(Vector3(mWidth * decimal(0.5), halfHeight, mLength * decimal(0.5)));

And here I see that the width and height (length) are set by halving it. So 199 / 2 = 99.5.

This explains where those values come from.
But now I need to figure out how to correct it.
If I use 20…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@DanielChappuis
Comment options

@anugentc
Comment options

@anugentc
Comment options

@DanielChappuis
Comment options

Answer selected by anugentc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants