moonshineTheleocat / bullet

Automatically exported from code.google.com/p/bullet
Other
0 stars 0 forks source link

glm and btTransform interoperability problem #697

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
glm::mat4 worldTrans(1);
btTransform objTrans;
objTrans.setIdentity();
objTrans.getOpenGLMatrix(glm::value_ptr(worldTrans));

gdb backtrace
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x0000000100007032 in btMatrix3x3::getOpenGLSubMatrix (this=0x7fff5fbffa80, 
m=0x7fff5fbffad8) at btMatrix3x3.h:360
360         vm[0] = v0;

bullet-2.81-rev2613
Mac OSX ML 10.8.2 64-bit

Original issue reported on code.google.com by omai...@gmail.com on 16 Feb 2013 at 5:32

GoogleCodeExporter commented 9 years ago
getOpenGLMatrix requires the pointer to be 16 byte aligned.

Try using this:
ATTRIBUTE_ALIGNED16(glm::value_ptr v(worldTrans));
objTrans.getOpenGLMatrix(v);

Original comment by erwin.coumans on 11 Sep 2013 at 12:01

GoogleCodeExporter commented 9 years ago
I'm having this problem as well. And adding the ATTRIBUTE_ALIGNED16 didn't help 
me. Can anyone speak to what's going on

Original comment by ryanbart...@gmail.com on 29 Dec 2013 at 11:55

GoogleCodeExporter commented 9 years ago
It now worked but I would like to not have to Align it everytime I want 
something. Is there a way not to do this?

Original comment by ryanbart...@gmail.com on 29 Dec 2013 at 11:59

GoogleCodeExporter commented 9 years ago
You either align the data, or disable all SSE and suffer some performance. SSE 
requires alignment, it is a hardware requirement. It is only necessary in a few 
cases.

Original comment by erwin.coumans on 30 Dec 2013 at 3:34

GoogleCodeExporter commented 9 years ago
Thanks so much for the help. 

Original comment by ryanbart...@gmail.com on 30 Dec 2013 at 5:04

GoogleCodeExporter commented 9 years ago
solved by aligning the glm matrix , not the pointer to it

glm::mat4 ATTRIBUTE_ALIGNED16(worldTrans);
btTransform objTrans;
objTrans.setIdentity();
objTrans.getOpenGLMatrix(glm::value_ptr(worldTrans));

Original comment by omai...@gmail.com on 29 Jan 2014 at 10:59

GoogleCodeExporter commented 9 years ago
thanks for reporting back, I'm glad it works for you.

Original comment by erwin.coumans on 29 Jan 2014 at 11:06

GoogleCodeExporter commented 9 years ago
Many Thanks.

Original comment by omai...@gmail.com on 29 Jan 2014 at 11:09