本文整理汇总了C++中TransportPath::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ TransportPath::Empty方法的具体用法?C++ TransportPath::Empty怎么用?C++ TransportPath::Empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransportPath
的用法示例。
在下文中一共展示了TransportPath::Empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateWaypoints
bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
{
TransportPath path;
sObjectMgr->GetTransportPathNodes(pathid, path);
if (path.Empty())
return false;
std::vector<keyFrame> keyFrames;
int mapChange = 0;
mapids.clear();
for (size_t i = 1; i < path.Size() - 1; ++i)
{
if (mapChange == 0)
{
if ((path[i].mapid == path[i+1].mapid))
{
keyFrame k(path[i].x, path[i].y, path[i].z, path[i].mapid, path[i].actionFlag, path[i].delay);
keyFrames.push_back(k);
mapids.insert(k.mapid);
}
else
{
mapChange = 1;
}
}
else
{
--mapChange;
}
}
int lastStop = -1;
int firstStop = -1;
// first cell is arrived at by teleportation :S
keyFrames[0].distFromPrev = 0;
if (keyFrames[0].actionflag == 2)
{
lastStop = 0;
}
// find the rest of the distances between key points
for (size_t i = 1; i < keyFrames.size(); ++i)
{
if ((keyFrames[i].actionflag == 1) || (keyFrames[i].mapid != keyFrames[i-1].mapid))
{
keyFrames[i].distFromPrev = 0;
}
else
{
keyFrames[i].distFromPrev =
sqrt(pow(keyFrames[i].x - keyFrames[i - 1].x, 2) +
pow(keyFrames[i].y - keyFrames[i - 1].y, 2) +
pow(keyFrames[i].z - keyFrames[i - 1].z, 2));
}
if (keyFrames[i].actionflag == 2)
{
// remember first stop frame
if (firstStop == -1)
firstStop = i;
lastStop = i;
}
}
float tmpDist = 0;
for (size_t i = 0; i < keyFrames.size(); ++i)
{
int j = (i + lastStop) % keyFrames.size();
if (keyFrames[j].actionflag == 2)
tmpDist = 0;
else
tmpDist += keyFrames[j].distFromPrev;
keyFrames[j].distSinceStop = tmpDist;
}
for (int i = int(keyFrames.size()) - 1; i >= 0; i--)
{
int j = (i + (firstStop+1)) % keyFrames.size();
tmpDist += keyFrames[(j + 1) % keyFrames.size()].distFromPrev;
keyFrames[j].distUntilStop = tmpDist;
if (keyFrames[j].actionflag == 2)
tmpDist = 0;
}
for (size_t i = 0; i < keyFrames.size(); ++i)
{
if (keyFrames[i].distSinceStop < (30 * 30 * 0.5f))
keyFrames[i].tFrom = sqrt(2 * keyFrames[i].distSinceStop);
else
keyFrames[i].tFrom = ((keyFrames[i].distSinceStop - (30 * 30 * 0.5f)) / 30) + 30;
if (keyFrames[i].distUntilStop < (30 * 30 * 0.5f))
keyFrames[i].tTo = sqrt(2 * keyFrames[i].distUntilStop);
else
keyFrames[i].tTo = ((keyFrames[i].distUntilStop - (30 * 30 * 0.5f)) / 30) + 30;
keyFrames[i].tFrom *= 1000;
keyFrames[i].tTo *= 1000;
}
//.........这里部分代码省略.........