| 3361 | } |
| 3362 | |
| 3363 | bool Player::canCrouch() |
| 3364 | { |
| 3365 | if (!mAllowCrouching) |
| 3366 | return false; |
| 3367 | |
| 3368 | if ( mState != MoveState || |
| 3369 | mDamageState != Enabled || |
| 3370 | isMounted() || |
| 3371 | mSwimming || |
| 3372 | mFalling ) |
| 3373 | return false; |
| 3374 | |
| 3375 | // Can't crouch if no crouch animation! |
| 3376 | if ( mDataBlock->actionList[PlayerData::CrouchRootAnim].sequence == -1 ) |
| 3377 | return false; |
| 3378 | |
| 3379 | // We are already in this pose, so don't test it again... |
| 3380 | if ( mPose == CrouchPose ) |
| 3381 | return true; |
| 3382 | |
| 3383 | // Do standard Torque physics test here! |
| 3384 | if ( !mPhysicsRep ) |
| 3385 | { |
| 3386 | F32 radius; |
| 3387 | |
| 3388 | if ( mPose == PronePose ) |
| 3389 | radius = mDataBlock->proneBoxSize.z; |
| 3390 | else |
| 3391 | return true; |
| 3392 | |
| 3393 | // use our X and Y dimentions on our boxsize as the radii for our search, and the difference between a standing position |
| 3394 | // and the position we currently are in. |
| 3395 | Point3F extent( mDataBlock->crouchBoxSize.x / 2, mDataBlock->crouchBoxSize.y / 2, mDataBlock->crouchBoxSize.z - radius ); |
| 3396 | |
| 3397 | Point3F position = getPosition(); |
| 3398 | position.z += radius; |
| 3399 | |
| 3400 | // Use these radii to create a box that represents the difference between a standing position and the position |
| 3401 | // we want to move into. |
| 3402 | Box3F B(position - extent, position + extent, true); |
| 3403 | |
| 3404 | EarlyOutPolyList polyList; |
| 3405 | polyList.mPlaneList.clear(); |
| 3406 | polyList.mNormal.set( 0,0,0 ); |
| 3407 | polyList.mPlaneList.setSize( 6 ); |
| 3408 | polyList.mPlaneList[0].set( B.minExtents, VectorF( -1,0,0 ) ); |
| 3409 | polyList.mPlaneList[1].set( B.maxExtents, VectorF( 0,1,0 ) ); |
| 3410 | polyList.mPlaneList[2].set( B.maxExtents, VectorF( 1,0,0 ) ); |
| 3411 | polyList.mPlaneList[3].set( B.minExtents, VectorF( 0,-1,0 ) ); |
| 3412 | polyList.mPlaneList[4].set( B.minExtents, VectorF( 0,0,-1 ) ); |
| 3413 | polyList.mPlaneList[5].set( B.maxExtents, VectorF( 0,0,1 ) ); |
| 3414 | |
| 3415 | // If an object exists in this space, we must stay prone. Otherwise we are free to crouch. |
| 3416 | return !getContainer()->buildPolyList( PLC_Collision, B, StaticShapeObjectType, &polyList ); |
| 3417 | } |
| 3418 | |
| 3419 | return mPhysicsRep->testSpacials( getPosition(), mDataBlock->crouchBoxSize ); |
| 3420 | } |
nothing calls this directly
no test coverage detected