File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,13 +121,35 @@ void jmePhysicsSpace::contactEndedCallback(btPersistentManifold * const &pm) {
121121 return ;
122122 }
123123
124- jmePhysicsSpace * const pSpace = (jmePhysicsSpace *) pUser0->m_jmeSpace ;
124+ jmePhysicsSpace * pSpace = (jmePhysicsSpace *) pUser0->m_jmeSpace ;
125+ // pSpace could be NULL if Body0 was removed from the space.
125126 if (pSpace == NULL ) {
127+ const btCollisionObject * const pBody1 = pm->getBody1 ();
128+ if (pBody1 == NULL ) {
126129#ifdef _DEBUG
127- printf (" null jmePhysicsSpace in contactEndedCallback\n " );
128- fflush (stdout);
130+ printf (" null body 1 in contactEndedCallback\n " );
131+ fflush (stdout);
129132#endif
130- return ;
133+ return ;
134+ }
135+
136+ jmeUserPointer const pUser1 = (jmeUserPointer) pBody1->getUserPointer ();
137+ if (pUser1 == NULL ) {
138+ #ifdef _DEBUG
139+ printf (" null body 1 user pointer in contactEndedCallback\n " );
140+ fflush (stdout);
141+ #endif
142+ return ;
143+ }
144+
145+ pSpace = (jmePhysicsSpace *) pUser1->m_jmeSpace ;
146+ if (pSpace == NULL ) {
147+ #ifdef _DEBUG
148+ printf (" can't access jmePhysicsSpace in contactEndedCallback\n " );
149+ fflush (stdout);
150+ #endif
151+ return ;
152+ }
131153 }
132154
133155#if BT_THREADSAFE
You can’t perform that action at this time.
0 commit comments