btTriangleIndexVertexArray constructing

User avatar
vswbmw
Posts: 4
Joined: Mon May 25, 2009 10:26 am

btTriangleIndexVertexArray constructing

Post by vswbmw »

Why triangleIndexBase & vertexBase in btTriangleIndexVertexArray ctor aren't const? And code below is:

Code: Select all

mesh.m_triangleIndexBase = (const unsigned char *)triangleIndexBase;
mesh.m_vertexBase = (const unsigned char *)vertexBase;
I had added const modifiers and nothing changed in my tests.
Some magic about non const? Or just missed modifiers?
Coz
Posts: 10
Joined: Fri Mar 02, 2007 8:02 pm

Re: btTriangleIndexVertexArray constructing

Post by Coz »

I had do use a const_cast, but at first I thought that maybe the reason is that btTriangleIndexVertexArray might be used for softbodies, but from http://www.bulletphysics.com/mediawiki- ... _Rendering it seems that it uses 'btSoftBodyArray'.

When I browse the repository, in btTriangleIndexVertexArray the constructor has a comment on top, 'just to be backwards compatible', which suggest that this constructor is deprecated, and will be eventually removed, so that might be the reason about why this has not been changed.

Otherwise, maybe a bugfix should be filled, but I don't want to without knowing the details first...
User avatar
jann.poppinga
Posts: 12
Joined: Wed Aug 26, 2009 3:32 pm

Re: btTriangleIndexVertexArray constructing

Post by jann.poppinga »

I looked at the HTMLified source code of the constructor here http://bulletphysics.com/Bullet/BulletF ... ource.html

Code: Select all

00018 btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride)
00019 : m_hasAabb(0)
00020 {
00021         btIndexedMesh mesh;
00022 
00023         mesh.m_numTriangles = numTriangles;
00024         mesh.m_triangleIndexBase = (const unsigned char *)triangleIndexBase;
00025         mesh.m_triangleIndexStride = triangleIndexStride;
00026         mesh.m_numVertices = numVertices;
00027         mesh.m_vertexBase = (const unsigned char *)vertexBase;
00028         mesh.m_vertexStride = vertexStride;
00029 
00030         addIndexedMesh(mesh);
00031 
00032 }
This both confirms that the parameters are quasi-const and also shows a better way to use this feature than using const_cast.