Box2d b2Island class Solve broken in 3.16 release

I updated my cocos2d-x version from 3.12 to 3.16. I wondered why physics does not work correctly and crashes in some situations in b2Island::Solve method.

In the following code it seems that indexing to m_joints array has a wrong index variable. In my opinion there should be j instead of i:

// Solve position constraints
timer.Reset();
bool positionSolved = false;
for (int32 i = 0; i < step.positionIterations; ++i)
{
	bool contactsOkay = contactSolver.SolvePositionConstraints();

	bool jointsOkay = true;
	for (int32 j = 0; j < m_jointCount; ++j)
	{
		bool jointOkay = m_joints[i]->SolvePositionConstraints(solverData);
		jointsOkay = jointsOkay && jointOkay;
	}

	if (contactsOkay && jointsOkay)
	{
		// Exit early if the position errors are small.
		positionSolved = true;
		break;
	}
}

Do you agree with me?

In addition, in win32 project someone had probably accidentally included an unnecessary command

“xcopy “D:\bamtang\git\cocos2d-x\tests\game-controller-test\Resources\ipadhd” “C:\testing\cocos2d-x-3.16\build\Debug.win32\game-controller-test” /D /E /I /F /Y”

It seems to reference to some hard-coded location in someone’s own computer.

1 Like

Thank you . My app was crashed when I was adding joints to b2world. Now it works.

Great! No problem. Hopefully it will be fixed in the next cocos2d-x release.