mirror of
https://github.com/overte-org/overte.git
synced 2025-04-24 21:55:53 +02:00
handle merge with nodelist-patches branch
This commit is contained in:
commit
4ebd5795fc
15 changed files with 50 additions and 66 deletions
|
@ -144,8 +144,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_enableProcessVoxelsThread(true),
|
||||
_voxelProcessor(),
|
||||
_voxelHideShowThread(&_voxels),
|
||||
_voxelEditSender(this),
|
||||
_particleEditSender(this),
|
||||
_packetsPerSecond(0),
|
||||
_bytesPerSecond(0),
|
||||
_recentMaxPackets(0),
|
||||
|
@ -230,6 +228,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER
|
||||
<< NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
|
||||
<< NODE_TYPE_METAVOXEL_SERVER);
|
||||
|
||||
// connect to the packet sent signal of the _voxelEditSender and the _particleEditSender
|
||||
connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent);
|
||||
connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent);
|
||||
|
||||
// move the silentNodeTimer to the _nodeThread
|
||||
QTimer* silentNodeTimer = new QTimer();
|
||||
|
@ -639,21 +641,20 @@ void Application::resetProfile(const QString& username) {
|
|||
}
|
||||
|
||||
void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
const char* nodeTypes, int numNodeTypes) {
|
||||
Application* self = getInstance();
|
||||
for (int i = 0; i < numNodeTypes; ++i) {
|
||||
|
||||
const QSet<NODE_TYPE>& destinationNodeTypes) {
|
||||
foreach(NODE_TYPE type, destinationNodeTypes) {
|
||||
// Intercept data to voxel server when voxels are disabled
|
||||
if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
||||
if (type == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Perform the broadcast for one type
|
||||
int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, & nodeTypes[i], 1);
|
||||
|
||||
int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes,
|
||||
QSet<NODE_TYPE>() << type);
|
||||
|
||||
// Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
|
||||
BandwidthMeter::ChannelIndex channel;
|
||||
switch (nodeTypes[i]) {
|
||||
switch (type) {
|
||||
case NODE_TYPE_AGENT:
|
||||
case NODE_TYPE_AVATAR_MIXER:
|
||||
channel = BandwidthMeter::AVATARS;
|
||||
|
@ -664,7 +665,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_
|
|||
default:
|
||||
continue;
|
||||
}
|
||||
self->_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes);
|
||||
_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1319,15 +1320,13 @@ void Application::wheelEvent(QWheelEvent* event) {
|
|||
}
|
||||
|
||||
void Application::sendPingPackets() {
|
||||
|
||||
const char nodesToPing[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_PARTICLE_SERVER,
|
||||
NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_METAVOXEL_SERVER};
|
||||
|
||||
unsigned char pingPacket[MAX_PACKET_SIZE];
|
||||
int length = NodeList::getInstance()->fillPingPacket(pingPacket);
|
||||
|
||||
getInstance()->controlledBroadcastToNodes(pingPacket, length,
|
||||
nodesToPing, sizeof(nodesToPing));
|
||||
getInstance()->controlledBroadcastToNodes(pingPacket, length, QSet<NODE_TYPE>()
|
||||
<< NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
|
||||
<< NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER
|
||||
<< NODE_TYPE_METAVOXEL_SERVER);
|
||||
}
|
||||
|
||||
// Every second, check the frame rates and other stuff
|
||||
|
@ -2369,9 +2368,8 @@ void Application::updateAvatar(float deltaTime) {
|
|||
|
||||
endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);
|
||||
|
||||
const char nodeTypesOfInterest[] = { NODE_TYPE_AVATAR_MIXER };
|
||||
controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,
|
||||
nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
|
||||
QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
|
||||
|
||||
// Update _viewFrustum with latest camera and view frustum data...
|
||||
// NOTE: we get this from the view frustum, to make it simpler, since the
|
||||
|
@ -3911,7 +3909,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen
|
|||
return statsMessageLength;
|
||||
}
|
||||
|
||||
void Application::packetSentNotification(ssize_t length) {
|
||||
void Application::packetSent(quint64 length) {
|
||||
_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ static const float NODE_KILLED_RED = 1.0f;
|
|||
static const float NODE_KILLED_GREEN = 0.0f;
|
||||
static const float NODE_KILLED_BLUE = 0.0f;
|
||||
|
||||
class Application : public QApplication, public PacketSenderNotify {
|
||||
class Application : public QApplication {
|
||||
Q_OBJECT
|
||||
|
||||
friend class VoxelPacketProcessor;
|
||||
|
@ -172,8 +172,8 @@ public:
|
|||
Profile* getProfile() { return &_profile; }
|
||||
void resetProfile(const QString& username);
|
||||
|
||||
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
const char* nodeTypes, int numNodeTypes);
|
||||
void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
const QSet<NODE_TYPE>& destinationNodeTypes);
|
||||
|
||||
void setupWorldLight();
|
||||
|
||||
|
@ -189,9 +189,6 @@ public:
|
|||
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const;
|
||||
|
||||
|
||||
virtual void packetSentNotification(ssize_t length);
|
||||
|
||||
VoxelShader& getVoxelShader() { return _voxelShader; }
|
||||
PointShader& getPointShader() { return _pointShader; }
|
||||
FileLogger* getLogger() { return _logger; }
|
||||
|
@ -210,7 +207,8 @@ public:
|
|||
public slots:
|
||||
void domainChanged(const QString& domainHostname);
|
||||
void nodeKilled(SharedNodePointer node);
|
||||
|
||||
void packetSent(quint64 length);
|
||||
|
||||
void exportVoxels();
|
||||
void importVoxels();
|
||||
void cutVoxels();
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include <PacketHeaders.h>
|
||||
#include "JurisdictionListener.h"
|
||||
|
||||
JurisdictionListener::JurisdictionListener(NODE_TYPE type, PacketSenderNotify* notify) :
|
||||
_packetSender(notify, JurisdictionListener::DEFAULT_PACKETS_PER_SECOND)
|
||||
JurisdictionListener::JurisdictionListener(NODE_TYPE type) :
|
||||
_packetSender(JurisdictionListener::DEFAULT_PACKETS_PER_SECOND)
|
||||
{
|
||||
_nodeType = type;
|
||||
ReceivedPacketProcessor::_dontSleep = true; // we handle sleeping so this class doesn't need to
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
||||
static const int NO_SERVER_CHECK_RATE = 60; // if no servers yet detected, keep checking at 60fps
|
||||
|
||||
JurisdictionListener(NODE_TYPE type = NODE_TYPE_VOXEL_SERVER, PacketSenderNotify* notify = NULL);
|
||||
JurisdictionListener(NODE_TYPE type = NODE_TYPE_VOXEL_SERVER);
|
||||
|
||||
virtual bool process();
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "JurisdictionSender.h"
|
||||
|
||||
|
||||
JurisdictionSender::JurisdictionSender(JurisdictionMap* map, NODE_TYPE type, PacketSenderNotify* notify) :
|
||||
JurisdictionSender::JurisdictionSender(JurisdictionMap* map, NODE_TYPE type) :
|
||||
ReceivedPacketProcessor(),
|
||||
_jurisdictionMap(map),
|
||||
_packetSender(notify, JurisdictionSender::DEFAULT_PACKETS_PER_SECOND)
|
||||
_packetSender(JurisdictionSender::DEFAULT_PACKETS_PER_SECOND)
|
||||
{
|
||||
_nodeType = type;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class JurisdictionSender : public ReceivedPacketProcessor {
|
|||
public:
|
||||
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
||||
|
||||
JurisdictionSender(JurisdictionMap* map, NODE_TYPE type = NODE_TYPE_VOXEL_SERVER, PacketSenderNotify* notify = NULL);
|
||||
JurisdictionSender(JurisdictionMap* map, NODE_TYPE type = NODE_TYPE_VOXEL_SERVER);
|
||||
~JurisdictionSender();
|
||||
|
||||
void setJurisdiction(JurisdictionMap* map) { _jurisdictionMap = map; }
|
||||
|
|
|
@ -27,8 +27,8 @@ EditPacketBuffer::EditPacketBuffer(PACKET_TYPE type, unsigned char* buffer, ssiz
|
|||
const int OctreeEditPacketSender::DEFAULT_MAX_PENDING_MESSAGES = PacketSender::DEFAULT_PACKETS_PER_SECOND;
|
||||
|
||||
|
||||
OctreeEditPacketSender::OctreeEditPacketSender(PacketSenderNotify* notify) :
|
||||
PacketSender(notify),
|
||||
OctreeEditPacketSender::OctreeEditPacketSender() :
|
||||
PacketSender(),
|
||||
_shouldSend(true),
|
||||
_maxPendingMessages(DEFAULT_MAX_PENDING_MESSAGES),
|
||||
_releaseQueuedMessagesPending(false),
|
||||
|
|
|
@ -28,8 +28,9 @@ public:
|
|||
|
||||
/// Utility for processing, packing, queueing and sending of outbound edit messages.
|
||||
class OctreeEditPacketSender : public PacketSender {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OctreeEditPacketSender(PacketSenderNotify* notify = NULL);
|
||||
OctreeEditPacketSender();
|
||||
~OctreeEditPacketSender();
|
||||
|
||||
/// Queues a single edit message. Will potentially send a pending multi-command packet. Determines which server
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
|
||||
/// Utility for processing, packing, queueing and sending of outbound edit voxel messages.
|
||||
class ParticleEditPacketSender : public OctreeEditPacketSender {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ParticleEditPacketSender(PacketSenderNotify* notify = NULL) : OctreeEditPacketSender(notify) { }
|
||||
~ParticleEditPacketSender() { }
|
||||
|
||||
/// Send particle add message immediately
|
||||
/// NOTE: ParticleProperties assumes that all distances are in meter units
|
||||
void sendEditParticleMessage(PACKET_TYPE type, ParticleID particleID, const ParticleProperties& properties);
|
||||
|
|
|
@ -250,7 +250,7 @@ void ScriptEngine::run() {
|
|||
|
||||
int numAvatarPacketBytes = _avatarData->getBroadcastData(avatarPacket + numAvatarHeaderBytes) + numAvatarHeaderBytes;
|
||||
|
||||
nodeList->broadcastToNodes(avatarPacket, numAvatarPacketBytes, &NODE_TYPE_AVATAR_MIXER, 1);
|
||||
nodeList->broadcastToNodes(avatarPacket, numAvatarPacketBytes, QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
|
||||
}
|
||||
|
||||
if (willSendVisualDataCallBack) {
|
||||
|
|
|
@ -669,12 +669,13 @@ SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
|
|||
}
|
||||
}
|
||||
|
||||
unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) {
|
||||
unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
const QSet<NODE_TYPE>& destinationNodeTypes) {
|
||||
unsigned n = 0;
|
||||
|
||||
foreach (const SharedNodePointer& node, getNodeHash()) {
|
||||
// only send to the NodeTypes we are asked to send to.
|
||||
if (memchr(nodeTypes, node->getType(), numNodeTypes)) {
|
||||
if (destinationNodeTypes.contains(node->getType())) {
|
||||
if (getNodeActiveSocketOrPing(node.data())) {
|
||||
// we know which socket is good for this node, send there
|
||||
_nodeSocket.writeDatagram((char*) broadcastData, dataBytes,
|
||||
|
|
|
@ -90,6 +90,7 @@ public:
|
|||
|
||||
void reset();
|
||||
|
||||
const QSet<NODE_TYPE>& getNodeInterestSet() const { return _nodeTypesOfInterest; }
|
||||
void addNodeTypeToInterestSet(NODE_TYPE nodeTypeToAdd);
|
||||
void addSetOfNodeTypesToNodeInterestSet(const QSet<NODE_TYPE>& setOfNodeTypes);
|
||||
|
||||
|
@ -115,7 +116,7 @@ public:
|
|||
|
||||
int updateNodeWithData(Node *node, const HifiSockAddr& senderSockAddr, unsigned char *packetData, int dataBytes);
|
||||
|
||||
unsigned broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes);
|
||||
unsigned broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const QSet<NODE_TYPE>& destinationNodeTypes);
|
||||
SharedNodePointer soloNodeOfType(char nodeType);
|
||||
|
||||
void loadData(QSettings* settings);
|
||||
|
|
|
@ -27,13 +27,12 @@ const int PacketSender::MINIMAL_SLEEP_INTERVAL = (USECS_PER_SECOND / TARGET_FPS)
|
|||
|
||||
const int AVERAGE_CALL_TIME_SAMPLES = 10;
|
||||
|
||||
PacketSender::PacketSender(PacketSenderNotify* notify, int packetsPerSecond) :
|
||||
PacketSender::PacketSender(int packetsPerSecond) :
|
||||
_packetsPerSecond(packetsPerSecond),
|
||||
_usecsPerProcessCallHint(0),
|
||||
_lastProcessCallTime(0),
|
||||
_averageProcessCallTime(AVERAGE_CALL_TIME_SAMPLES),
|
||||
_lastSendTime(0), // Note: we set this to 0 to indicate we haven't yet sent something
|
||||
_notify(notify),
|
||||
_lastPPSCheck(0),
|
||||
_packetsOverCheckInterval(0),
|
||||
_started(usecTimestampNow()),
|
||||
|
@ -271,10 +270,9 @@ bool PacketSender::nonThreadedProcess() {
|
|||
_packetsOverCheckInterval++;
|
||||
_totalPacketsSent++;
|
||||
_totalBytesSent += temporary.getLength();
|
||||
|
||||
if (_notify) {
|
||||
_notify->packetSentNotification(temporary.getLength());
|
||||
}
|
||||
|
||||
emit packetSent(temporary.getLength());
|
||||
|
||||
_lastSendTime = now;
|
||||
}
|
||||
return isStillRunning();
|
||||
|
|
|
@ -15,15 +15,9 @@
|
|||
#include "NetworkPacket.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
/// Notification Hook for packets being sent by a PacketSender
|
||||
class PacketSenderNotify {
|
||||
public:
|
||||
virtual void packetSentNotification(ssize_t length) = 0;
|
||||
};
|
||||
|
||||
|
||||
/// Generalized threaded processor for queueing and sending of outbound packets.
|
||||
class PacketSender : public GenericThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
static const uint64_t USECS_PER_SECOND;
|
||||
|
@ -35,7 +29,7 @@ public:
|
|||
static const int MINIMUM_PACKETS_PER_SECOND;
|
||||
static const int MINIMAL_SLEEP_INTERVAL;
|
||||
|
||||
PacketSender(PacketSenderNotify* notify = NULL, int packetsPerSecond = DEFAULT_PACKETS_PER_SECOND);
|
||||
PacketSender(int packetsPerSecond = DEFAULT_PACKETS_PER_SECOND);
|
||||
~PacketSender();
|
||||
|
||||
/// Add packet to outbound queue.
|
||||
|
@ -48,9 +42,6 @@ public:
|
|||
void setPacketsPerSecond(int packetsPerSecond);
|
||||
int getPacketsPerSecond() const { return _packetsPerSecond; }
|
||||
|
||||
void setPacketSenderNotify(PacketSenderNotify* notify) { _notify = notify; }
|
||||
PacketSenderNotify* getPacketSenderNotify() const { return _notify; }
|
||||
|
||||
virtual bool process();
|
||||
|
||||
/// are there packets waiting in the send queue to be sent
|
||||
|
@ -97,7 +88,8 @@ public:
|
|||
|
||||
/// returns the total bytes queued by this object over its lifetime
|
||||
uint64_t getLifetimeBytesQueued() const { return _totalBytesQueued; }
|
||||
|
||||
signals:
|
||||
void packetSent(quint64);
|
||||
protected:
|
||||
int _packetsPerSecond;
|
||||
int _usecsPerProcessCallHint;
|
||||
|
@ -107,7 +99,6 @@ protected:
|
|||
private:
|
||||
std::vector<NetworkPacket> _packets;
|
||||
uint64_t _lastSendTime;
|
||||
PacketSenderNotify* _notify;
|
||||
|
||||
bool threadedProcess();
|
||||
bool nonThreadedProcess();
|
||||
|
|
|
@ -15,10 +15,8 @@
|
|||
|
||||
/// Utility for processing, packing, queueing and sending of outbound edit voxel messages.
|
||||
class VoxelEditPacketSender : public OctreeEditPacketSender {
|
||||
Q_OBJECT
|
||||
public:
|
||||
VoxelEditPacketSender(PacketSenderNotify* notify = NULL) : OctreeEditPacketSender(notify) { }
|
||||
~VoxelEditPacketSender() { }
|
||||
|
||||
/// Send voxel edit message immediately
|
||||
void sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail);
|
||||
|
||||
|
|
Loading…
Reference in a new issue