| 2468 | //----------------------------------------------------------------------------- |
| 2469 | |
| 2470 | S32 SceneObject::createChainCollisionShape( const U32 pointCount, const b2Vec2* localPoints ) |
| 2471 | { |
| 2472 | // Debug Profiling. |
| 2473 | PROFILE_SCOPE(SceneObject_CreateChainCollisionShape); |
| 2474 | |
| 2475 | // Sanity! |
| 2476 | if ( pointCount < 2 ) |
| 2477 | { |
| 2478 | Con::errorf("SceneObject::createChainCollisionShape() - Invalid point count of %d.", pointCount); |
| 2479 | return -1; |
| 2480 | } |
| 2481 | |
| 2482 | // Configure fixture definition. |
| 2483 | b2FixtureDef* pFixtureDef = new b2FixtureDef( mDefaultFixture ); |
| 2484 | b2ChainShape* pShape = new b2ChainShape(); |
| 2485 | pShape->CreateChain( localPoints, pointCount ); |
| 2486 | pFixtureDef->shape = pShape; |
| 2487 | |
| 2488 | if ( mpScene ) |
| 2489 | { |
| 2490 | // Create and push fixture. |
| 2491 | mCollisionFixtures.push_back( mpBody->CreateFixture( pFixtureDef ) ); |
| 2492 | |
| 2493 | // Destroy shape and fixture. |
| 2494 | delete pShape; |
| 2495 | delete pFixtureDef; |
| 2496 | |
| 2497 | return mCollisionFixtures.size()-1; |
| 2498 | } |
| 2499 | |
| 2500 | // Push fixture definition. |
| 2501 | mCollisionFixtureDefs.push_back( pFixtureDef ); |
| 2502 | |
| 2503 | return mCollisionFixtureDefs.size()-1; |
| 2504 | } |
| 2505 | |
| 2506 | //----------------------------------------------------------------------------- |
| 2507 |
no test coverage detected