mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
Implemented physics collision for MeshRoad.
According to deepscratch's post in the forum: http://www.garagegames.com/community/forums/viewthread/130181/1#comment-826897
This commit is contained in:
parent
2554cf6c1a
commit
c328cb53b1
1 changed files with 19 additions and 2 deletions
|
|
@ -49,6 +49,7 @@
|
|||
#include "collision/concretePolyList.h"
|
||||
#include "T3D/physics/physicsPlugin.h"
|
||||
#include "T3D/physics/physicsBody.h"
|
||||
#include "T3D/physics/physicsCollision.h"
|
||||
#include "environment/nodeListManager.h"
|
||||
|
||||
#define MIN_METERS_PER_SEGMENT 1.0f
|
||||
|
|
@ -1722,6 +1723,8 @@ void MeshRoad::_generateSlices()
|
|||
|
||||
void MeshRoad::_generateSegments()
|
||||
{
|
||||
SAFE_DELETE( mPhysicsRep );
|
||||
|
||||
mSegments.clear();
|
||||
|
||||
for ( U32 i = 0; i < mSlices.size() - 1; i++ )
|
||||
|
|
@ -1736,8 +1739,22 @@ void MeshRoad::_generateSegments()
|
|||
|
||||
if ( PHYSICSMGR )
|
||||
{
|
||||
SAFE_DELETE( mPhysicsRep );
|
||||
//mPhysicsRep = PHYSICSMGR->createBody();
|
||||
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 );
|
||||
|
||||
PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
|
||||
mPhysicsRep = PHYSICSMGR->createBody();
|
||||
mPhysicsRep->init( colShape, 0, 0, this, world );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue