While porting this I found this...

xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: While porting this I found this...

Post by xexuxjy » Tue Oct 20, 2015 8:06 am

Yeah it's pretty stale, but then bullet 2 hasn't really moved on much in that time :)
There's a lot of stuff in the port for pooling frequent objects and an attempt to pass by structs's by reference where possible which helps a lot in terms of memory usage and general performance. It should work under mono as well (you may need to remove the #define XNA which is there to provide compatability between the XNA Vector3,Matrix,etc classes and the local Indexed versions of those). Anyway it would be interesting to see another port if you have the code hosted somewhere.

d3x0r
Posts: 51
Joined: Tue Dec 11, 2012 9:59 pm

Re: While porting this I found this...

Post by d3x0r » Tue Oct 20, 2015 10:38 am

I made too many find and replace errors on a global scale.
I feel I need to restart given what I know now about what it needs.
Made some errors in conversion where vector*matrix was assumed to be the same as matrix*vector and I can't find them now.

Was trying to stick to the original names; bullet XNA renames everything...
or give up and use XNA...

Hard to validate the conversion too...

could wish for a more mechanical conversion... but sorting out things like classes declared in methods would be difficult :)

I dunno so close... yet so far... was a long way into converting Dbvh and ended up swiping the one from XNA; which I learned about the global pools... probably a good thing to have.

xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: While porting this I found this...

Post by xexuxjy » Tue Oct 20, 2015 11:06 am

Definitely. I ran it a lot with the JetBrains tools and the early versions generated a lot of garbage which the pools helped almost completely eradicate. Some of the common vector functions (dot,cross and so on) also are 'unrolled' to avoid some extra function calls.

The biggest thing that I wished I'd done at the beginning would have been coming up with the Indexed (Vector ,Matrix,BasisMatrix) classes first as they make the code conversion from cpp so much easier. Lots of little bugs because I switched vector * matrix to matrix* vector over and they took a _long_ time to track down.

If you want some help removing any XNA hangovers from it, or have some good mono optimisations give me a shout.

User avatar
Erwin Coumans
Site Admin
Posts: 4189
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: While porting this I found this...

Post by Erwin Coumans » Thu Oct 22, 2015 6:21 pm

1e30 instead of BT_LARGE_FLOAT
Yes, this is my sloppy from my side. There are also not enough unit tests there should be more documentation etc.

I hope to find some time to sort it out in a future revision (Bullet 4.x).

d3x0r
Posts: 51
Joined: Tue Dec 11, 2012 9:59 pm

Re: While porting this I found this...

Post by d3x0r » Sat Oct 31, 2015 10:25 pm

in btHingeConstraint.cpp

m_useOffsetForConstraintFrame is typically set to true which is used in things like...

Code: Select all

void btHingeConstraint::getInfo2 (btConstraintInfo2* info)
{
	if(m_useOffsetForConstraintFrame)
	{
		getInfo2InternalUsingFrameOffset(info, m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(),m_rbA.getAngularVelocity(),m_rbB.getAngularVelocity());
	}
	else
	{
		getInfo2Internal(info, m_rbA.getCenterOfMassTransform(),m_rbB.getCenterOfMassTransform(),m_rbA.getAngularVelocity(),m_rbB.getAngularVelocity());
	}
}
but then there's

Code: Select all

void	btHingeConstraint::getInfo2NonVirtual (btConstraintInfo2* info,const btTransform& transA,const btTransform& transB,const btVector3& angVelA,const btVector3& angVelB)
{
	///the regular (virtual) implementation getInfo2 already performs 'testLimit' during getInfo1, so we need to do it now
	testLimit(transA,transB);

	getInfo2Internal(info,transA,transB,angVelA,angVelB);
}
which still calls getInfo2Internal (without frame offset) and doesn't switch on obsolete.


------------
Comment error in btMatrix3x3

Code: Select all

		/*@brief Get the matrix represented as euler angles around ZYX
		 @param yaw Yaw around X axis
		 @param pitch Pitch around Y axis
		 @param roll around X axis 
		 @param solution_number Which solution of two possible solutions ( 1 or 2) are possible values*/
		public void getEulerZYX( out double yaw, out double pitch, out double roll, int solution_number = 1 )
shouldn't this be

Code: Select all

		 @param yaw Yaw around Y axis
		 @param pitch Pitch around X axis
		 @param roll around Z axis 
which I actually found because the same routine is basically in Generic6DofConstraint as matrixToEulerXYZ which fills in a btVector3

Post Reply