MeshRoad Collision with physics engines?
by Ronald J Nelson · in Torque 3D Professional · 04/25/2014 (6:50 pm) · 4 replies
I just tried using the MeshRoad system while using Bullet and saw that it has no collision. Is there something I am missing?
I saw in another post something deepscratch put in for it, it crashed when I tried it so I am asking.
Thanks in advance.
I saw in another post something deepscratch put in for it, it crashed when I tried it so I am asking.
Thanks in advance.
#2
04/26/2014 (9:44 am)
Quite alright, I figured it out on my own.
#3
05/20/2014 (2:27 pm)
How'd ya fix it?
#4
www.garagegames.com/community/forums/viewthread/130181
Replace the function with the same name with what I have below. It works fine for me so far.
05/24/2014 (2:50 am)
It was a combination of the fixes shown here:www.garagegames.com/community/forums/viewthread/130181
Replace the function with the same name with what I have below. It works fine for me so far.
void MeshRoad::_generateSegments()
{
mSegments.clear();
for ( U32 i = 0; i < mSlices.size() - 1; i++ )
{
MeshRoadSegment seg( &mSlices[i], &mSlices[i+1], getWorldTransform() );
mSegments.push_back( seg );
}
if ( isClientObject() )
_generateVerts();
if ( PHYSICSMGR )
{
SAFE_DELETE( mPhysicsRep );
mPhysicsRep = PHYSICSMGR->createBody();
if( mPhysicsRep )
{
ConcretePolyList polylist;
if (buildPolyList(PLC_Collision, &polylist, getWorldBox(), getWorldSphere()))
{
polylist.triangulate();
PhysicsCollision *colShape = PHYSICSMGR->createCollision();
/*
colShape->addTriangleMesh( polylist.mVertexList.address(),
polylist.mVertexList.size(),
polylist.mIndexList.address(),
polylist.mIndexList.size() / 3,
MatrixF::Identity );
*/
Point3F p[8];
// Points already in world coordinates so we don't need to translate them
for( int i = 0, j = 1; j < mSlices.size(); i++, j++ )
{
p[0] = mSlices[i].pb0;
p[1] = mSlices[i].p0;
p[2] = mSlices[i].p2;
p[3] = mSlices[i].pb2;
p[4] = mSlices[j].pb0;
p[5] = mSlices[j].p0;
p[6] = mSlices[j].p2;
p[7] = mSlices[j].pb2;
colShape->addConvex( &p[0], 8, MatrixF::Identity );
}
PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
mPhysicsRep->init( colShape, 0, 0, this, world );
}
}
}
}
Chris DeBoy