<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/9377" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2013-08-29T18:45:40+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/9377</id>

		<entry>
		<author><name><![CDATA[h[Oz]]]></name></author>
		<updated>2013-08-29T18:45:40+00:00</updated>

		<published>2013-08-29T18:45:40+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=31639#p31639</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=31639#p31639"/>
		<title type="html"><![CDATA[removeCollisionObject EXC_BAD_ACCESS - Objective-C]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=31639#p31639"><![CDATA[
Hello, <br><br>This is my first post here. <br>I'm currently trying to make a "multi-patch" plugin under Quartz Composer (Objective-C) and I'm facing a problem while removing collision objects, stored as pointer values in an NSMutableDictionary. <br><br>I create btRigidBodies with specific shape and attributes, then when I want to deallocate the dynamicsWorld I remove all rigid bodies with removeCollisionObject, but it crashes and I can't find why. <br><br>I checked every allocation / deallocation in my own program and it seems to be OK, but there I have this trouble. Here is the code. I would be extremely grateful if someone had an idea of what's happening. <br><br>Here is the dealloc method, calling a [self removeRigidBody:(btRigidBody *)body] method<div class="codebox"><p>Code: </p><pre><code>- (void) dealloc{    NSArray *keys = [bodiesList allKeys];    for (int i = 0; i &lt; [keys count]; i++) {        [self removeRigidBody:(btRigidBody *)[[bodiesList objectForKey:[keys objectAtIndex:i]] pointerValue]];       // -&gt; pass the btRigidBody to the method    }        //delete collision shapesfor (int j = 0; j &lt; collisionShapes.size(); j++){btCollisionShape *shape = collisionShapes[j];        delete shape;}collisionShapes.clear();        [bodiesList release];    bodiesList = nil;        [super dealloc];}</code></pre></div>The other method : <br><div class="codebox"><p>Code: </p><pre><code>- (void) removeRigidBody:(btRigidBody *)body{    if (body != NULL)    {        delete body-&gt;getMotionState();        delete body-&gt;getCollisionShape();    }    btWorld-&gt;removeCollisionObject(body);       // -&gt; Here I have an EXC_BAD_ACCESS    body = NULL;    }</code></pre></div>Thank you !<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=10425">h[Oz]</a> — Thu Aug 29, 2013 6:45 pm</p><hr />
]]></content>
	</entry>
	</feed>
