Softbody performance issue

qtsohg
Posts: 14
Joined: Fri Oct 24, 2008 3:32 pm

Softbody performance issue

Post by qtsohg »

Hey All,

I must be doing something wrong or no one else must be using Softbodies.

We are working on a football game and I am trying to use the Softbodies to be the net. Now as soon as I enable these nets, the framerate nearly halves!

I am really at the end here and do not know what I should try next.

Here is my code for the actual creation of the softbody:

Code: Select all

sint32 numTris = TriMesh.m_NumTris; // = 579
	sint32 totalVerts = TriMesh.m_NumTris*3; // = 1728
	sint32 ActualNumVerts = TriMesh.m_NumVerts; // = 319

	// lets see which ones we need to attach!
	for (int i = 0; i < ActualNumVerts; i++)
	{
		int CountVert = 0;
		for (int j = 0; j < numTris*3; j++)
		{
			if (TriMesh.m_pIndices[j] == i)
			{
				CountVert++;
			}
		}

		if ((CountVert <= 5) && i <pSoftBody->m_nodes.size())
		{
			pSoftBody->setMass(i, 0);	
		}
		CountVert = 0;
	}
	
	// Middle one!
	pSoftBody->setMass(/*109*/96, 0);
	
 	btSoftBody::Material*	pm=pSoftBody->appendMaterial();
	pm->m_kLST				=	0.1f;
	pm->m_kAST				=	0.1f;
	pm->m_kVST				=	0.4f;
	
	pSoftBody->generateBendingConstraints(2,pm);
	pSoftBody->m_cfg.collisions	=	btSoftBody::fCollision::CL_RS;
	pSoftBody->m_cfg.kVC = 0;
	
	pSoftBody->m_cfg.kKHR		= 0.2f;
	// The commented lines below are different Settings on how the net reacts.
	// Please leave them in for future use.
	//  pSoftBody->m_cfg.kMT	= 0.1f;
	//  pSoftBody->setPose(false, true);
	// 	pSoftBody->m_cfg.kCHR	= 1;
	// 	pSoftBody->m_cfg.kDF	= 1;

	// 	pSoftBody->m_cfg.kSKHR_CL	= 1;
	// 	pSoftBody->m_cfg.kSRHR_CL	= 1;
	// 	pSoftBody->m_cfg.citerations = 1;
	// 	pSoftBody->m_cfg.piterations = 0;

	pSoftBody->generateClusters(64);
	pSoftBody->setTotalMass(10);

	// Finally move the object to position
	pSoftBody->translate(pvectorTobtVector(vPosition bt_cm2m));
	
	pSoftBody->setActivationState(WANTS_DEACTIVATION);
	// Add it to our Dynamic world
	((btSoftRigidDynamicsWorld*)m_pDynamicsWorld)->addSoftBody(pSoftBody);
The NumTris = 576 and ActualNumVerts = 319.

And yes, I have looked at all the softbody examples multiple times. I really am at a loss.

Any pointers? Any suggestions? Please?

Thanks