[Bug] btDX11SoftBodySolver crashes if no soft bodies

sakagushi
Posts: 1
Joined: Mon Dec 02, 2013 5:18 pm

[Bug] btDX11SoftBodySolver crashes if no soft bodies

Post by sakagushi »

Greetings,

I was doing some implementation of soft bodies on my current game. At first, I just implemented the btDX11SoftBodySolver, replacing the btDefaultSoftBodySolver, adding the ID3D11Device* and ID3D11DeviceContext* parameters (I am using immediate context).

The bullet library is 2.82 (I am not using SVN)

The soft bodies are loaded on user call (when the user loads a character, for instance), so initially, the physics world has no soft bodies registered.

But, at first frame, the software crashes, on btDX11SoftBodySolver::prepareCollisionConstraints(), line 1281.

It attempts to access an object in an array (m_perClothCollisionObjects), but since there are no objects, it just crashes. The surroundings are:

Code: Select all

	// And update last cloth	
	m_perClothCollisionObjects[currentCloth].firstObject = startIndex;
	m_perClothCollisionObjects[currentCloth].endObject =  m_collisionObjectDetails.size();
My proposed solution:

Code: Select all

	// And update last cloth	
	if (m_perClothCollisionObjects.size() > 0) {
		m_perClothCollisionObjects[currentCloth].firstObject = startIndex;
		m_perClothCollisionObjects[currentCloth].endObject = m_collisionObjectDetails.size();
	}
Adding those checks, the program does not crash. I am not sure if I should do it like this, but it solves this issue.

I also created an issue on the tracker, here: https://code.google.com/p/bullet/issues/detail?id=775
Thanks,
Bruno
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: [Bug] btDX11SoftBodySolver crashes if no soft bodies

Post by Erwin Coumans »

The DX11 and OpenCL cloth in Bullet 2.x is not well maintained and needs work before shipping in a product.

Thanks for the report, if you have a patch we can apply it.
Thanks,
Erwin