1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

rwengine: store btCollisionShape along btRigidBody in Part

Should fix this memory leak:
==16721== 103 bytes in 1 blocks are definitely lost in loss record 181 of 264
==16721==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==16721==    by 0x58F1AF3: ??? (in /usr/lib64/libLinearMath.so.2.83)
==16721==    by 0x83E3C9: btBoxShape::operator new(unsigned long) (btBoxShape.h:34)
==16721==    by 0x83CD75: VehicleObject::createObjectHinge(VehicleObject::Part*) (VehicleObject.cpp:722)
==16721==    by 0x83C251: VehicleObject::setPartLocked(VehicleObject::Part*, bool) (VehicleObject.cpp:610)
==16721==    by 0x83C2D0: VehicleObject::setPartTarget(VehicleObject::Part*, bool, float) (VehicleObject.cpp:623)
==16721==    by 0x7B10CD: Activities::EnterVehicle::update(CharacterObject*, CharacterController*) (CharacterController.cpp:226)
==16721==    by 0x7B062D: CharacterController::updateActivity() (CharacterController.cpp:26)
==16721==    by 0x7B09FE: CharacterController::update(float) (CharacterController.cpp:98)
==16721==    by 0x8EBBFA: DefaultAIController::update(float) (DefaultAIController.cpp:87)
==16721==    by 0x82ED5A: CharacterObject::tick(float) (CharacterObject.cpp:240)
==16721==    by 0x763630: RWGame::tick(float) (RWGame.cpp:506)
==16721==
==16721== 120 bytes in 5 blocks are definitely lost in loss record 187 of 264
==16721==    at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==16721==    by 0x8EBA26: DefaultAIController::update(float) (DefaultAIController.cpp:63)
==16721==    by 0x82ED5A: CharacterObject::tick(float) (CharacterObject.cpp:240)
==16721==    by 0x763630: RWGame::tick(float) (RWGame.cpp:506)
==16721==    by 0x763128: RWGame::run() (RWGame.cpp:420)
==16721==    by 0x750394: main (main.cpp:15)
This commit is contained in:
Anonymous Maarten 2017-09-13 18:51:28 +02:00 committed by Daniel Evans
parent eba262b789
commit a610ea2387
2 changed files with 5 additions and 1 deletions

View File

@ -668,7 +668,7 @@ void VehicleObject::registerPart(ModelFrame* mf) {
dynamicParts.insert(
{mf->getName(),
{mf, normal, damage, nullptr, nullptr, false, 0.f, 0.f, 0.f}});
{mf, normal, damage, nullptr, nullptr, nullptr, false, 0.f, 0.f, 0.f}});
}
void VehicleObject::createObjectHinge(Part* part) {
@ -737,6 +737,7 @@ void VehicleObject::createObjectHinge(Part* part) {
hinge->setLimit(hingeMin, hingeMax);
hinge->setBreakingImpulseThreshold(250.f);
part->cs = cs;
part->body = subObject;
part->constraint = hinge;
@ -754,8 +755,10 @@ void VehicleObject::destroyObjectHinge(Part* part) {
engine->dynamicsWorld->removeCollisionObject(part->body);
delete part->body->getMotionState();
delete part->body;
delete part->cs;
}
part->cs = nullptr;
part->body = nullptr;
part->constraint = nullptr;

View File

@ -42,6 +42,7 @@ public:
ModelFrame* dummy;
Atomic* normal;
Atomic* damaged;
btCollisionShape *cs;
btRigidBody* body;
btHingeConstraint* constraint;
bool moveToAngle;