Skip to content

Commit 2711911

Browse files
author
Roger Zanoni
committed
Postpone joint initialization
The bodies connected by joints must be properly initialized before initializing the joint. This is a temporary solution. Signed-off-by: Roger Zanoni <roger.zanoni@openbossa.org>
1 parent dea6647 commit 2711911

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/scene.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "box2dcontactlistener.h"
2727
#include "box2dcontact.h"
2828
#include "box2ddebugdrawitem.h"
29+
#include "box2djointitem.h"
2930

3031
#include <QtCore/QtGlobal>
3132

@@ -156,16 +157,27 @@ void Scene::componentComplete()
156157
#else
157158
QGraphicsItem *item;
158159
#endif
160+
161+
QList<Box2DJointItem *> jointItems;
162+
159163
foreach (item, childItems()) {
160164
if (Entity *entity = dynamic_cast<Entity *>(item))
161165
entity->setScene(this);
162166

163167
if (Box2DBaseItem *box2DItem = dynamic_cast<Box2DBaseItem *>(item)) {
164168
box2DItem->setWorld(m_world);
165-
box2DItem->initialize();
169+
170+
if (Box2DJointItem *box2DJointItem = dynamic_cast<Box2DJointItem *>(item))
171+
jointItems << box2DJointItem;
172+
else
173+
box2DItem->initialize();
166174
}
167175
}
168176

177+
foreach (Box2DJointItem *box2DJointItem, jointItems) {
178+
box2DJointItem->initialize();
179+
}
180+
169181
if (m_debugDraw) {
170182
m_debugDraw->setWidth(width());
171183
m_debugDraw->setHeight(height());

0 commit comments

Comments
 (0)