mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
added flag,seq,st to EnvironmentData, untested
removed/commented out debug prints
This commit is contained in:
parent
c799077379
commit
5d4b0df108
7 changed files with 38 additions and 8 deletions
|
@ -40,12 +40,36 @@ bool VoxelServer::hasSpecialPacketToSend(const SharedNodePointer& node) {
|
||||||
return shouldSendEnvironments;
|
return shouldSendEnvironments;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoxelServer::sendSpecialPacket(OCTREE_PACKET_SEQUENCE& sequence, const SharedNodePointer& node) {
|
int VoxelServer::sendSpecialPacket(OCTREE_PACKET_SEQUENCE& sequenceNumber, const SharedNodePointer& node) {
|
||||||
|
|
||||||
// TODO: add flags, seq, timestamp to packet
|
unsigned char* copyAt = _tempOutputBuffer;
|
||||||
|
|
||||||
int numBytesPacketHeader = populatePacketHeader(reinterpret_cast<char*>(_tempOutputBuffer), PacketTypeEnvironmentData);
|
int numBytesPacketHeader = populatePacketHeader(reinterpret_cast<char*>(_tempOutputBuffer), PacketTypeEnvironmentData);
|
||||||
|
copyAt += numBytesPacketHeader;
|
||||||
int envPacketLength = numBytesPacketHeader;
|
int envPacketLength = numBytesPacketHeader;
|
||||||
|
|
||||||
|
|
||||||
|
// pack in flags
|
||||||
|
OCTREE_PACKET_FLAGS flags = 0;
|
||||||
|
OCTREE_PACKET_FLAGS* flagsAt = (OCTREE_PACKET_FLAGS*)copyAt;
|
||||||
|
*flagsAt = flags;
|
||||||
|
copyAt += sizeof(OCTREE_PACKET_FLAGS);
|
||||||
|
envPacketLength += sizeof(OCTREE_PACKET_FLAGS);
|
||||||
|
|
||||||
|
// pack in sequence number
|
||||||
|
OCTREE_PACKET_SEQUENCE* sequenceAt = (OCTREE_PACKET_SEQUENCE*)copyAt;
|
||||||
|
*sequenceAt = sequenceNumber;
|
||||||
|
copyAt += sizeof(OCTREE_PACKET_SEQUENCE);
|
||||||
|
envPacketLength += sizeof(OCTREE_PACKET_SEQUENCE);
|
||||||
|
|
||||||
|
// pack in timestamp
|
||||||
|
OCTREE_PACKET_SENT_TIME now = usecTimestampNow();
|
||||||
|
OCTREE_PACKET_SENT_TIME* timeAt = (OCTREE_PACKET_SENT_TIME*)copyAt;
|
||||||
|
*timeAt = now;
|
||||||
|
copyAt += sizeof(OCTREE_PACKET_SENT_TIME);
|
||||||
|
envPacketLength += sizeof(OCTREE_PACKET_SENT_TIME);
|
||||||
|
|
||||||
|
|
||||||
int environmentsToSend = getSendMinimalEnvironment() ? 1 : getEnvironmentDataCount();
|
int environmentsToSend = getSendMinimalEnvironment() ? 1 : getEnvironmentDataCount();
|
||||||
|
|
||||||
for (int i = 0; i < environmentsToSend; i++) {
|
for (int i = 0; i < environmentsToSend; i++) {
|
||||||
|
@ -53,6 +77,8 @@ int VoxelServer::sendSpecialPacket(OCTREE_PACKET_SEQUENCE& sequence, const Share
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList::getInstance()->writeDatagram((char*) _tempOutputBuffer, envPacketLength, SharedNodePointer(node));
|
NodeList::getInstance()->writeDatagram((char*) _tempOutputBuffer, envPacketLength, SharedNodePointer(node));
|
||||||
|
sequenceNumber++;
|
||||||
|
|
||||||
return envPacketLength;
|
return envPacketLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
// subclass may implement these method
|
// subclass may implement these method
|
||||||
virtual void beforeRun();
|
virtual void beforeRun();
|
||||||
virtual bool hasSpecialPacketToSend(const SharedNodePointer& node);
|
virtual bool hasSpecialPacketToSend(const SharedNodePointer& node);
|
||||||
virtual int sendSpecialPacket(OCTREE_PACKET_SEQUENCE& sequence, const SharedNodePointer& node);
|
virtual int sendSpecialPacket(OCTREE_PACKET_SEQUENCE& sequenceNumber, const SharedNodePointer& node);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _sendEnvironments;
|
bool _sendEnvironments;
|
||||||
|
|
|
@ -160,6 +160,11 @@ bool Environment::findCapsulePenetration(const glm::vec3& start, const glm::vec3
|
||||||
int Environment::parseData(const HifiSockAddr& senderAddress, const QByteArray& packet) {
|
int Environment::parseData(const HifiSockAddr& senderAddress, const QByteArray& packet) {
|
||||||
// push past the packet header
|
// push past the packet header
|
||||||
int bytesRead = numBytesForPacketHeader(packet);
|
int bytesRead = numBytesForPacketHeader(packet);
|
||||||
|
|
||||||
|
// push past flags, sequence, timestamp
|
||||||
|
bytesRead += sizeof(OCTREE_PACKET_FLAGS);
|
||||||
|
bytesRead += sizeof(OCTREE_PACKET_SEQUENCE);
|
||||||
|
bytesRead += sizeof(OCTREE_PACKET_SENT_TIME);
|
||||||
|
|
||||||
// get the lock for the duration of the call
|
// get the lock for the duration of the call
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
|
|
|
@ -668,7 +668,6 @@ dataAt += sizeof(OCTREE_PACKET_SENT_TIME);
|
||||||
|
|
||||||
uint16_t numberOfIds = 0; // placeholder for now
|
uint16_t numberOfIds = 0; // placeholder for now
|
||||||
memcpy(&numberOfIds, dataAt, sizeof(numberOfIds));
|
memcpy(&numberOfIds, dataAt, sizeof(numberOfIds));
|
||||||
qDebug() << "\t\t\t numberOfIds: " << numberOfIds;
|
|
||||||
dataAt += sizeof(numberOfIds);
|
dataAt += sizeof(numberOfIds);
|
||||||
processedBytes += sizeof(numberOfIds);
|
processedBytes += sizeof(numberOfIds);
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ qint64 LimitedNodeList::writeUnverifiedDatagram(const QByteArray& datagram, cons
|
||||||
|
|
||||||
qint64 LimitedNodeList::writeDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
|
qint64 LimitedNodeList::writeDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
|
||||||
const HifiSockAddr& overridenSockAddr) {
|
const HifiSockAddr& overridenSockAddr) {
|
||||||
|
/*
|
||||||
QByteArray datagram(data, size);
|
QByteArray datagram(data, size);
|
||||||
|
|
||||||
qDebug() << "\t writeDatagram()...";
|
qDebug() << "\t writeDatagram()...";
|
||||||
|
@ -303,7 +303,7 @@ qint64 LimitedNodeList::writeDatagram(const char* data, qint64 size, const Share
|
||||||
dataAt += sizeof(uint16_t);
|
dataAt += sizeof(uint16_t);
|
||||||
qDebug() << "\t\t\t ids: " << ids;
|
qDebug() << "\t\t\t ids: " << ids;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return writeDatagram(QByteArray(data, size), destinationNode, overridenSockAddr);
|
return writeDatagram(QByteArray(data, size), destinationNode, overridenSockAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -868,13 +868,14 @@ bool OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qDebug() << "\t" << QString::number(sequence, 16) << "\t sentAt:" << QString::number(sentAt, 16) << " usecs";
|
//qDebug() << "\t" << QString::number(sequence, 16) << "\t sentAt:" << QString::number(sentAt, 16) << " usecs";
|
||||||
|
|
||||||
// Guard against possible corrupted packets... with bad timestamps
|
// Guard against possible corrupted packets... with bad timestamps
|
||||||
const int MAX_RESONABLE_FLIGHT_TIME = 200 * USECS_PER_SECOND; // 200 seconds is more than enough time for a packet to arrive
|
const int MAX_RESONABLE_FLIGHT_TIME = 200 * USECS_PER_SECOND; // 200 seconds is more than enough time for a packet to arrive
|
||||||
const int MIN_RESONABLE_FLIGHT_TIME = 0;
|
const int MIN_RESONABLE_FLIGHT_TIME = 0;
|
||||||
if (flightTime > MAX_RESONABLE_FLIGHT_TIME || flightTime < MIN_RESONABLE_FLIGHT_TIME) {
|
if (flightTime > MAX_RESONABLE_FLIGHT_TIME || flightTime < MIN_RESONABLE_FLIGHT_TIME) {
|
||||||
qDebug() << "ignoring unreasonable packet... flightTime:" << flightTime;
|
qDebug() << "ignoring unreasonable packet... flightTime:" << flightTime;
|
||||||
|
qDebug() << "\t sequence:" << QString::number(sequence, 16);
|
||||||
qDebug() << "\t sentAt:" << QString::number(sentAt, 16) << " usecs";
|
qDebug() << "\t sentAt:" << QString::number(sentAt, 16) << " usecs";
|
||||||
qDebug() << "\t arrivedAt:" << QString::number(arrivedAt, 16) << " usecs";
|
qDebug() << "\t arrivedAt:" << QString::number(arrivedAt, 16) << " usecs";
|
||||||
qDebug() << "\t nodeClockSkewUsec:" << nodeClockSkewUsec << " usecs";
|
qDebug() << "\t nodeClockSkewUsec:" << nodeClockSkewUsec << " usecs";
|
||||||
|
|
|
@ -633,7 +633,6 @@ dataAt += sizeof(OCTREE_PACKET_SENT_TIME);
|
||||||
|
|
||||||
uint16_t numberOfIds = 0; // placeholder for now
|
uint16_t numberOfIds = 0; // placeholder for now
|
||||||
memcpy(&numberOfIds, dataAt, sizeof(numberOfIds));
|
memcpy(&numberOfIds, dataAt, sizeof(numberOfIds));
|
||||||
qDebug() << "\t\t\t numberOfIds: " << numberOfIds;
|
|
||||||
dataAt += sizeof(numberOfIds);
|
dataAt += sizeof(numberOfIds);
|
||||||
processedBytes += sizeof(numberOfIds);
|
processedBytes += sizeof(numberOfIds);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue