// // ParticleEditPacketSender.cpp // interface // // Created by Brad Hefta-Gaub on 8/12/13. // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // // Threaded or non-threaded voxel packet Sender for the Application // #include #include #include #include #include "ParticleEditPacketSender.h" #include "Particle.h" void ParticleEditPacketSender::sendEditParticleMessage(PACKET_TYPE type, ParticleID particleID, const ParticleProperties& properties) { // allows app to disable sending if for example voxels have been disabled if (!_shouldSend) { return; // bail early } static unsigned char bufferOut[MAX_PACKET_SIZE]; int sizeOut = 0; // This encodes the voxel edit message into a buffer... if (Particle::encodeParticleEditMessageDetails(type, particleID, properties, &bufferOut[0], _maxPacketSize, sizeOut)){ // If we don't have voxel jurisdictions, then we will simply queue up these packets and wait till we have // jurisdictions for processing if (!serversExist()) { queuePendingPacketToNodes(type, bufferOut, sizeOut); } else { queuePacketToNodes(bufferOut, sizeOut); } } } void ParticleEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { Particle::adjustEditPacketForClockSkew(codeColorBuffer, length, clockSkew); } void ParticleEditPacketSender::queueParticleEditMessage(PACKET_TYPE type, ParticleID particleID, const ParticleProperties& properties) { if (!_shouldSend) { return; // bail early } // use MAX_PACKET_SIZE since it's static and guaranteed to be larger than _maxPacketSize static unsigned char bufferOut[MAX_PACKET_SIZE]; int sizeOut = 0; if (Particle::encodeParticleEditMessageDetails(type, particleID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) { queueOctreeEditMessage(type, bufferOut, sizeOut); } }