Greetings,
I wanted to resize a box, so I did a little searching and saw this post:
http://www.box2d.org/forum/viewtopic.php?f=3&t=5138&p=24251&hilit=resizing#wrapheader
The issue I seem to run into is that if I create the box2d body and then resize it to be larger than it's original size, other bodies can tunnel through the edges of the new larger area. The center (the size of the original box) seems to be solid and I have no tunneling. Also worth mentioning: the issue does not occur if I create a large box first and then resize it to be smaller.
This is a rough visual of what I am creating that has an issue...the center box is the orginal shape and the outer box is the newly set size:
Other bodies will not tunnel through the inner box, but will tunnel through the edges ('.' area) of the outer box.
The basic code I am using is (slightly adapted from the post previously mentioned):
Where newSize is a b2Vec2 of the new width(x) and height(y).
My question is: I am supposed to be doing something after the above to notify box2d that the size of the body has changed? (The debugDraw is showing the new larger box, but collisions only seem to be happening to the smaller original box). Also, I tried calling body->ResetMassData() after the Set calls above, but it did not seem to have any effect.
Any help would be appreciated.
Regards,
Q
PS(I am not changing the number of vertices (or the number of fixtures)...vertices are always 4 and it is a single fixture body)
I wanted to resize a box, so I did a little searching and saw this post:
http://www.box2d.org/forum/viewtopic.php?f=3&t=5138&p=24251&hilit=resizing#wrapheader
The issue I seem to run into is that if I create the box2d body and then resize it to be larger than it's original size, other bodies can tunnel through the edges of the new larger area. The center (the size of the original box) seems to be solid and I have no tunneling. Also worth mentioning: the issue does not occur if I create a large box first and then resize it to be smaller.
This is a rough visual of what I am creating that has an issue...the center box is the orginal shape and the outer box is the newly set size:
Code: Select all
|----------------|
|................|
|...|--------|...|
|...| |...|
|...| |...|
|...|--------|...|
|................|
|----------------|Other bodies will not tunnel through the inner box, but will tunnel through the edges ('.' area) of the outer box.
The basic code I am using is (slightly adapted from the post previously mentioned):
Code: Select all
b2PolygonShape* shape = (b2PolygonShape*)body->GetFixtureList()->GetShape();
shape->m_vertices[0].Set(-newSize.x/2, -newSize.y/2);
shape->m_vertices[1].Set( newSize.x/2, -newSize.y/2);
shape->m_vertices[2].Set( newSize.x/2, newSize.y/2);
shape->m_vertices[3].Set(-newSize.x/2, newSize.y/2);
Where newSize is a b2Vec2 of the new width(x) and height(y).
My question is: I am supposed to be doing something after the above to notify box2d that the size of the body has changed? (The debugDraw is showing the new larger box, but collisions only seem to be happening to the smaller original box). Also, I tried calling body->ResetMassData() after the Set calls above, but it did not seem to have any effect.
Any help would be appreciated.
Regards,
Q
PS(I am not changing the number of vertices (or the number of fixtures)...vertices are always 4 and it is a single fixture body)