Fix Fixture memory management issues

--HG--
branch : box2d-update
This commit is contained in:
Bill Meltsner
2011-09-24 14:54:06 -04:00
parent 055238659b
commit 8ae43be1fe
2 changed files with 6 additions and 9 deletions
+6 -8
View File
@@ -47,7 +47,6 @@ namespace box2d
def.userData = (void *)data;
def.density = density;
fixture = body->body->CreateFixture(&def);
shape = new Shape(fixture->GetShape());
Memoizer::add(fixture, this);
}
@@ -57,10 +56,7 @@ namespace box2d
data = (fixtureudata *)f->GetUserData();
body = (Body *)Memoizer::find(f->GetBody());
if (!body) body = new Body(f->GetBody());
body->retain();
shape = (Shape *)Memoizer::find(f->GetShape());
if (!shape) shape = new Shape(f->GetShape());
else shape->retain();
else body->retain();
Memoizer::add(fixture, this);
}
@@ -77,12 +73,11 @@ namespace box2d
fixture = 0;
body->release();
shape->release();
}
Shape::Type Fixture::getType() const
{
return shape->getType();
return Shape(fixture->GetShape()).getType();
}
void Fixture::setFriction(float friction)
@@ -132,7 +127,10 @@ namespace box2d
Shape * Fixture::getShape() const
{
return shape;
if (!fixture->GetShape()) return NULL;
Shape * s = (Shape *)Memoizer::find(fixture->GetShape());
if (!s) s = new Shape(fixture->GetShape());
return s;
}
Fixture * Fixture::getNext() const
-1
View File
@@ -60,7 +60,6 @@ namespace box2d
protected:
Body * body;
Shape * shape;
b2Fixture * fixture;
fixtureudata * data;