From: <ma...@us...> - 2011-12-19 18:47:16
|
Revision: 7855 http://planeshift.svn.sourceforge.net/planeshift/?rev=7855&view=rev Author: magodra Date: 2011-12-19 18:47:09 +0000 (Mon, 19 Dec 2011) Log Message: ----------- - Fixed stagging movement of npcs, now interruped npcs move smoth as they should. Modified Paths: -------------- trunk/src/npcclient/npcbehave.cpp trunk/src/npcclient/npcoperations.cpp Modified: trunk/src/npcclient/npcbehave.cpp =================================================================== --- trunk/src/npcclient/npcbehave.cpp 2011-12-19 17:42:49 UTC (rev 7854) +++ trunk/src/npcclient/npcbehave.cpp 2011-12-19 18:47:09 UTC (rev 7855) @@ -618,7 +618,7 @@ // This behavior is done so set it inactive active->SetIsActive(false); active = NULL; - break; + // Don't break so that we find a new behavior for this npc. } else { Modified: trunk/src/npcclient/npcoperations.cpp =================================================================== --- trunk/src/npcclient/npcoperations.cpp 2011-12-19 17:42:49 UTC (rev 7854) +++ trunk/src/npcclient/npcoperations.cpp 2011-12-19 18:47:09 UTC (rev 7855) @@ -264,7 +264,7 @@ float velocity = npc->GetLinMove()->GetVelocity().Norm(); float moveLimit = 0.5*velocity*timedelta; // 1/2 the distance that should have been travelled. - float movedDistance = (oldPos - newPos).SquaredNorm(); + float movedDistance = (oldPos - newPos).Norm(); if (movedDistance < moveLimit) // then stopped dead, presumably by collision { @@ -4487,12 +4487,14 @@ float close = GetVelocity(npc)*timedelta; if(distance <= close) { + npc->Printf(5,"We are close %.3f < %.3f",distance,close); + timedelta = distance / GetVelocity(npc); } - npc->Printf(8, "advance: pos=(%f.2,%f.2,%f.2) rot=%.2f %s localDest=%s dist=%f", - myPos.x,myPos.y,myPos.z, myRot, mySector->QueryObject()->GetName(), - destPoint->GetPosition().Description().GetData(),distance); + npc->Printf(8, "advance: pos=%s rot=%.2f localDest=%s dist=%.3f timedelta=%.3f", + toString(myPos,mySector).GetDataSafe(), myRot, + destPoint->GetPosition().Description().GetData(),distance,timedelta); { int ret; @@ -4511,8 +4513,9 @@ iSector* myNewSector; npc->GetLinMove()->GetDRData(on_ground,speed,myNewPos,myRot,myNewSector,bodyVel,worldVel,ang_vel); - npc->Printf(8,"World position bodyVel=%s worldVel=%s", - toString(bodyVel).GetDataSafe(),toString(worldVel).GetDataSafe()); + npc->Printf(8,"World position bodyVel=%s worldVel=%s newPos=%s", + toString(bodyVel).GetDataSafe(),toString(worldVel).GetDataSafe(), + toString(myNewPos,myNewSector).GetDataSafe()); CheckMoveOk(npc, eventmgr, myPos, mySector, myNewPos, myNewSector, timedelta); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |