btCollisionShape::setLocalScaling seems to have no effect

jbacon
Posts: 11
Joined: Wed May 13, 2009 12:30 pm

btCollisionShape::setLocalScaling seems to have no effect

Post by jbacon »

Hi,

Im using Bullet 2.73 under msvc8 pro. Im running into the issue that
calling setLocalScaling( btvector3( 0.5, 0.5, 0.5 ), on a rigidbody
that has a btCylinderShapeX collisionshape doesn't seem to have any
effect; when I check the effective size of the collsion object in my
scene using raycasting, it's as if it's not scaled down at all.

any hints ?

Thanks,

J
jyrenth
Posts: 2
Joined: Wed May 05, 2010 7:37 pm

Re: btCollisionShape::setLocalScaling seems to have no effect

Post by jyrenth »

I'm getting the same problem with a Box collision shape.
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: btCollisionShape::setLocalScaling seems to have no effec

Post by Nacho »

In the btCylinderShape class, the virtual method setLocalScaling is no overwrite, and when you call it, the btConvexInternalShape::setLocalScaling is calling, that only set the m_localScaling member.

Copy setLocalScaling from btCapsuleShape.h to btCylinderShape.h (for example after getRadius method) and it works:

Code: Select all

	virtual void	setLocalScaling(const btVector3& scaling)
	{
		btVector3 oldMargin(getMargin(),getMargin(),getMargin());
		btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
		btVector3 unScaledImplicitShapeDimensionsWithMargin = implicitShapeDimensionsWithMargin / m_localScaling;

		btConvexInternalShape::setLocalScaling(scaling);

		m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin;

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

Re: btCollisionShape::setLocalScaling seems to have no effec

Post by Erwin Coumans »

Please report an issue in the tracker with patch.

Thanks a lot,
Erwin
Nacho
Posts: 31
Joined: Tue Mar 04, 2008 1:41 pm

Re: btCollisionShape::setLocalScaling seems to have no effec

Post by Nacho »