ATTRIBUTE_ALIGNED16 doesn't like my vs8 project

stevenLD
Posts: 10
Joined: Fri Sep 14, 2007 1:27 am

ATTRIBUTE_ALIGNED16 doesn't like my vs8 project

Post by stevenLD »

I have my struct which contains a btCompoundShape struct. Unfortunately, due to the btCompoundShape's ATTRIBUTE_ALIGNED16 property, it's throwing an error during compile. (We were assuming that these struct alignments were possibly for PS2 or other consoles with strict rules on memory alignment.) What would be the correct solution to dealing with this issue? Does Bullet ever make use of its ALIGNED16 state in calculations, or is it merely for console compatibility or something like that?

(This compiled fine [or, at least, didn't recognize it was a problem] on our old VS6 project. It only appeared when creating the VS8 version.)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: ATTRIBUTE_ALIGNED16 doesn't like my vs8 project

Post by Erwin Coumans »

It should compile fine under all visual studio versions, I'm using Visual Studio 2005 myself most of the time. The alignment is not only used for consoles, but also for upcoming SIMD/SSE optimizations. Did you open the correct msvc8 projectfile/solution?

Can you provide the error message?
Thanks,
Erwin
stevenLD
Posts: 10
Joined: Fri Sep 14, 2007 1:27 am

Re: ATTRIBUTE_ALIGNED16 doesn't like my vs8 project

Post by stevenLD »

error C2719: 'element': formal parameter with __declspec(align('16')) won't be aligned

Code: Select all

struct CELL
{
	//... bunch of members ...//

	// Bullet Physics
	btRigidBody*		m_pBtPhysicsActor;		// Physics actor.
	btCompoundShape		m_btCollisionShape;		// Physics collision shape
};
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: ATTRIBUTE_ALIGNED16 doesn't like my vs8 project

Post by Erwin Coumans »

It is best to store a pointer to the compoundshape. If possible, it is best to share collision shapes among several rigidbodies.

Alternatively, you can make your CELL structure aligned, using ATTRIBUTE_ALIGNED16(struct) CELL.
Hope this helps,
Erwin
stevenLD
Posts: 10
Joined: Fri Sep 14, 2007 1:27 am

Re: ATTRIBUTE_ALIGNED16 doesn't like my vs8 project

Post by stevenLD »

These compounds will never be common amongst other CELLs, so sharing wasn't really a concern. new/deleting them would probably be disadvantageous as well. We cant straight-up force alignment of our CELL struct for other reasons. However, if the only way to get it to compile is to pad our CELL out to a 16-byte multiple and make sure the btCompoundShape is itself on a 16-byte boundary, then I suppose we'll just have to suck up the wasted space and do it..