netmil / box2dweb

Automatically exported from code.google.com/p/box2dweb
0 stars 0 forks source link

AddController doesn't update the m_prev of head #49

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. world.AddController(contA)
2. world.AddController(contB)
3. world.RemoveController(contA)
4. contA.Step is still called at each world step beyond this point.

Add controller never updates contA.m_prev when contB is added. Subsequently, 
RemoveController(contA) call has no effect and contA remains on the list of 
controllers.

What is the expected output? What do you see instead?

I expect contA.Step to not be called from then on.

"Patch" (excuse the non-patch nature, added lines marked with '+'):

b2World.prototype.AddController = function (c) {
+  if( this.m_controllerList !== null ) {
+    this.m_controllerList.m_prev = c;
+  }
    c.m_next = this.m_controllerList;
    c.m_prev = null;
    this.m_controllerList = c;
    c.m_world = this;
    this.m_controllerCount++;
    return c;
}

Original issue reported on code.google.com by nzaluts...@amplify.com on 27 Mar 2015 at 4:26