MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / copyChainCollisionShapeTo

Method copyChainCollisionShapeTo

engine/source/2d/sceneobject/SceneObject.cc:3257–3295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3255//-----------------------------------------------------------------------------
3256
3257S32 SceneObject::copyChainCollisionShapeTo( SceneObject* pSceneObject, const b2FixtureDef& fixtureDef ) const
3258{
3259 // Fetch shape.
3260 const b2ChainShape* pShape = dynamic_cast<const b2ChainShape*>( fixtureDef.shape );
3261
3262 // Check shape.
3263 if ( !pShape )
3264 {
3265 Con::errorf("SceneObject::copyChainCollisionShapeTo() - Invalid shape.");
3266 return INVALID_COLLISION_SHAPE_INDEX;
3267 }
3268
3269 // Fetch point count.
3270 const U32 pointCount = pShape->m_count;
3271
3272 // Fetch local points.
3273 b2Vec2* localPoints = pShape->m_vertices;
3274
3275 // Fetch adjacent positions.
3276 const bool hasAdjacentLocalPositionStart = pShape->m_hasPrevVertex;
3277 const bool hasAdjacentLocalPositionEnd = pShape->m_hasNextVertex;
3278 const b2Vec2 adjacentLocalPositionStart = pShape->m_prevVertex;
3279 const b2Vec2 adjacentLocalPositionEnd = pShape->m_nextVertex;
3280
3281 // Create shape.
3282 const S32 shapeIndex = pSceneObject->createChainCollisionShape(
3283 pointCount, localPoints,
3284 hasAdjacentLocalPositionStart, hasAdjacentLocalPositionEnd,
3285 adjacentLocalPositionStart, adjacentLocalPositionEnd);
3286
3287 // Was shape created.
3288 if ( shapeIndex != -1 )
3289 {
3290 // Yes, so configure shape.
3291 pSceneObject->setCollisionShapeDefinition( shapeIndex, fixtureDef );
3292 }
3293
3294 return shapeIndex;
3295}
3296
3297//-----------------------------------------------------------------------------
3298

Callers

nothing calls this directly

Calls 3

errorfFunction · 0.85

Tested by

no test coverage detected