remove debug code

This commit is contained in:
Brad Hefta-Gaub 2014-01-21 14:06:55 -08:00
parent 97b0ed2cc5
commit 278ca02595
5 changed files with 37 additions and 93 deletions

View file

@ -67,7 +67,7 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
uint64_t processTime = 0; uint64_t processTime = 0;
uint64_t lockWaitTime = 0; uint64_t lockWaitTime = 0;
if (true || _myServer->wantsDebugReceiving()) { if (_myServer->wantsDebugReceiving()) {
qDebug() << "PROCESSING THREAD: got '" << packetType << "' packet - " << _receivedPacketCount qDebug() << "PROCESSING THREAD: got '" << packetType << "' packet - " << _receivedPacketCount
<< " command from client receivedBytes=" << packetLength << " command from client receivedBytes=" << packetLength
<< " sequence=" << sequence << " transitTime=" << transitTime << " usecs"; << " sequence=" << sequence << " transitTime=" << transitTime << " usecs";
@ -77,7 +77,7 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
while (atByte < packetLength) { while (atByte < packetLength) {
int maxSize = packetLength - atByte; int maxSize = packetLength - atByte;
if (true || debugProcessPacket) { if (debugProcessPacket) {
printf("OctreeInboundPacketProcessor::processPacket() %c " printf("OctreeInboundPacketProcessor::processPacket() %c "
"packetData=%p packetLength=%ld voxelData=%p atByte=%d maxSize=%d\n", "packetData=%p packetLength=%ld voxelData=%p atByte=%d maxSize=%d\n",
packetType, packetData, packetLength, editData, atByte, maxSize); packetType, packetData, packetLength, editData, atByte, maxSize);

View file

@ -181,12 +181,7 @@ void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t l
const JurisdictionMap& map = (*_serverJurisdictions)[nodeUUID]; const JurisdictionMap& map = (*_serverJurisdictions)[nodeUUID];
isMyJurisdiction = (map.isMyJurisdiction(octCode, CHECK_NODE_ONLY) == JurisdictionMap::WITHIN); isMyJurisdiction = (map.isMyJurisdiction(octCode, CHECK_NODE_ONLY) == JurisdictionMap::WITHIN);
if (isMyJurisdiction) { if (isMyJurisdiction) {
qDebug() << "calling queuePacketToNode(nodeUUID, buffer, length); nodeUUID=" << nodeUUID << " length=" << length;
queuePacketToNode(nodeUUID, buffer, length); queuePacketToNode(nodeUUID, buffer, length);
} else {
qDebug() << "not my jurisdiction skipping queuePacketToNode(nodeUUID, buffer, length); nodeUUID=" << nodeUUID << " length=" << length;
} }
} }
} }
@ -196,13 +191,10 @@ qDebug() << "not my jurisdiction skipping queuePacketToNode(nodeUUID, buffer, le
// NOTE: codeColorBuffer - is JUST the octcode/color and does not contain the packet header! // NOTE: codeColorBuffer - is JUST the octcode/color and does not contain the packet header!
void OctreeEditPacketSender::queueOctreeEditMessage(PACKET_TYPE type, unsigned char* codeColorBuffer, ssize_t length) { void OctreeEditPacketSender::queueOctreeEditMessage(PACKET_TYPE type, unsigned char* codeColorBuffer, ssize_t length) {
qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
if (!_shouldSend) { if (!_shouldSend) {
return; // bail early return; // bail early
} }
qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
// If we don't have jurisdictions, then we will simply queue up all of these packets and wait till we have // If we don't have jurisdictions, then we will simply queue up all of these packets and wait till we have
// jurisdictions for processing // jurisdictions for processing
if (!serversExist()) { if (!serversExist()) {
@ -221,7 +213,7 @@ qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
return; // bail early return; // bail early
} }
qDebug() << "queueOctreeEditMessage() line:" << __LINE__; //qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
// We want to filter out edit messages for servers based on the server's Jurisdiction // We want to filter out edit messages for servers based on the server's Jurisdiction
// But we can't really do that with a packed message, since each edit message could be destined // But we can't really do that with a packed message, since each edit message could be destined
@ -240,17 +232,17 @@ qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
if ((*_serverJurisdictions).find(nodeUUID) != (*_serverJurisdictions).end()) { if ((*_serverJurisdictions).find(nodeUUID) != (*_serverJurisdictions).end()) {
const JurisdictionMap& map = (*_serverJurisdictions)[nodeUUID]; const JurisdictionMap& map = (*_serverJurisdictions)[nodeUUID];
isMyJurisdiction = (map.isMyJurisdiction(codeColorBuffer, CHECK_NODE_ONLY) == JurisdictionMap::WITHIN); isMyJurisdiction = (map.isMyJurisdiction(codeColorBuffer, CHECK_NODE_ONLY) == JurisdictionMap::WITHIN);
qDebug() << "queueOctreeEditMessage() line:" << __LINE__ << " isMyJurisdiction=" << isMyJurisdiction; //qDebug() << "queueOctreeEditMessage() line:" << __LINE__ << " isMyJurisdiction=" << isMyJurisdiction;
} else { } else {
isMyJurisdiction = false; isMyJurisdiction = false;
qDebug() << "queueOctreeEditMessage() line:" << __LINE__; //qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
} }
} }
if (isMyJurisdiction) { if (isMyJurisdiction) {
EditPacketBuffer& packetBuffer = _pendingEditPackets[nodeUUID]; EditPacketBuffer& packetBuffer = _pendingEditPackets[nodeUUID];
packetBuffer._nodeUUID = nodeUUID; packetBuffer._nodeUUID = nodeUUID;
qDebug() << "queueOctreeEditMessage() line:" << __LINE__; //qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
// If we're switching type, then we send the last one and start over // If we're switching type, then we send the last one and start over
if ((type != packetBuffer._currentType && packetBuffer._currentSize > 0) || if ((type != packetBuffer._currentType && packetBuffer._currentSize > 0) ||
@ -270,10 +262,10 @@ qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
// fixup the buffer for any clock skew // fixup the buffer for any clock skew
if (node->getClockSkewUsec() != 0) { if (node->getClockSkewUsec() != 0) {
adjustEditPacketForClockSkew(codeColorBuffer, length, node->getClockSkewUsec()); adjustEditPacketForClockSkew(codeColorBuffer, length, node->getClockSkewUsec());
qDebug() << "queueOctreeEditMessage() line:" << __LINE__; //qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
} }
qDebug() << "queueOctreeEditMessage() line:" << __LINE__; //qDebug() << "queueOctreeEditMessage() line:" << __LINE__;
memcpy(&packetBuffer._currentBuffer[packetBuffer._currentSize], codeColorBuffer, length); memcpy(&packetBuffer._currentBuffer[packetBuffer._currentSize], codeColorBuffer, length);
packetBuffer._currentSize += length; packetBuffer._currentSize += length;
@ -291,14 +283,14 @@ void OctreeEditPacketSender::releaseQueuedMessages() {
} else { } else {
for (std::map<QUuid, EditPacketBuffer>::iterator i = _pendingEditPackets.begin(); i != _pendingEditPackets.end(); i++) { for (std::map<QUuid, EditPacketBuffer>::iterator i = _pendingEditPackets.begin(); i != _pendingEditPackets.end(); i++) {
releaseQueuedPacket(i->second); releaseQueuedPacket(i->second);
qDebug() << "releaseQueuedMessages() line:" << __LINE__; //qDebug() << "releaseQueuedMessages() line:" << __LINE__;
} }
} }
} }
void OctreeEditPacketSender::releaseQueuedPacket(EditPacketBuffer& packetBuffer) { void OctreeEditPacketSender::releaseQueuedPacket(EditPacketBuffer& packetBuffer) {
if (packetBuffer._currentSize > 0 && packetBuffer._currentType != PACKET_TYPE_UNKNOWN) { if (packetBuffer._currentSize > 0 && packetBuffer._currentType != PACKET_TYPE_UNKNOWN) {
qDebug() << "OctreeEditPacketSender::releaseQueuedPacket() line:" << __LINE__; //qDebug() << "OctreeEditPacketSender::releaseQueuedPacket() line:" << __LINE__;
queuePacketToNode(packetBuffer._nodeUUID, &packetBuffer._currentBuffer[0], packetBuffer._currentSize); queuePacketToNode(packetBuffer._nodeUUID, &packetBuffer._currentBuffer[0], packetBuffer._currentSize);
} }
packetBuffer._currentSize = 0; packetBuffer._currentSize = 0;

View file

@ -58,7 +58,7 @@ void Particle::handleAddParticleResponse(unsigned char* packetData , int packetL
memcpy(&particleID, dataAt, sizeof(particleID)); memcpy(&particleID, dataAt, sizeof(particleID));
dataAt += sizeof(particleID); dataAt += sizeof(particleID);
qDebug() << "handleAddParticleResponse()... particleID=" << particleID << " creatorTokenID=" << creatorTokenID; //qDebug() << "handleAddParticleResponse()... particleID=" << particleID << " creatorTokenID=" << creatorTokenID;
// add our token to id mapping // add our token to id mapping
_tokenIDsToIDs[creatorTokenID] = particleID; _tokenIDsToIDs[creatorTokenID] = particleID;
@ -86,10 +86,10 @@ void Particle::init(glm::vec3 position, float radius, rgbColor color, glm::vec3
if (id == NEW_PARTICLE) { if (id == NEW_PARTICLE) {
_id = _nextID; _id = _nextID;
_nextID++; _nextID++;
qDebug() << "Particle::init()... assigning new id... _id=" << _id; //qDebug() << "Particle::init()... assigning new id... _id=" << _id;
} else { } else {
_id = id; _id = id;
qDebug() << "Particle::init()... assigning id from init... _id=" << _id; //qDebug() << "Particle::init()... assigning id from init... _id=" << _id;
} }
uint64_t now = usecTimestampNow(); uint64_t now = usecTimestampNow();
_lastEdited = now; _lastEdited = now;
@ -154,12 +154,9 @@ bool Particle::appendParticleData(OctreePacketData* packetData) const {
if (success) { if (success) {
success = packetData->appendValue(getInHand()); success = packetData->appendValue(getInHand());
} }
/**
if (success) { if (success) {
qDebug() << "appendParticleData().... getShouldDie()=" << getShouldDie();
success = packetData->appendValue(getShouldDie()); success = packetData->appendValue(getShouldDie());
} }
**/
if (success) { if (success) {
uint16_t scriptLength = _script.size() + 1; // include NULL uint16_t scriptLength = _script.size() + 1; // include NULL
@ -274,15 +271,11 @@ int Particle::readParticleDataFromBuffer(const unsigned char* data, int bytesLef
dataAt += sizeof(_inHand); dataAt += sizeof(_inHand);
bytesRead += sizeof(_inHand); bytesRead += sizeof(_inHand);
/**
// shouldDie // shouldDie
memcpy(&_shouldDie, dataAt, sizeof(_shouldDie)); memcpy(&_shouldDie, dataAt, sizeof(_shouldDie));
dataAt += sizeof(_shouldDie); dataAt += sizeof(_shouldDie);
bytesRead += sizeof(_shouldDie); bytesRead += sizeof(_shouldDie);
qDebug() << "readParticleDataFromBuffer().... _shouldDie()=" << _shouldDie;
**/
// script // script
uint16_t scriptLength; uint16_t scriptLength;
memcpy(&scriptLength, dataAt, sizeof(scriptLength)); memcpy(&scriptLength, dataAt, sizeof(scriptLength));
@ -301,7 +294,7 @@ qDebug() << "readParticleDataFromBuffer().... _shouldDie()=" << _shouldDie;
Particle Particle::fromEditPacket(unsigned char* data, int length, int& processedBytes, ParticleTree* tree) { Particle Particle::fromEditPacket(unsigned char* data, int length, int& processedBytes, ParticleTree* tree) {
qDebug() << "Particle::fromEditPacket() length=" << length; //qDebug() << "Particle::fromEditPacket() length=" << length;
Particle newParticle; // id and _lastUpdated will get set here... Particle newParticle; // id and _lastUpdated will get set here...
unsigned char* dataAt = data; unsigned char* dataAt = data;
@ -311,8 +304,8 @@ qDebug() << "Particle::fromEditPacket() length=" << length;
int octets = numberOfThreeBitSectionsInCode(data); int octets = numberOfThreeBitSectionsInCode(data);
int lengthOfOctcode = bytesRequiredForCodeLength(octets); int lengthOfOctcode = bytesRequiredForCodeLength(octets);
qDebug() << "Particle::fromEditPacket() lengthOfOctcode=" << lengthOfOctcode; //qDebug() << "Particle::fromEditPacket() lengthOfOctcode=" << lengthOfOctcode;
printOctalCode(data); //printOctalCode(data);
// we don't actually do anything with this octcode... // we don't actually do anything with this octcode...
dataAt += lengthOfOctcode; dataAt += lengthOfOctcode;
@ -324,13 +317,14 @@ printOctalCode(data);
dataAt += sizeof(editID); dataAt += sizeof(editID);
processedBytes += sizeof(editID); processedBytes += sizeof(editID);
qDebug() << "editID:" << editID; //qDebug() << "editID:" << editID;
bool isNewParticle = (editID == NEW_PARTICLE); bool isNewParticle = (editID == NEW_PARTICLE);
// special case for handling "new" particles // special case for handling "new" particles
if (isNewParticle) { if (isNewParticle) {
qDebug() << "editID == NEW_PARTICLE"; //qDebug() << "editID == NEW_PARTICLE";
// If this is a NEW_PARTICLE, then we assume that there's an additional uint32_t creatorToken, that // If this is a NEW_PARTICLE, then we assume that there's an additional uint32_t creatorToken, that
// we want to send back to the creator as an map to the actual id // we want to send back to the creator as an map to the actual id
uint32_t creatorTokenID; uint32_t creatorTokenID;
@ -338,7 +332,7 @@ qDebug() << "editID == NEW_PARTICLE";
dataAt += sizeof(creatorTokenID); dataAt += sizeof(creatorTokenID);
processedBytes += sizeof(creatorTokenID); processedBytes += sizeof(creatorTokenID);
qDebug() << "creatorTokenID:" << creatorTokenID; //qDebug() << "creatorTokenID:" << creatorTokenID;
newParticle.setCreatorTokenID(creatorTokenID); newParticle.setCreatorTokenID(creatorTokenID);
newParticle._newlyCreated = true; newParticle._newlyCreated = true;
@ -352,10 +346,8 @@ qDebug() << "creatorTokenID:" << creatorTokenID;
// copy existing properties before over-writing with new properties // copy existing properties before over-writing with new properties
if (existingParticle) { if (existingParticle) {
newParticle = *existingParticle; newParticle = *existingParticle;
//qDebug() << "newParticle = *existingParticle... calling debugDump()...";
qDebug() << "newParticle = *existingParticle... calling debugDump()..."; //existingParticle->debugDump();
existingParticle->debugDump();
} }
newParticle._id = editID; newParticle._id = editID;
@ -368,8 +360,6 @@ qDebug() << "newParticle = *existingParticle... calling debugDump()...";
memcpy(&newParticle._lastEdited, dataAt, sizeof(newParticle._lastEdited)); memcpy(&newParticle._lastEdited, dataAt, sizeof(newParticle._lastEdited));
dataAt += sizeof(newParticle._lastEdited); dataAt += sizeof(newParticle._lastEdited);
processedBytes += sizeof(newParticle._lastEdited); processedBytes += sizeof(newParticle._lastEdited);
qDebug() << "newParticle._lastEdited:" << newParticle._lastEdited;
// All of the remaining items are optional, and may or may not be included based on their included values in the // All of the remaining items are optional, and may or may not be included based on their included values in the
// properties included bits // properties included bits
@ -378,7 +368,7 @@ qDebug() << "newParticle._lastEdited:" << newParticle._lastEdited;
memcpy(&packetContainsBits, dataAt, sizeof(packetContainsBits)); memcpy(&packetContainsBits, dataAt, sizeof(packetContainsBits));
dataAt += sizeof(packetContainsBits); dataAt += sizeof(packetContainsBits);
processedBytes += sizeof(packetContainsBits); processedBytes += sizeof(packetContainsBits);
qDebug() << "packetContainsBits:" << packetContainsBits; //qDebug() << "packetContainsBits:" << packetContainsBits;
} }
@ -387,7 +377,6 @@ qDebug() << "newParticle._lastEdited:" << newParticle._lastEdited;
memcpy(&newParticle._radius, dataAt, sizeof(newParticle._radius)); memcpy(&newParticle._radius, dataAt, sizeof(newParticle._radius));
dataAt += sizeof(newParticle._radius); dataAt += sizeof(newParticle._radius);
processedBytes += sizeof(newParticle._radius); processedBytes += sizeof(newParticle._radius);
qDebug() << "newParticle._radius:" << newParticle._radius;
} }
// position // position
@ -395,7 +384,6 @@ qDebug() << "newParticle._radius:" << newParticle._radius;
memcpy(&newParticle._position, dataAt, sizeof(newParticle._position)); memcpy(&newParticle._position, dataAt, sizeof(newParticle._position));
dataAt += sizeof(newParticle._position); dataAt += sizeof(newParticle._position);
processedBytes += sizeof(newParticle._position); processedBytes += sizeof(newParticle._position);
qDebug() << "newParticle._position:";
} }
// color // color
@ -403,7 +391,6 @@ qDebug() << "newParticle._position:";
memcpy(newParticle._color, dataAt, sizeof(newParticle._color)); memcpy(newParticle._color, dataAt, sizeof(newParticle._color));
dataAt += sizeof(newParticle._color); dataAt += sizeof(newParticle._color);
processedBytes += sizeof(newParticle._color); processedBytes += sizeof(newParticle._color);
qDebug() << "newParticle._color:";
} }
// velocity // velocity
@ -411,7 +398,6 @@ qDebug() << "newParticle._color:";
memcpy(&newParticle._velocity, dataAt, sizeof(newParticle._velocity)); memcpy(&newParticle._velocity, dataAt, sizeof(newParticle._velocity));
dataAt += sizeof(newParticle._velocity); dataAt += sizeof(newParticle._velocity);
processedBytes += sizeof(newParticle._velocity); processedBytes += sizeof(newParticle._velocity);
qDebug() << "newParticle._velocity:";
} }
// gravity // gravity
@ -419,7 +405,6 @@ qDebug() << "newParticle._velocity:";
memcpy(&newParticle._gravity, dataAt, sizeof(newParticle._gravity)); memcpy(&newParticle._gravity, dataAt, sizeof(newParticle._gravity));
dataAt += sizeof(newParticle._gravity); dataAt += sizeof(newParticle._gravity);
processedBytes += sizeof(newParticle._gravity); processedBytes += sizeof(newParticle._gravity);
qDebug() << "newParticle._gravity:";
} }
// damping // damping
@ -427,7 +412,6 @@ qDebug() << "newParticle._gravity:";
memcpy(&newParticle._damping, dataAt, sizeof(newParticle._damping)); memcpy(&newParticle._damping, dataAt, sizeof(newParticle._damping));
dataAt += sizeof(newParticle._damping); dataAt += sizeof(newParticle._damping);
processedBytes += sizeof(newParticle._damping); processedBytes += sizeof(newParticle._damping);
qDebug() << "newParticle._damping:" << newParticle._damping;
} }
// lifetime // lifetime
@ -435,7 +419,6 @@ qDebug() << "newParticle._damping:" << newParticle._damping;
memcpy(&newParticle._lifetime, dataAt, sizeof(newParticle._lifetime)); memcpy(&newParticle._lifetime, dataAt, sizeof(newParticle._lifetime));
dataAt += sizeof(newParticle._lifetime); dataAt += sizeof(newParticle._lifetime);
processedBytes += sizeof(newParticle._lifetime); processedBytes += sizeof(newParticle._lifetime);
qDebug() << "newParticle._lifetime:" << newParticle._lifetime;
} }
// TODO: make inHand and shouldDie into single bits // TODO: make inHand and shouldDie into single bits
@ -444,18 +427,14 @@ qDebug() << "newParticle._lifetime:" << newParticle._lifetime;
memcpy(&newParticle._inHand, dataAt, sizeof(newParticle._inHand)); memcpy(&newParticle._inHand, dataAt, sizeof(newParticle._inHand));
dataAt += sizeof(newParticle._inHand); dataAt += sizeof(newParticle._inHand);
processedBytes += sizeof(newParticle._inHand); processedBytes += sizeof(newParticle._inHand);
qDebug() << "newParticle._inHand:" << newParticle._inHand;
} }
/**
// shouldDie // shouldDie
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SHOULDDIE) == PACKET_CONTAINS_SHOULDDIE)) { if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SHOULDDIE) == PACKET_CONTAINS_SHOULDDIE)) {
memcpy(&newParticle._shouldDie, dataAt, sizeof(newParticle._shouldDie)); memcpy(&newParticle._shouldDie, dataAt, sizeof(newParticle._shouldDie));
dataAt += sizeof(newParticle._shouldDie); dataAt += sizeof(newParticle._shouldDie);
processedBytes += sizeof(newParticle._shouldDie); processedBytes += sizeof(newParticle._shouldDie);
qDebug() << "fromEditPacket().... newParticle._shouldDie=" << newParticle._shouldDie;
} }
**/
// script // script
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SCRIPT) == PACKET_CONTAINS_SCRIPT)) { if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SCRIPT) == PACKET_CONTAINS_SCRIPT)) {
@ -467,10 +446,9 @@ qDebug() << "fromEditPacket().... newParticle._shouldDie=" << newParticle._shoul
newParticle._script = tempString; newParticle._script = tempString;
dataAt += scriptLength; dataAt += scriptLength;
processedBytes += scriptLength; processedBytes += scriptLength;
qDebug() << "newParticle._script:" << newParticle._script;
} }
const bool wantDebugging = true; const bool wantDebugging = false;
if (wantDebugging) { if (wantDebugging) {
qDebug("Particle::fromEditPacket()..."); qDebug("Particle::fromEditPacket()...");
qDebug() << " Particle id in packet:" << editID; qDebug() << " Particle id in packet:" << editID;
@ -507,8 +485,9 @@ bool Particle::encodeParticleEditMessageDetails(PACKET_TYPE command, ParticleID
float rootScale = 0.5f; float rootScale = 0.5f;
unsigned char* octcode = pointToOctalCode(rootPosition.x, rootPosition.y, rootPosition.z, rootScale); unsigned char* octcode = pointToOctalCode(rootPosition.x, rootPosition.y, rootPosition.z, rootScale);
// old code... this matters for particle servers with different jurisdictions, but for now, we'll send // TODO: Consider this old code... including the correct octree for where the particle will go matters for
// everything to the root, since the tree does the right thing... // particle servers with different jurisdictions, but for now, we'll send everything to the root, since the
// tree does the right thing...
// //
//unsigned char* octcode = pointToOctalCode(details[i].position.x, details[i].position.y, //unsigned char* octcode = pointToOctalCode(details[i].position.x, details[i].position.y,
// details[i].position.z, details[i].radius); // details[i].position.z, details[i].radius);
@ -533,17 +512,14 @@ bool Particle::encodeParticleEditMessageDetails(PACKET_TYPE command, ParticleID
memcpy(copyAt, &id.id, sizeof(id.id)); memcpy(copyAt, &id.id, sizeof(id.id));
copyAt += sizeof(id.id); copyAt += sizeof(id.id);
sizeOut += sizeof(id.id); sizeOut += sizeof(id.id);
qDebug() << "encoding, id.id:" << id.id;
// special case for handling "new" particles // special case for handling "new" particles
if (isNewParticle) { if (isNewParticle) {
qDebug() << "encodeParticleEditMessageDetails()... isNewParticle...";
// If this is a NEW_PARTICLE, then we assume that there's an additional uint32_t creatorToken, that // If this is a NEW_PARTICLE, then we assume that there's an additional uint32_t creatorToken, that
// we want to send back to the creator as an map to the actual id // we want to send back to the creator as an map to the actual id
memcpy(copyAt, &id.creatorTokenID, sizeof(id.creatorTokenID)); memcpy(copyAt, &id.creatorTokenID, sizeof(id.creatorTokenID));
copyAt += sizeof(id.creatorTokenID); copyAt += sizeof(id.creatorTokenID);
sizeOut += sizeof(id.creatorTokenID); sizeOut += sizeof(id.creatorTokenID);
qDebug() << "encoding, id.creatorTokenID:" << id.creatorTokenID;
} }
// lastEdited // lastEdited
@ -551,8 +527,6 @@ qDebug() << "encoding, id.creatorTokenID:" << id.creatorTokenID;
memcpy(copyAt, &lastEdited, sizeof(lastEdited)); memcpy(copyAt, &lastEdited, sizeof(lastEdited));
copyAt += sizeof(lastEdited); copyAt += sizeof(lastEdited);
sizeOut += sizeof(lastEdited); sizeOut += sizeof(lastEdited);
qDebug() << "encoding, lastEdited:" << lastEdited;
// For new particles, all remaining items are mandatory, for an edited particle, All of the remaining items are // For new particles, all remaining items are mandatory, for an edited particle, All of the remaining items are
// optional, and may or may not be included based on their included values in the properties included bits // optional, and may or may not be included based on their included values in the properties included bits
@ -561,7 +535,6 @@ qDebug() << "encoding, lastEdited:" << lastEdited;
memcpy(copyAt, &packetContainsBits, sizeof(packetContainsBits)); memcpy(copyAt, &packetContainsBits, sizeof(packetContainsBits));
copyAt += sizeof(packetContainsBits); copyAt += sizeof(packetContainsBits);
sizeOut += sizeof(packetContainsBits); sizeOut += sizeof(packetContainsBits);
qDebug() << "encoding, packetContainsBits:" << packetContainsBits;
} }
// radius // radius
@ -570,7 +543,6 @@ qDebug() << "encoding, packetContainsBits:" << packetContainsBits;
memcpy(copyAt, &radius, sizeof(radius)); memcpy(copyAt, &radius, sizeof(radius));
copyAt += sizeof(radius); copyAt += sizeof(radius);
sizeOut += sizeof(radius); sizeOut += sizeof(radius);
qDebug() << "encoding, radius:" << radius;
} }
// position // position
@ -578,7 +550,6 @@ qDebug() << "encoding, radius:" << radius;
memcpy(copyAt, &properties.getPosition(), sizeof(properties.getPosition())); memcpy(copyAt, &properties.getPosition(), sizeof(properties.getPosition()));
copyAt += sizeof(properties.getPosition()); copyAt += sizeof(properties.getPosition());
sizeOut += sizeof(properties.getPosition()); sizeOut += sizeof(properties.getPosition());
qDebug() << "encoding, properties.getPosition():";
} }
// color // color
@ -587,7 +558,6 @@ qDebug() << "encoding, properties.getPosition():";
memcpy(copyAt, color, sizeof(color)); memcpy(copyAt, color, sizeof(color));
copyAt += sizeof(color); copyAt += sizeof(color);
sizeOut += sizeof(color); sizeOut += sizeof(color);
qDebug() << "encoding, color:";
} }
// velocity // velocity
@ -595,7 +565,6 @@ qDebug() << "encoding, color:";
memcpy(copyAt, &properties.getVelocity(), sizeof(properties.getVelocity())); memcpy(copyAt, &properties.getVelocity(), sizeof(properties.getVelocity()));
copyAt += sizeof(properties.getVelocity()); copyAt += sizeof(properties.getVelocity());
sizeOut += sizeof(properties.getVelocity()); sizeOut += sizeof(properties.getVelocity());
qDebug() << "encoding, getVelocity:";
} }
// gravity // gravity
@ -603,7 +572,6 @@ qDebug() << "encoding, getVelocity:";
memcpy(copyAt, &properties.getGravity(), sizeof(properties.getGravity())); memcpy(copyAt, &properties.getGravity(), sizeof(properties.getGravity()));
copyAt += sizeof(properties.getGravity()); copyAt += sizeof(properties.getGravity());
sizeOut += sizeof(properties.getGravity()); sizeOut += sizeof(properties.getGravity());
qDebug() << "encoding, getGravity():";
} }
// damping // damping
@ -612,7 +580,6 @@ qDebug() << "encoding, getGravity():";
memcpy(copyAt, &damping, sizeof(damping)); memcpy(copyAt, &damping, sizeof(damping));
copyAt += sizeof(damping); copyAt += sizeof(damping);
sizeOut += sizeof(damping); sizeOut += sizeof(damping);
qDebug() << "encoding, damping:" << damping;
} }
// lifetime // lifetime
@ -621,7 +588,6 @@ qDebug() << "encoding, damping:" << damping;
memcpy(copyAt, &lifetime, sizeof(lifetime)); memcpy(copyAt, &lifetime, sizeof(lifetime));
copyAt += sizeof(lifetime); copyAt += sizeof(lifetime);
sizeOut += sizeof(lifetime); sizeOut += sizeof(lifetime);
qDebug() << "encoding, lifetime:" << lifetime;
} }
// inHand // inHand
@ -630,19 +596,15 @@ qDebug() << "encoding, lifetime:" << lifetime;
memcpy(copyAt, &inHand, sizeof(inHand)); memcpy(copyAt, &inHand, sizeof(inHand));
copyAt += sizeof(inHand); copyAt += sizeof(inHand);
sizeOut += sizeof(inHand); sizeOut += sizeof(inHand);
qDebug() << "encoding, inHand:" << inHand;
} }
/**
// shoulDie // shoulDie
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SHOULDDIE) == PACKET_CONTAINS_SHOULDDIE)) { if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SHOULDDIE) == PACKET_CONTAINS_SHOULDDIE)) {
bool shouldDie = properties.getShouldDie(); bool shouldDie = properties.getShouldDie();
memcpy(copyAt, &shouldDie, sizeof(shouldDie)); memcpy(copyAt, &shouldDie, sizeof(shouldDie));
copyAt += sizeof(shouldDie); copyAt += sizeof(shouldDie);
sizeOut += sizeof(shouldDie); sizeOut += sizeof(shouldDie);
qDebug() << "encoding, shouldDie:" << shouldDie;
} }
**/
// script // script
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SCRIPT) == PACKET_CONTAINS_SCRIPT)) { if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SCRIPT) == PACKET_CONTAINS_SCRIPT)) {
@ -653,7 +615,6 @@ qDebug() << "encoding, shouldDie:" << shouldDie;
memcpy(copyAt, qPrintable(properties.getScript()), scriptLength); memcpy(copyAt, qPrintable(properties.getScript()), scriptLength);
copyAt += scriptLength; copyAt += scriptLength;
sizeOut += scriptLength; sizeOut += scriptLength;
qDebug() << "encoding, getScript:" << properties.getScript();
} }
bool wantDebugging = false; bool wantDebugging = false;
@ -666,8 +627,8 @@ qDebug() << "encoding, getScript:" << properties.getScript();
// cleanup // cleanup
delete[] octcode; delete[] octcode;
qDebug() << "encoding... sizeOut:" << sizeOut; //qDebug() << "encoding... sizeOut:" << sizeOut;
return success; return success;
} }
@ -721,8 +682,6 @@ void Particle::update(const uint64_t& now) {
bool shouldDie = getShouldDie() || (!isInHand && isStopped && isReallyOld); bool shouldDie = getShouldDie() || (!isInHand && isStopped && isReallyOld);
setShouldDie(shouldDie); setShouldDie(shouldDie);
//qDebug() << "update()... getShouldDie()=" << getShouldDie();
runUpdateScript(); // allow the javascript to alter our state runUpdateScript(); // allow the javascript to alter our state
// If the ball is in hand, it doesn't move or have gravity effect it // If the ball is in hand, it doesn't move or have gravity effect it
@ -931,12 +890,11 @@ uint16_t ParticleProperties::getChangedBits() const {
changedBits += PACKET_CONTAINS_SCRIPT; changedBits += PACKET_CONTAINS_SCRIPT;
} }
/**
// how do we want to handle this? // how do we want to handle this?
if (_shouldDieChanged) { if (_shouldDieChanged) {
changedBits += PACKET_CONTAINS_SHOULDDIE; changedBits += PACKET_CONTAINS_SHOULDDIE;
} }
**/
return changedBits; return changedBits;
} }

View file

@ -32,9 +32,6 @@ void ParticleEditPacketSender::sendEditParticleMessage(PACKET_TYPE type, Particl
if (!serversExist()) { if (!serversExist()) {
queuePendingPacketToNodes(type, bufferOut, sizeOut); queuePendingPacketToNodes(type, bufferOut, sizeOut);
} else { } else {
qDebug("calling queuePacketToNodes(bufferOut, sizeOut=%d)... ", sizeOut);
queuePacketToNodes(bufferOut, sizeOut); queuePacketToNodes(bufferOut, sizeOut);
} }
} }
@ -46,9 +43,6 @@ void ParticleEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeC
void ParticleEditPacketSender::queueParticleEditMessage(PACKET_TYPE type, ParticleID particleID, const ParticleProperties& properties) { void ParticleEditPacketSender::queueParticleEditMessage(PACKET_TYPE type, ParticleID particleID, const ParticleProperties& properties) {
qDebug() << "ParticleEditPacketSender::queueParticleEditMessage() id.id=" << particleID.id << " id.creatorTokenID=" << particleID.creatorTokenID;
if (!_shouldSend) { if (!_shouldSend) {
return; // bail early return; // bail early
} }
@ -58,9 +52,6 @@ qDebug() << "ParticleEditPacketSender::queueParticleEditMessage() id.id=" << par
int sizeOut = 0; int sizeOut = 0;
if (Particle::encodeParticleEditMessageDetails(type, particleID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) { if (Particle::encodeParticleEditMessageDetails(type, particleID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) {
qDebug("calling queueOctreeEditMessage(bufferOut, sizeOut=%d)... ", sizeOut);
queueOctreeEditMessage(type, bufferOut, sizeOut); queueOctreeEditMessage(type, bufferOut, sizeOut);
} }
} }

View file

@ -46,12 +46,15 @@ void ParticlesScriptingInterface::editParticle(ParticleID particleID, const Part
} }
// TODO: This deleteParticle() method uses the PACKET_TYPE_PARTICLE_ADD_OR_EDIT message to send
// a changed particle with a shouldDie() property set to true. This works and is currently the only
// way to tell the particle server to delete a particle. But we should change this to use the PACKET_TYPE_PARTICLE_ERASE
// message which takes a list of particle id's to delete.
void ParticlesScriptingInterface::deleteParticle(ParticleID particleID) { void ParticlesScriptingInterface::deleteParticle(ParticleID particleID) {
// setup properties to kill the particle // setup properties to kill the particle
ParticleProperties properties; ParticleProperties properties;
properties.setScript("print('here'); Particle.setShouldDie(true);"); properties.setShouldDie(true);
//properties.setShouldDie(true);
uint32_t actualID = particleID.id; uint32_t actualID = particleID.id;
if (!particleID.isKnownID) { if (!particleID.isKnownID) {
@ -59,7 +62,7 @@ void ParticlesScriptingInterface::deleteParticle(ParticleID particleID) {
// hmmm... we kind of want to bail if someone attempts to edit an unknown // hmmm... we kind of want to bail if someone attempts to edit an unknown
if (actualID == UNKNOWN_PARTICLE_ID) { if (actualID == UNKNOWN_PARTICLE_ID) {
qDebug() << "ParticlesScriptingInterface::deleteParticle(), bailing - unknown particle..."; //qDebug() << "ParticlesScriptingInterface::deleteParticle(), bailing - unknown particle...";
return; // bailing early return; // bailing early
} }
} }
@ -67,6 +70,6 @@ qDebug() << "ParticlesScriptingInterface::deleteParticle(), bailing - unknown pa
particleID.id = actualID; particleID.id = actualID;
particleID.isKnownID = true; particleID.isKnownID = true;
qDebug() << "ParticlesScriptingInterface::deleteParticle(), queueParticleMessage......"; //qDebug() << "ParticlesScriptingInterface::deleteParticle(), queueParticleMessage......";
queueParticleMessage(PACKET_TYPE_PARTICLE_ADD_OR_EDIT, particleID, properties); queueParticleMessage(PACKET_TYPE_PARTICLE_ADD_OR_EDIT, particleID, properties);
} }