| 1522 | } |
| 1523 | |
| 1524 | void ConvexShape::_updateCollision() |
| 1525 | { |
| 1526 | SAFE_DELETE( mPhysicsRep ); |
| 1527 | |
| 1528 | if ( !PHYSICSMGR ) |
| 1529 | return; |
| 1530 | |
| 1531 | PhysicsCollision *colShape = PHYSICSMGR->createCollision(); |
| 1532 | |
| 1533 | // We need the points untransformed! |
| 1534 | Vector<Point3F> rawPoints; |
| 1535 | MatrixF xfm( getWorldTransform() ); |
| 1536 | xfm.setPosition( Point3F::Zero ); |
| 1537 | for ( U32 i=0; i < mGeometry.points.size(); i++ ) |
| 1538 | { |
| 1539 | Point3F p = mGeometry.points[i]; |
| 1540 | xfm.mulP( p ); |
| 1541 | rawPoints.push_back( p ); |
| 1542 | } |
| 1543 | |
| 1544 | // The convex generation from a point cloud |
| 1545 | // can fail at times... give up in that case. |
| 1546 | if ( !colShape->addConvex( mGeometry.points.address(), |
| 1547 | mGeometry.points.size(), |
| 1548 | MatrixF::Identity ) ) |
| 1549 | { |
| 1550 | delete colShape; |
| 1551 | return; |
| 1552 | } |
| 1553 | |
| 1554 | PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" ); |
| 1555 | |
| 1556 | mPhysicsRep = PHYSICSMGR->createBody(); |
| 1557 | mPhysicsRep->init( colShape, 0, 0, this, world ); |
| 1558 | |
| 1559 | mPhysicsRep->setTransform( getTransform() ); |
| 1560 | } |
| 1561 | |
| 1562 | void ConvexShape::_renderDebug( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mat ) |
| 1563 | { |
nothing calls this directly
no test coverage detected