mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
Merge pull request #758 from eightyeight/meshroad_physics_collision
Implemented physics collision for MeshRoad
This commit is contained in:
commit
469fe3afa7
1 changed files with 19 additions and 2 deletions
|
|
@ -49,6 +49,7 @@
|
||||||
#include "collision/concretePolyList.h"
|
#include "collision/concretePolyList.h"
|
||||||
#include "T3D/physics/physicsPlugin.h"
|
#include "T3D/physics/physicsPlugin.h"
|
||||||
#include "T3D/physics/physicsBody.h"
|
#include "T3D/physics/physicsBody.h"
|
||||||
|
#include "T3D/physics/physicsCollision.h"
|
||||||
#include "environment/nodeListManager.h"
|
#include "environment/nodeListManager.h"
|
||||||
|
|
||||||
#define MIN_METERS_PER_SEGMENT 1.0f
|
#define MIN_METERS_PER_SEGMENT 1.0f
|
||||||
|
|
@ -1722,6 +1723,8 @@ void MeshRoad::_generateSlices()
|
||||||
|
|
||||||
void MeshRoad::_generateSegments()
|
void MeshRoad::_generateSegments()
|
||||||
{
|
{
|
||||||
|
SAFE_DELETE( mPhysicsRep );
|
||||||
|
|
||||||
mSegments.clear();
|
mSegments.clear();
|
||||||
|
|
||||||
for ( U32 i = 0; i < mSlices.size() - 1; i++ )
|
for ( U32 i = 0; i < mSlices.size() - 1; i++ )
|
||||||
|
|
@ -1736,8 +1739,22 @@ void MeshRoad::_generateSegments()
|
||||||
|
|
||||||
if ( PHYSICSMGR )
|
if ( PHYSICSMGR )
|
||||||
{
|
{
|
||||||
SAFE_DELETE( mPhysicsRep );
|
ConcretePolyList polylist;
|
||||||
//mPhysicsRep = PHYSICSMGR->createBody();
|
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