What steps will reproduce the problem?
many contacts at the same time
Problem:
jbox2d 2.1.2
package org.jbox2d.dynamics.contacts
class TOISolver
method initialize(Contact[] contacts, int count, Body toiBody)
Sometimes i got an array index out of bounds exception at line 99:
TOIConstraint constraint = m_constraints[i];
The problem is wrong reallocating:
if(m_count >= m_constraints.length){
TOIConstraint[] old = m_constraints;
m_constraints = new TOIConstraint[old.length*2];
System.arraycopy(old, 0, m_constraints, 0, old.length);
for(int i=old.length; i<m_constraints.length; i++){
m_constraints[i] = new TOIConstraint();
}
}
Exception occurs in the case m_count > old.length*2. This should work:
while(m_count >= m_constraints.length){
TOIConstraint[] old = m_constraints;
m_constraints = new TOIConstraint[old.length*2];
System.arraycopy(old, 0, m_constraints, 0, old.length);
for(int i=old.length; i<m_constraints.length; i++){
m_constraints[i] = new TOIConstraint();
}
}
Have a nice Day
Original issue reported on code.google.com by zel1...@gmail.com on 31 Jul 2011 at 7:51
Original issue reported on code.google.com by
zel1...@gmail.com
on 31 Jul 2011 at 7:51