本文整理汇总了C++中MapObject::getNextPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ MapObject::getNextPosition方法的具体用法?C++ MapObject::getNextPosition怎么用?C++ MapObject::getNextPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapObject
的用法示例。
在下文中一共展示了MapObject::getNextPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int
wns::Position
Street::getNextPosition(MapUser* user, simTimeType dt) const
{
// in case we just entered this street, we have to determine the
// user's heading. If we come from the crossing at endPoint[0], we
// call it "Forward", otherwise we'll call it "Reverse"
if (user->currentObject!=this->id)
{
MapObject::ID from = user->currentObject;
user->heading = ( ( from==connections.at(0))
? int(Headings::Forward())
: int(Headings::Reverse()) );
user->currentObject=this->id;
}
// how much of this road remains?
double remaining = (1-user->percent)*streetVector.abs();
// is user velocity on this street bounded by vMax?
double currentVelocity = ( user->velocity < vMax ? user->velocity : vMax );
if (currentVelocity*dt < remaining)
{
// we stay on this road and only advance by a certain
// percentage (given through velocity and timestep)
user->percent += (currentVelocity*dt)/streetVector.abs();
MESSAGE_BEGIN(NORMAL, log, m, "MapUser advancing on street ");
m << id << ", completed " << int(100.0*user->percent)
<< "%, velocity " << currentVelocity << "(desired: " << user->velocity << ") m/s";
MESSAGE_END();
return this->getPosition(user);
}
else
{
// we reach the end of this street, how long does that take?
double untilCrossing = remaining/currentVelocity;
// determine the object we'll reach next
MapObject* nextObject = map->getObject(( user->heading==Headings::Forward()
? connections.at(1)
: connections.at(0) ));
// and delegate the decision about the new final position
return nextObject->getNextPosition(user,dt-untilCrossing);
}
}