BasicDemo.cpp changing box to convexHull problems [SOLVED]

sefiroths
Posts: 21
Joined: Thu Nov 11, 2010 1:45 pm

BasicDemo.cpp changing box to convexHull problems [SOLVED]

Post by sefiroths »

hi, i'm trying to learn using bullet from demos provided.
i'm using visual studio 2010
i have started with basicDemo.cpp changing the box in tetraedron, so i have putted this code:

Code: Select all

                float a=1;
		btScalar v[] = {
			0.000000, 1.000000, -0.000000,
			0.942809, -0.333333, 0.000000,
			-0.471405, -0.333333, -0.816497,
			-0.471405, -0.333333, 0.816497
		};


		//btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
		btCollisionShape* colShape = new btConvexHullShape(v,4);
but what is displayed is very confusing...
am i missing something?
Image
/************** test *************/
i have found that adding point so:

Code: Select all

btConvexHullShape* colShapeTemp = new btConvexHullShape();
		btConvexHullShape* colShape = new btConvexHullShape(v,4,12);
		colShapeTemp->addPoint(btVector3(0.000000, 1.000000, -0.000000));
		colShapeTemp->addPoint(btVector3(0.942809, -0.333333, 0.000000));
		colShapeTemp->addPoint(btVector3(-0.471405, -0.333333, -0.816497));
		colShapeTemp->addPoint(btVector3(-0.471405, -0.333333, 0.816497));
		btCollisionShape* colShape =colShapeTemp;
worked well. so step by step i have seen that stride was 16...????
i have tryied again with:

Code: Select all

                float a=1;
		btScalar v[] = {
			0.000000, 1.000000, -0.000000,
			0.942809, -0.333333, 0.000000,
			-0.471405, -0.333333, -0.816497,
			-0.471405, -0.333333, 0.816497
		};


		//btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
		btCollisionShape* colShape = new btConvexHullShape(v,4,12);
and that solved the problem.
perhaps sizeof(btVector3) as btVector3 is a class, doesn't give 12byte (4 byte *3 float) but something different?
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: BasicDemo.cpp changing box to convexHull problems [SOLVE

Post by Flix »

sefiroths wrote:perhaps sizeof(btVector3) as btVector3 is a class, doesn't give 12byte (4 byte *3 float) but something different?
Yes, it should give 16 as far as I know, because of alignment issues...
Using a btVector3 array, instead of a btScalar array, would have solved the problem too.
sefiroths
Posts: 21
Joined: Thu Nov 11, 2010 1:45 pm

Re: BasicDemo.cpp changing box to convexHull problems [SOLVE

Post by sefiroths »

thanks for explanation :D