diff --git a/source/platform/pbwheel.cpp b/source/platform/pbwheel.cpp index 2d54c93cf..344f502ac 100644 --- a/source/platform/pbwheel.cpp +++ b/source/platform/pbwheel.cpp @@ -24,13 +24,14 @@ void CNpcBigWheelPlatform::postInit() { - sBBox boundingBox = m_modelGfx->GetBBox(); - boundingBox.YMin = boundingBox.YMax - 32; - setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ) - 8, ( boundingBox.YMax - boundingBox.YMin ) ); - setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 ); + CNpcPlatform::postInit(); + //sBBox boundingBox = m_modelGfx->GetBBox(); + //boundingBox.YMin = boundingBox.YMax - 32; + //setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ) - 8, ( boundingBox.YMax - boundingBox.YMin ) ); + //setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 ); - calculateNonRotatedCollisionData(); - setCollisionAngle( m_tiltAngle >> 8 ); + //calculateNonRotatedCollisionData(); + //setCollisionAngle( m_tiltAngle >> 8 ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -103,4 +104,32 @@ const CRECT *CNpcBigWheelPlatform::getThinkBBox() objThinkBox.y2 = thinkBBox.YMax; return &objThinkBox; -} \ No newline at end of file +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +int CNpcBigWheelPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, int offsetY) +{ + DVECTOR top; + + CRECT collisionArea = getCollisionArea(); + + top.vy = offsetY + collisionArea.y1; + + s32 centreX = ( ( collisionArea.x1 + collisionArea.x2 ) >> 1 ) + offsetX; + + if ( abs( _x - centreX ) <= 20 ) + { + top.vy = offsetY + collisionArea.y2 - 16; + } + else + { + s32 baseY = offsetY + collisionArea.y2 - 16; + + top.vy = baseY + ( ( ( abs( _x - centreX ) - 20 ) * ( offsetY + collisionArea.y1 - baseY ) ) / ( collisionArea.x2 - centreX - 20 ) ); + } + + // Non-rotated platform + + return( top.vy - _y ); +} diff --git a/source/platform/pbwheel.h b/source/platform/pbwheel.h index a1be11c81..00ca69db7 100644 --- a/source/platform/pbwheel.h +++ b/source/platform/pbwheel.h @@ -23,6 +23,7 @@ class CNpcBigWheelPlatform : public CNpcPlatform public: virtual CRECT const *getThinkBBox(); virtual void postInit(); + virtual int getHeightFromPlatformAtPosition(int _x,int _y, int offsetX = 0, int offsetY = 0); protected: virtual void setWaypoints( sThingPlatform *ThisPlatform ); virtual void processMovement( int _frames ); diff --git a/source/player/player.cpp b/source/player/player.cpp index 4605111c2..386332b06 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -713,22 +713,18 @@ if(newmode!=-1) platform=isOnPlatform(); if(platform) { + DVECTOR posDelta; + posDelta=platform->getPosDelta(); + posDelta.vy = 0; + shove(posDelta); + int platformOffset = ( ( CNpcPlatform* ) platform )->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy ); int height=CGameScene::getCollision()->getHeightFromGround(Pos.vx,Pos.vy,16); if ( platformOffset < height ) { Pos.vy += platformOffset; - - DVECTOR posDelta; - posDelta=platform->getPosDelta(); - posDelta.vy = 0; - shove(posDelta); } - /*if(((CNpcPlatform*)platform)->getHeightFromPlatformAtPosition(Pos.vx+posDelta.vx,Pos.vy+posDelta.vy)==0) - { - shove(posDelta); - }*/ }