This commit is contained in:
Charles 2001-06-05 13:08:23 +00:00
parent 88f26878ed
commit 0a4f638870
3 changed files with 42 additions and 16 deletions

View File

@ -24,13 +24,14 @@
void CNpcBigWheelPlatform::postInit() void CNpcBigWheelPlatform::postInit()
{ {
sBBox boundingBox = m_modelGfx->GetBBox(); CNpcPlatform::postInit();
boundingBox.YMin = boundingBox.YMax - 32; //sBBox boundingBox = m_modelGfx->GetBBox();
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ) - 8, ( boundingBox.YMax - boundingBox.YMin ) ); //boundingBox.YMin = boundingBox.YMax - 32;
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 ); //setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ) - 8, ( boundingBox.YMax - boundingBox.YMin ) );
//setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
calculateNonRotatedCollisionData(); //calculateNonRotatedCollisionData();
setCollisionAngle( m_tiltAngle >> 8 ); //setCollisionAngle( m_tiltAngle >> 8 );
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -104,3 +105,31 @@ const CRECT *CNpcBigWheelPlatform::getThinkBBox()
return &objThinkBox; return &objThinkBox;
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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 );
}

View File

@ -23,6 +23,7 @@ class CNpcBigWheelPlatform : public CNpcPlatform
public: public:
virtual CRECT const *getThinkBBox(); virtual CRECT const *getThinkBBox();
virtual void postInit(); virtual void postInit();
virtual int getHeightFromPlatformAtPosition(int _x,int _y, int offsetX = 0, int offsetY = 0);
protected: protected:
virtual void setWaypoints( sThingPlatform *ThisPlatform ); virtual void setWaypoints( sThingPlatform *ThisPlatform );
virtual void processMovement( int _frames ); virtual void processMovement( int _frames );

View File

@ -713,22 +713,18 @@ if(newmode!=-1)
platform=isOnPlatform(); platform=isOnPlatform();
if(platform) if(platform)
{ {
DVECTOR posDelta;
posDelta=platform->getPosDelta();
posDelta.vy = 0;
shove(posDelta);
int platformOffset = ( ( CNpcPlatform* ) platform )->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy ); int platformOffset = ( ( CNpcPlatform* ) platform )->getHeightFromPlatformAtPosition( Pos.vx, Pos.vy );
int height=CGameScene::getCollision()->getHeightFromGround(Pos.vx,Pos.vy,16); int height=CGameScene::getCollision()->getHeightFromGround(Pos.vx,Pos.vy,16);
if ( platformOffset < height ) if ( platformOffset < height )
{ {
Pos.vy += platformOffset; 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);
}*/
} }