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()
{
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;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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:
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 );

View File

@ -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);
}*/
}