void PacketBuilder::WriteCatmullRomPath(const MoveSpline& move_spline, ByteBuffer& data) { const Spline<int32> spline = move_spline._Spline(); uint32 count = spline.getPointCount() - 3; data << count; for (uint32 i = 0; i < count; ++i) data << CalcTransportOffset(move_spline, spline.getPoint(2 + i)); }
void PacketBuilder::WriteCatmullRomCyclicPath(const MoveSpline& move_spline, ByteBuffer& data) { const Spline<int32> spline = move_spline._Spline(); uint32 count = spline.getPointCount() - 3; data << uint32(count + 1); data << spline.getPoint(1); // fake point, client will erase it from the spline after first cycle done for (uint32 i = 0; i < count; ++i) data << CalcTransportOffset(move_spline, spline.getPoint(1 + i)); }
void PacketBuilder::WriteLinearPath(const MoveSpline& move_spline, ByteBuffer& data) { const Spline<int32> spline = move_spline._Spline(); uint32 last_idx = spline.getPointCount() - 3; const Vector3 * real_path = &spline.getPoint(1); data << last_idx; data << CalcTransportOffset(move_spline, real_path[last_idx]); // destination if (last_idx > 1) { Vector3 middle = (CalcTransportOffset(move_spline, real_path[0]) + CalcTransportOffset(move_spline, real_path[last_idx])) / 2.f; Vector3 offset; // first and last points already appended for (uint32 i = 1; i < last_idx; ++i) { offset = CalcTransportOffset(move_spline, middle) - CalcTransportOffset(move_spline, real_path[i]); data.appendPackXYZ(offset.x, offset.y, offset.z); } } }