Hi, im' using Box2D version 2.1.2 and i've a problem destroying a body...
My body is composed by 4 edges and 1 box. When i destroy it, the application stop on b2Assert(false) in this function:
m_shape_>m_type is 135002112... it's a strange value, maybe something i haven't initialized?
This is how i created my body:
I can't figure out what's wrong... any ideas?
My body is composed by 4 edges and 1 box. When i destroy it, the application stop on b2Assert(false) in this function:
Code:
void b2Fixture::Destroy(b2BlockAllocator* allocator)
{
// The proxy must be destroyed before calling this.
b2Assert(m_proxyId == b2BroadPhase::e_nullProxy);
// Free the child shape.
switch (m_shape->m_type)
{
case b2Shape::e_circle:
{
b2CircleShape* s = (b2CircleShape*)m_shape;
s->~b2CircleShape();
allocator->Free(s, sizeof(b2CircleShape));
}
break;
case b2Shape::e_polygon:
{
b2PolygonShape* s = (b2PolygonShape*)m_shape;
s->~b2PolygonShape();
allocator->Free(s, sizeof(b2PolygonShape));
}
break;
default:
b2Assert(false);
break;
}
m_shape = NULL;
}
{
// The proxy must be destroyed before calling this.
b2Assert(m_proxyId == b2BroadPhase::e_nullProxy);
// Free the child shape.
switch (m_shape->m_type)
{
case b2Shape::e_circle:
{
b2CircleShape* s = (b2CircleShape*)m_shape;
s->~b2CircleShape();
allocator->Free(s, sizeof(b2CircleShape));
}
break;
case b2Shape::e_polygon:
{
b2PolygonShape* s = (b2PolygonShape*)m_shape;
s->~b2PolygonShape();
allocator->Free(s, sizeof(b2PolygonShape));
}
break;
default:
b2Assert(false);
break;
}
m_shape = NULL;
}
m_shape_>m_type is 135002112... it's a strange value, maybe something i haven't initialized?
This is how i created my body:
Code:
b2PolygonShape groundBox;
// bottom
groundBox.SetAsEdge(b2Vec2(0,0), b2Vec2(screenSize.width/PTM_RATIO,0));
b2Fixture* fix = physBody->CreateFixture(&groundBox,0.0);
fix->SetFilterData(filter);
fix->SetSensor(true);
// top
groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO));
fix = physBody->CreateFixture(&groundBox,0.0);
fix->SetFilterData(filter);
fix->SetSensor(true);
// left
groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(0,0));
fix = physBody->CreateFixture(&groundBox,0.0);
fix->SetFilterData(filter);
fix->SetSensor(true);
// right
groundBox.SetAsEdge(b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,0));
fix = physBody->CreateFixture(&groundBox,0.0);
fix->SetFilterData(filter);
fix->SetSensor(true);
#if 1
//no touching zone
b2PolygonShape groundNoTouch;
CGSize noTouchSize = CGSizeMake(screenSize.width/5/PTM_RATIO,screenSize.height/PTM_RATIO);
groundNoTouch.SetAsBox(noTouchSize.width, noTouchSize.height , b2Vec2(noTouchSize.width/2,noTouchSize.height/2),0.0);
noTouchZone = physBody->CreateFixture(&groundNoTouch,0.0);
noTouchZone->SetFilterData(filter);
noTouchZone->SetSensor(true);
#endif
// bottom
groundBox.SetAsEdge(b2Vec2(0,0), b2Vec2(screenSize.width/PTM_RATIO,0));
b2Fixture* fix = physBody->CreateFixture(&groundBox,0.0);
fix->SetFilterData(filter);
fix->SetSensor(true);
// top
groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO));
fix = physBody->CreateFixture(&groundBox,0.0);
fix->SetFilterData(filter);
fix->SetSensor(true);
// left
groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(0,0));
fix = physBody->CreateFixture(&groundBox,0.0);
fix->SetFilterData(filter);
fix->SetSensor(true);
// right
groundBox.SetAsEdge(b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,0));
fix = physBody->CreateFixture(&groundBox,0.0);
fix->SetFilterData(filter);
fix->SetSensor(true);
#if 1
//no touching zone
b2PolygonShape groundNoTouch;
CGSize noTouchSize = CGSizeMake(screenSize.width/5/PTM_RATIO,screenSize.height/PTM_RATIO);
groundNoTouch.SetAsBox(noTouchSize.width, noTouchSize.height , b2Vec2(noTouchSize.width/2,noTouchSize.height/2),0.0);
noTouchZone = physBody->CreateFixture(&groundNoTouch,0.0);
noTouchZone->SetFilterData(filter);
noTouchZone->SetSensor(true);
#endif
I can't figure out what's wrong... any ideas?