mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
particle edit checkpoint
This commit is contained in:
parent
3bcd02f8e3
commit
cd0e8e742c
7 changed files with 229 additions and 129 deletions
|
@ -34,7 +34,7 @@ void OctreeInboundPacketProcessor::resetStats() {
|
|||
_totalLockWaitTime = 0;
|
||||
_totalElementsInPacket = 0;
|
||||
_totalPackets = 0;
|
||||
|
||||
|
||||
_singleSenderStats.clear();
|
||||
}
|
||||
|
||||
|
@ -43,14 +43,14 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
|
|||
unsigned char* packetData, ssize_t packetLength) {
|
||||
|
||||
bool debugProcessPacket = _myServer->wantsVerboseDebug();
|
||||
|
||||
|
||||
if (debugProcessPacket) {
|
||||
printf("OctreeInboundPacketProcessor::processPacket() packetData=%p packetLength=%ld\n", packetData, packetLength);
|
||||
}
|
||||
|
||||
int numBytesPacketHeader = numBytesForPacketHeader(packetData);
|
||||
|
||||
|
||||
|
||||
|
||||
// Ask our tree subclass if it can handle the incoming packet...
|
||||
PACKET_TYPE packetType = packetData[0];
|
||||
if (_myServer->getOctree()->handlesEditPacketType(packetType)) {
|
||||
|
@ -58,7 +58,7 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
|
|||
_receivedPacketCount++;
|
||||
|
||||
SharedNodePointer senderNode = NodeList::getInstance()->nodeWithAddress(senderSockAddr);
|
||||
|
||||
|
||||
unsigned short int sequence = (*((unsigned short int*)(packetData + numBytesPacketHeader)));
|
||||
uint64_t sentAt = (*((uint64_t*)(packetData + numBytesPacketHeader + sizeof(sequence))));
|
||||
uint64_t arrivedAt = usecTimestampNow();
|
||||
|
@ -66,10 +66,10 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
|
|||
int editsInPacket = 0;
|
||||
uint64_t processTime = 0;
|
||||
uint64_t lockWaitTime = 0;
|
||||
|
||||
if (_myServer->wantsDebugReceiving()) {
|
||||
qDebug() << "PROCESSING THREAD: got '" << packetType << "' packet - " << _receivedPacketCount
|
||||
<< " command from client receivedBytes=" << packetLength
|
||||
|
||||
if (true || _myServer->wantsDebugReceiving()) {
|
||||
qDebug() << "PROCESSING THREAD: got '" << packetType << "' packet - " << _receivedPacketCount
|
||||
<< " command from client receivedBytes=" << packetLength
|
||||
<< " sequence=" << sequence << " transitTime=" << transitTime << " usecs";
|
||||
}
|
||||
int atByte = numBytesPacketHeader + sizeof(sequence) + sizeof(sentAt);
|
||||
|
@ -77,7 +77,7 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
|
|||
while (atByte < packetLength) {
|
||||
int maxSize = packetLength - atByte;
|
||||
|
||||
if (debugProcessPacket) {
|
||||
if (true || debugProcessPacket) {
|
||||
printf("OctreeInboundPacketProcessor::processPacket() %c "
|
||||
"packetData=%p packetLength=%ld voxelData=%p atByte=%d maxSize=%d\n",
|
||||
packetType, packetData, packetLength, editData, atByte, maxSize);
|
||||
|
@ -86,7 +86,7 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
|
|||
uint64_t startLock = usecTimestampNow();
|
||||
_myServer->getOctree()->lockForWrite();
|
||||
uint64_t startProcess = usecTimestampNow();
|
||||
int editDataBytesRead = _myServer->getOctree()->processEditPacketData(packetType,
|
||||
int editDataBytesRead = _myServer->getOctree()->processEditPacketData(packetType,
|
||||
packetData,
|
||||
packetLength,
|
||||
editData, maxSize, senderNode.data());
|
||||
|
@ -129,15 +129,15 @@ void OctreeInboundPacketProcessor::processPacket(const HifiSockAddr& senderSockA
|
|||
}
|
||||
}
|
||||
|
||||
void OctreeInboundPacketProcessor::trackInboundPackets(const QUuid& nodeUUID, int sequence, uint64_t transitTime,
|
||||
void OctreeInboundPacketProcessor::trackInboundPackets(const QUuid& nodeUUID, int sequence, uint64_t transitTime,
|
||||
int editsInPacket, uint64_t processTime, uint64_t lockWaitTime) {
|
||||
|
||||
|
||||
_totalTransitTime += transitTime;
|
||||
_totalProcessTime += processTime;
|
||||
_totalLockWaitTime += lockWaitTime;
|
||||
_totalElementsInPacket += editsInPacket;
|
||||
_totalPackets++;
|
||||
|
||||
|
||||
// find the individual senders stats and track them there too...
|
||||
// see if this is the first we've heard of this node...
|
||||
if (_singleSenderStats.find(nodeUUID) == _singleSenderStats.end()) {
|
||||
|
@ -162,7 +162,7 @@ void OctreeInboundPacketProcessor::trackInboundPackets(const QUuid& nodeUUID, in
|
|||
|
||||
|
||||
SingleSenderStats::SingleSenderStats() {
|
||||
_totalTransitTime = 0;
|
||||
_totalTransitTime = 0;
|
||||
_totalProcessTime = 0;
|
||||
_totalLockWaitTime = 0;
|
||||
_totalElementsInPacket = 0;
|
||||
|
|
|
@ -86,8 +86,10 @@ void Particle::init(glm::vec3 position, float radius, rgbColor color, glm::vec3
|
|||
if (id == NEW_PARTICLE) {
|
||||
_id = _nextID;
|
||||
_nextID++;
|
||||
qDebug() << "Particle::init()... assigning new id... _id=" << _id;
|
||||
} else {
|
||||
_id = id;
|
||||
qDebug() << "Particle::init()... assigning id from init... _id=" << _id;
|
||||
}
|
||||
uint64_t now = usecTimestampNow();
|
||||
_lastEdited = now;
|
||||
|
@ -152,6 +154,13 @@ bool Particle::appendParticleData(OctreePacketData* packetData) const {
|
|||
if (success) {
|
||||
success = packetData->appendValue(getInHand());
|
||||
}
|
||||
/**
|
||||
if (success) {
|
||||
qDebug() << "appendParticleData().... getShouldDie()=" << getShouldDie();
|
||||
success = packetData->appendValue(getShouldDie());
|
||||
}
|
||||
**/
|
||||
|
||||
if (success) {
|
||||
uint16_t scriptLength = _script.size() + 1; // include NULL
|
||||
success = packetData->appendValue(scriptLength);
|
||||
|
@ -265,6 +274,15 @@ int Particle::readParticleDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
dataAt += sizeof(_inHand);
|
||||
bytesRead += sizeof(_inHand);
|
||||
|
||||
/**
|
||||
// shouldDie
|
||||
memcpy(&_shouldDie, dataAt, sizeof(_shouldDie));
|
||||
dataAt += sizeof(_shouldDie);
|
||||
bytesRead += sizeof(_shouldDie);
|
||||
|
||||
qDebug() << "readParticleDataFromBuffer().... _shouldDie()=" << _shouldDie;
|
||||
**/
|
||||
|
||||
// script
|
||||
uint16_t scriptLength;
|
||||
memcpy(&scriptLength, dataAt, sizeof(scriptLength));
|
||||
|
@ -282,6 +300,9 @@ int Particle::readParticleDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
|
||||
|
||||
Particle Particle::fromEditPacket(unsigned char* data, int length, int& processedBytes, ParticleTree* tree) {
|
||||
|
||||
qDebug() << "Particle::fromEditPacket() length=" << length;
|
||||
|
||||
Particle newParticle; // id and _lastUpdated will get set here...
|
||||
unsigned char* dataAt = data;
|
||||
processedBytes = 0;
|
||||
|
@ -290,6 +311,9 @@ Particle Particle::fromEditPacket(unsigned char* data, int length, int& processe
|
|||
int octets = numberOfThreeBitSectionsInCode(data);
|
||||
int lengthOfOctcode = bytesRequiredForCodeLength(octets);
|
||||
|
||||
qDebug() << "Particle::fromEditPacket() lengthOfOctcode=" << lengthOfOctcode;
|
||||
printOctalCode(data);
|
||||
|
||||
// we don't actually do anything with this octcode...
|
||||
dataAt += lengthOfOctcode;
|
||||
processedBytes += lengthOfOctcode;
|
||||
|
@ -300,36 +324,38 @@ Particle Particle::fromEditPacket(unsigned char* data, int length, int& processe
|
|||
dataAt += sizeof(editID);
|
||||
processedBytes += sizeof(editID);
|
||||
|
||||
qDebug() << "editID:" << editID;
|
||||
|
||||
bool isNewParticle = (editID == NEW_PARTICLE);
|
||||
|
||||
// special case for handling "new" particles
|
||||
if (editID == NEW_PARTICLE) {
|
||||
if (isNewParticle) {
|
||||
qDebug() << "editID == NEW_PARTICLE";
|
||||
// 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
|
||||
uint32_t creatorTokenID;
|
||||
memcpy(&creatorTokenID, dataAt, sizeof(creatorTokenID));
|
||||
dataAt += sizeof(creatorTokenID);
|
||||
processedBytes += sizeof(creatorTokenID);
|
||||
|
||||
qDebug() << "creatorTokenID:" << creatorTokenID;
|
||||
|
||||
newParticle.setCreatorTokenID(creatorTokenID);
|
||||
newParticle._newlyCreated = true;
|
||||
|
||||
newParticle.setAge(0); // this guy is new!
|
||||
qDebug() << "fromEditPacket() NEW_PARTICLE";
|
||||
|
||||
} else {
|
||||
qDebug() << "fromEditPacket() existingParticle id=" << editID;
|
||||
|
||||
// look up the existing particle
|
||||
|
||||
qDebug() << "fromEditPacket() existingParticle id=" << editID << "calling tree->findParticleByID(editID)";
|
||||
const Particle* existingParticle = tree->findParticleByID(editID, true);
|
||||
qDebug() << "fromEditPacket() existingParticle id=" << editID << "DONE tree->findParticleByID(editID)";
|
||||
|
||||
// copy existing properties before over-writing with new properties
|
||||
if (existingParticle) {
|
||||
newParticle = *existingParticle;
|
||||
qDebug() << "found it...";
|
||||
|
||||
qDebug() << "newParticle = *existingParticle... calling debugDump()...";
|
||||
|
||||
existingParticle->debugDump();
|
||||
} else {
|
||||
qDebug() << "WHOA! Didn't find it...";
|
||||
}
|
||||
|
||||
newParticle._id = editID;
|
||||
|
@ -342,84 +368,97 @@ qDebug() << "fromEditPacket() NEW_PARTICLE";
|
|||
memcpy(&newParticle._lastEdited, dataAt, sizeof(newParticle._lastEdited));
|
||||
dataAt += 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
|
||||
// properties included bits
|
||||
uint16_t packetContainsBits = 0;
|
||||
memcpy(&packetContainsBits, dataAt, sizeof(packetContainsBits));
|
||||
dataAt += sizeof(packetContainsBits);
|
||||
processedBytes += sizeof(packetContainsBits);
|
||||
if (!isNewParticle) {
|
||||
memcpy(&packetContainsBits, dataAt, sizeof(packetContainsBits));
|
||||
dataAt += sizeof(packetContainsBits);
|
||||
processedBytes += sizeof(packetContainsBits);
|
||||
qDebug() << "packetContainsBits:" << packetContainsBits;
|
||||
}
|
||||
|
||||
qDebug() << "fromEditPacket() packetContainsBits=" << packetContainsBits;
|
||||
|
||||
// radius
|
||||
if ((packetContainsBits & PACKET_CONTAINS_RADIUS) == PACKET_CONTAINS_RADIUS) {
|
||||
qDebug() << "fromEditPacket() PACKET_CONTAINS_RADIUS";
|
||||
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_RADIUS) == PACKET_CONTAINS_RADIUS)) {
|
||||
memcpy(&newParticle._radius, dataAt, sizeof(newParticle._radius));
|
||||
dataAt += sizeof(newParticle._radius);
|
||||
processedBytes += sizeof(newParticle._radius);
|
||||
qDebug() << "newParticle._radius:" << newParticle._radius;
|
||||
}
|
||||
|
||||
// position
|
||||
if ((packetContainsBits & PACKET_CONTAINS_POSITION) == PACKET_CONTAINS_POSITION) {
|
||||
qDebug() << "fromEditPacket() PACKET_CONTAINS_POSITION";
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_POSITION) == PACKET_CONTAINS_POSITION)) {
|
||||
memcpy(&newParticle._position, dataAt, sizeof(newParticle._position));
|
||||
dataAt += sizeof(newParticle._position);
|
||||
processedBytes += sizeof(newParticle._position);
|
||||
qDebug() << "newParticle._position:";
|
||||
}
|
||||
|
||||
// color
|
||||
if ((packetContainsBits & PACKET_CONTAINS_COLOR) == PACKET_CONTAINS_COLOR) {
|
||||
qDebug() << "fromEditPacket() PACKET_CONTAINS_COLOR";
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_COLOR) == PACKET_CONTAINS_COLOR)) {
|
||||
memcpy(newParticle._color, dataAt, sizeof(newParticle._color));
|
||||
dataAt += sizeof(newParticle._color);
|
||||
processedBytes += sizeof(newParticle._color);
|
||||
qDebug() << "newParticle._color:";
|
||||
}
|
||||
|
||||
// velocity
|
||||
if ((packetContainsBits & PACKET_CONTAINS_VELOCITY) == PACKET_CONTAINS_VELOCITY) {
|
||||
qDebug() << "fromEditPacket() PACKET_CONTAINS_VELOCITY";
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_VELOCITY) == PACKET_CONTAINS_VELOCITY)) {
|
||||
memcpy(&newParticle._velocity, dataAt, sizeof(newParticle._velocity));
|
||||
dataAt += sizeof(newParticle._velocity);
|
||||
processedBytes += sizeof(newParticle._velocity);
|
||||
qDebug() << "newParticle._velocity:";
|
||||
}
|
||||
|
||||
// gravity
|
||||
if ((packetContainsBits & PACKET_CONTAINS_GRAVITY) == PACKET_CONTAINS_GRAVITY) {
|
||||
qDebug() << "fromEditPacket() PACKET_CONTAINS_GRAVITY";
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_GRAVITY) == PACKET_CONTAINS_GRAVITY)) {
|
||||
memcpy(&newParticle._gravity, dataAt, sizeof(newParticle._gravity));
|
||||
dataAt += sizeof(newParticle._gravity);
|
||||
processedBytes += sizeof(newParticle._gravity);
|
||||
qDebug() << "newParticle._gravity:";
|
||||
}
|
||||
|
||||
// damping
|
||||
if ((packetContainsBits & PACKET_CONTAINS_DAMPING) == PACKET_CONTAINS_DAMPING) {
|
||||
qDebug() << "fromEditPacket() PACKET_CONTAINS_DAMPING";
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_DAMPING) == PACKET_CONTAINS_DAMPING)) {
|
||||
memcpy(&newParticle._damping, dataAt, sizeof(newParticle._damping));
|
||||
dataAt += sizeof(newParticle._damping);
|
||||
processedBytes += sizeof(newParticle._damping);
|
||||
qDebug() << "newParticle._damping:" << newParticle._damping;
|
||||
}
|
||||
|
||||
// lifetime
|
||||
if ((packetContainsBits & PACKET_CONTAINS_LIFETIME) == PACKET_CONTAINS_LIFETIME) {
|
||||
qDebug() << "fromEditPacket() PACKET_CONTAINS_LIFETIME";
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_LIFETIME) == PACKET_CONTAINS_LIFETIME)) {
|
||||
memcpy(&newParticle._lifetime, dataAt, sizeof(newParticle._lifetime));
|
||||
dataAt += sizeof(newParticle._lifetime);
|
||||
processedBytes += sizeof(newParticle._lifetime);
|
||||
qDebug() << "newParticle._lifetime:" << newParticle._lifetime;
|
||||
}
|
||||
|
||||
// TODO: make inHand and shouldDie into single bits
|
||||
// inHand
|
||||
if ((packetContainsBits & PACKET_CONTAINS_INHAND) == PACKET_CONTAINS_INHAND) {
|
||||
qDebug() << "fromEditPacket() PACKET_CONTAINS_INHAND";
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_INHAND) == PACKET_CONTAINS_INHAND)) {
|
||||
memcpy(&newParticle._inHand, dataAt, sizeof(newParticle._inHand));
|
||||
dataAt += sizeof(newParticle._inHand);
|
||||
processedBytes += sizeof(newParticle._inHand);
|
||||
qDebug() << "newParticle._inHand:" << newParticle._inHand;
|
||||
}
|
||||
|
||||
/**
|
||||
// shouldDie
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SHOULDDIE) == PACKET_CONTAINS_SHOULDDIE)) {
|
||||
memcpy(&newParticle._shouldDie, dataAt, sizeof(newParticle._shouldDie));
|
||||
dataAt += sizeof(newParticle._shouldDie);
|
||||
processedBytes += sizeof(newParticle._shouldDie);
|
||||
qDebug() << "fromEditPacket().... newParticle._shouldDie=" << newParticle._shouldDie;
|
||||
}
|
||||
**/
|
||||
|
||||
// script
|
||||
if ((packetContainsBits & PACKET_CONTAINS_SCRIPT) == PACKET_CONTAINS_SCRIPT) {
|
||||
qDebug() << "fromEditPacket() PACKET_CONTAINS_SCRIPT";
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SCRIPT) == PACKET_CONTAINS_SCRIPT)) {
|
||||
uint16_t scriptLength;
|
||||
memcpy(&scriptLength, dataAt, sizeof(scriptLength));
|
||||
dataAt += sizeof(scriptLength);
|
||||
|
@ -428,12 +467,13 @@ qDebug() << "fromEditPacket() PACKET_CONTAINS_SCRIPT";
|
|||
newParticle._script = tempString;
|
||||
dataAt += scriptLength;
|
||||
processedBytes += scriptLength;
|
||||
qDebug() << "newParticle._script:" << newParticle._script;
|
||||
}
|
||||
|
||||
const bool wantDebugging = true;
|
||||
if (wantDebugging) {
|
||||
qDebug("Particle::fromEditPacket()...");
|
||||
qDebug(" Particle id in packet:%u", editID);
|
||||
qDebug() << " Particle id in packet:" << editID;
|
||||
//qDebug() << " position: " << newParticle._position;
|
||||
newParticle.debugDump();
|
||||
}
|
||||
|
@ -445,6 +485,7 @@ void Particle::debugDump() const {
|
|||
printf("Particle id :%u\n", _id);
|
||||
printf(" age:%f\n", getAge());
|
||||
printf(" edited ago:%f\n", getEditedAgo());
|
||||
printf(" should die:%s\n", debug::valueOf(getShouldDie()));
|
||||
printf(" position:%f,%f,%f\n", _position.x, _position.y, _position.z);
|
||||
printf(" radius:%f\n", getRadius());
|
||||
printf(" velocity:%f,%f,%f\n", _velocity.x, _velocity.y, _velocity.z);
|
||||
|
@ -486,18 +527,23 @@ bool Particle::encodeParticleEditMessageDetails(PACKET_TYPE command, ParticleID
|
|||
sizeOut += lengthOfOctcode;
|
||||
|
||||
// Now add our edit content details...
|
||||
bool isNewParticle = (id.id == NEW_PARTICLE);
|
||||
|
||||
// id
|
||||
memcpy(copyAt, &id.id, sizeof(id.id));
|
||||
copyAt += sizeof(id.id);
|
||||
sizeOut += sizeof(id.id);
|
||||
qDebug() << "encoding, id.id:" << id.id;
|
||||
|
||||
// special case for handling "new" particles
|
||||
if (id.id == NEW_PARTICLE) {
|
||||
if (isNewParticle) {
|
||||
qDebug() << "encodeParticleEditMessageDetails()... isNewParticle...";
|
||||
// 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
|
||||
memcpy(copyAt, &id.creatorTokenID, sizeof(id.creatorTokenID));
|
||||
copyAt += sizeof(id.creatorTokenID);
|
||||
sizeOut += sizeof(id.creatorTokenID);
|
||||
qDebug() << "encoding, id.creatorTokenID:" << id.creatorTokenID;
|
||||
}
|
||||
|
||||
// lastEdited
|
||||
|
@ -505,89 +551,101 @@ bool Particle::encodeParticleEditMessageDetails(PACKET_TYPE command, ParticleID
|
|||
memcpy(copyAt, &lastEdited, sizeof(lastEdited));
|
||||
copyAt += sizeof(lastEdited);
|
||||
sizeOut += sizeof(lastEdited);
|
||||
qDebug() << "encoding, lastEdited:" << lastEdited;
|
||||
|
||||
// All of the remaining items are optional, and may or may not be included based on their included values in the
|
||||
// properties included bits
|
||||
|
||||
// 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
|
||||
uint16_t packetContainsBits = properties.getChangedBits();
|
||||
memcpy(copyAt, &packetContainsBits, sizeof(packetContainsBits));
|
||||
copyAt += sizeof(packetContainsBits);
|
||||
sizeOut += sizeof(packetContainsBits);
|
||||
|
||||
qDebug() << " packetContainsBits = " << packetContainsBits;
|
||||
if (!isNewParticle) {
|
||||
memcpy(copyAt, &packetContainsBits, sizeof(packetContainsBits));
|
||||
copyAt += sizeof(packetContainsBits);
|
||||
sizeOut += sizeof(packetContainsBits);
|
||||
qDebug() << "encoding, packetContainsBits:" << packetContainsBits;
|
||||
}
|
||||
|
||||
// radius
|
||||
if ((packetContainsBits & PACKET_CONTAINS_RADIUS) == PACKET_CONTAINS_RADIUS) {
|
||||
printf("encodeParticleEditMessageDetails() including PACKET_CONTAINS_RADIUS\n");
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_RADIUS) == PACKET_CONTAINS_RADIUS)) {
|
||||
float radius = properties.getRadius();
|
||||
memcpy(copyAt, &radius, sizeof(radius));
|
||||
copyAt += sizeof(radius);
|
||||
sizeOut += sizeof(radius);
|
||||
qDebug() << "encoding, radius:" << radius;
|
||||
}
|
||||
|
||||
// position
|
||||
if ((packetContainsBits & PACKET_CONTAINS_POSITION) == PACKET_CONTAINS_POSITION) {
|
||||
printf("encodeParticleEditMessageDetails() including PACKET_CONTAINS_POSITION\n");
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_POSITION) == PACKET_CONTAINS_POSITION)) {
|
||||
memcpy(copyAt, &properties.getPosition(), sizeof(properties.getPosition()));
|
||||
copyAt += sizeof(properties.getPosition());
|
||||
sizeOut += sizeof(properties.getPosition());
|
||||
qDebug() << "encoding, properties.getPosition():";
|
||||
}
|
||||
|
||||
// color
|
||||
if ((packetContainsBits & PACKET_CONTAINS_COLOR) == PACKET_CONTAINS_COLOR) {
|
||||
printf("encodeParticleEditMessageDetails() including PACKET_CONTAINS_COLOR\n");
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_COLOR) == PACKET_CONTAINS_COLOR)) {
|
||||
rgbColor color = { properties.getColor().red, properties.getColor().green, properties.getColor().blue };
|
||||
memcpy(copyAt, color, sizeof(color));
|
||||
copyAt += sizeof(color);
|
||||
sizeOut += sizeof(color);
|
||||
qDebug() << "encoding, color:";
|
||||
}
|
||||
|
||||
// velocity
|
||||
if ((packetContainsBits & PACKET_CONTAINS_VELOCITY) == PACKET_CONTAINS_VELOCITY) {
|
||||
printf("encodeParticleEditMessageDetails() including PACKET_CONTAINS_VELOCITY\n");
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_VELOCITY) == PACKET_CONTAINS_VELOCITY)) {
|
||||
memcpy(copyAt, &properties.getVelocity(), sizeof(properties.getVelocity()));
|
||||
copyAt += sizeof(properties.getVelocity());
|
||||
sizeOut += sizeof(properties.getVelocity());
|
||||
qDebug() << "encoding, getVelocity:";
|
||||
}
|
||||
|
||||
// gravity
|
||||
if ((packetContainsBits & PACKET_CONTAINS_GRAVITY) == PACKET_CONTAINS_GRAVITY) {
|
||||
printf("encodeParticleEditMessageDetails() including PACKET_CONTAINS_GRAVITY\n");
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_GRAVITY) == PACKET_CONTAINS_GRAVITY)) {
|
||||
memcpy(copyAt, &properties.getGravity(), sizeof(properties.getGravity()));
|
||||
copyAt += sizeof(properties.getGravity());
|
||||
sizeOut += sizeof(properties.getGravity());
|
||||
qDebug() << "encoding, getGravity():";
|
||||
}
|
||||
|
||||
// damping
|
||||
if ((packetContainsBits & PACKET_CONTAINS_DAMPING) == PACKET_CONTAINS_DAMPING) {
|
||||
printf("encodeParticleEditMessageDetails() including PACKET_CONTAINS_DAMPING\n");
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_DAMPING) == PACKET_CONTAINS_DAMPING)) {
|
||||
float damping = properties.getDamping();
|
||||
memcpy(copyAt, &damping, sizeof(damping));
|
||||
copyAt += sizeof(damping);
|
||||
sizeOut += sizeof(damping);
|
||||
qDebug() << "encoding, damping:" << damping;
|
||||
}
|
||||
|
||||
// lifetime
|
||||
if ((packetContainsBits & PACKET_CONTAINS_LIFETIME) == PACKET_CONTAINS_LIFETIME) {
|
||||
printf("encodeParticleEditMessageDetails() including PACKET_CONTAINS_LIFETIME\n");
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_LIFETIME) == PACKET_CONTAINS_LIFETIME)) {
|
||||
float lifetime = properties.getLifetime();
|
||||
memcpy(copyAt, &lifetime, sizeof(lifetime));
|
||||
copyAt += sizeof(lifetime);
|
||||
sizeOut += sizeof(lifetime);
|
||||
qDebug() << "encoding, lifetime:" << lifetime;
|
||||
}
|
||||
|
||||
// inHand
|
||||
if ((packetContainsBits & PACKET_CONTAINS_INHAND) == PACKET_CONTAINS_INHAND) {
|
||||
printf("encodeParticleEditMessageDetails() including PACKET_CONTAINS_INHAND\n");
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_INHAND) == PACKET_CONTAINS_INHAND)) {
|
||||
bool inHand = properties.getInHand();
|
||||
memcpy(copyAt, &inHand, sizeof(inHand));
|
||||
copyAt += sizeof(inHand);
|
||||
sizeOut += sizeof(inHand);
|
||||
qDebug() << "encoding, inHand:" << inHand;
|
||||
}
|
||||
|
||||
// script
|
||||
if ((packetContainsBits & PACKET_CONTAINS_SCRIPT) == PACKET_CONTAINS_SCRIPT) {
|
||||
printf("encodeParticleEditMessageDetails() including SCRIPT\n");
|
||||
/**
|
||||
// shoulDie
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SHOULDDIE) == PACKET_CONTAINS_SHOULDDIE)) {
|
||||
bool shouldDie = properties.getShouldDie();
|
||||
memcpy(copyAt, &shouldDie, sizeof(shouldDie));
|
||||
copyAt += sizeof(shouldDie);
|
||||
sizeOut += sizeof(shouldDie);
|
||||
qDebug() << "encoding, shouldDie:" << shouldDie;
|
||||
}
|
||||
**/
|
||||
|
||||
// script
|
||||
if (isNewParticle || ((packetContainsBits & PACKET_CONTAINS_SCRIPT) == PACKET_CONTAINS_SCRIPT)) {
|
||||
uint16_t scriptLength = properties.getScript().size() + 1;
|
||||
memcpy(copyAt, &scriptLength, sizeof(scriptLength));
|
||||
copyAt += sizeof(scriptLength);
|
||||
|
@ -595,6 +653,7 @@ qDebug() << " packetContainsBits = " << packetContainsBits;
|
|||
memcpy(copyAt, qPrintable(properties.getScript()), scriptLength);
|
||||
copyAt += scriptLength;
|
||||
sizeOut += scriptLength;
|
||||
qDebug() << "encoding, getScript:" << properties.getScript();
|
||||
}
|
||||
|
||||
bool wantDebugging = false;
|
||||
|
@ -608,6 +667,8 @@ qDebug() << " packetContainsBits = " << packetContainsBits;
|
|||
// cleanup
|
||||
delete[] octcode;
|
||||
|
||||
qDebug() << "encoding... sizeOut:" << sizeOut;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -660,8 +721,12 @@ void Particle::update() {
|
|||
|
||||
// Lifetime - even if you're moving, or in hand, if you're age is greater than your requested lifetime, you are going to die
|
||||
bool shouldDie = getShouldDie() || (getAge() > getLifetime()) || (!isInHand && !isStillMoving && isReallyOld);
|
||||
//qDebug() << "update()... getShouldDie()=" << getShouldDie();
|
||||
|
||||
setShouldDie(shouldDie);
|
||||
|
||||
//qDebug() << "update()... getShouldDie()=" << getShouldDie();
|
||||
|
||||
runUpdateScript(); // allow the javascript to alter our state
|
||||
|
||||
// If the ball is in hand, it doesn't move or have gravity effect it
|
||||
|
@ -808,7 +873,7 @@ void Particle::setProperties(const ParticleProperties& properties) {
|
|||
ParticleProperties::ParticleProperties() :
|
||||
_position(0),
|
||||
_color(),
|
||||
_radius(0),
|
||||
_radius(DEFAULT_RADIUS),
|
||||
_velocity(0),
|
||||
_gravity(DEFAULT_GRAVITY),
|
||||
_damping(DEFAULT_DAMPING),
|
||||
|
@ -870,12 +935,12 @@ uint16_t ParticleProperties::getChangedBits() const {
|
|||
changedBits += PACKET_CONTAINS_SCRIPT;
|
||||
}
|
||||
|
||||
/**
|
||||
// how do we want to handle this?
|
||||
|
||||
//if (_shouldDieChanged) {
|
||||
// changedBits += PACKET_CONTAINS_SHOULDDIE;
|
||||
//}
|
||||
|
||||
if (_shouldDieChanged) {
|
||||
changedBits += PACKET_CONTAINS_SHOULDDIE;
|
||||
}
|
||||
**/
|
||||
return changedBits;
|
||||
}
|
||||
|
||||
|
@ -945,18 +1010,13 @@ void ParticleProperties::copyFromScriptValue(const QScriptValue &object) {
|
|||
}
|
||||
|
||||
QScriptValue radius = object.property("radius");
|
||||
qDebug() << "copyFromScriptValue() line:" << __LINE__;
|
||||
if (radius.isValid()) {
|
||||
qDebug() << "copyFromScriptValue() line:" << __LINE__;
|
||||
float newRadius;
|
||||
newRadius = radius.toVariant().toFloat();
|
||||
qDebug() << "copyFromScriptValue() line:" << __LINE__ << " newRadius=" << newRadius;
|
||||
qDebug() << "copyFromScriptValue() line:" << __LINE__ << " _radius=" << _radius;
|
||||
if (newRadius != _radius) {
|
||||
_radius = newRadius;
|
||||
_radiusChanged = true;
|
||||
}
|
||||
qDebug() << "copyFromScriptValue() line:" << __LINE__ << " _radiusChanged=" << _radiusChanged;
|
||||
}
|
||||
|
||||
QScriptValue velocity = object.property("velocity");
|
||||
|
|
|
@ -40,10 +40,12 @@ const uint16_t PACKET_CONTAINS_DAMPING = 32;
|
|||
const uint16_t PACKET_CONTAINS_LIFETIME = 64;
|
||||
const uint16_t PACKET_CONTAINS_INHAND = 128;
|
||||
const uint16_t PACKET_CONTAINS_SCRIPT = 256;
|
||||
const uint16_t PACKET_CONTAINS_SHOULDDIE = 512;
|
||||
|
||||
const float DEFAULT_LIFETIME = 60.0f * 60.0f * 24.0f; // particles live for 1 day by default
|
||||
const float DEFAULT_LIFETIME = 10.f; //60.0f * 60.0f * 24.0f; // particles live for 1 day by default
|
||||
const float DEFAULT_DAMPING = 0.99f;
|
||||
const float DEFAULT_RADIUS = 0.1f / TREE_SCALE; // really shouldn't be a default?
|
||||
const float DEFAULT_RADIUS = 0.1f / TREE_SCALE;
|
||||
const float MINIMUM_PARTICLE_ELEMENT_SIZE = (1.0f / 100000.0f) / TREE_SCALE; // smallest size container
|
||||
const glm::vec3 DEFAULT_GRAVITY(0, (-9.8f / TREE_SCALE), 0);
|
||||
const QString DEFAULT_SCRIPT("");
|
||||
const bool IN_HAND = true; // it's in a hand
|
||||
|
@ -76,6 +78,17 @@ public:
|
|||
uint64_t getLastEdited() const { return _lastEdited; }
|
||||
uint16_t getChangedBits() const;
|
||||
|
||||
void setPosition(const glm::vec3& value) { _position = value; _positionChanged = true; }
|
||||
void setVelocity(const glm::vec3& value) { _velocity = value; _velocityChanged = true; }
|
||||
void setColor(const xColor& value) { _color = value; _colorChanged = true; }
|
||||
void setRadius(float value) { _radius = value; _radiusChanged = true; }
|
||||
void setGravity(const glm::vec3& value) { _gravity = value; _gravityChanged = true; }
|
||||
void setInHand(bool inHand) { _inHand = inHand; _inHandChanged = true; }
|
||||
void setDamping(float value) { _damping = value; _dampingChanged = true; }
|
||||
void setShouldDie(bool shouldDie) { _shouldDie = shouldDie; _shouldDieChanged = true; }
|
||||
void setLifetime(float value) { _lifetime = value; _lifetimeChanged = true; }
|
||||
void setScript(QString updateScript) { _script = updateScript; _scriptChanged = true; }
|
||||
|
||||
private:
|
||||
glm::vec3 _position;
|
||||
xColor _color;
|
||||
|
|
|
@ -55,7 +55,7 @@ void ParticleTree::storeParticle(const Particle& particle, Node* senderNode) {
|
|||
// if we didn't find it in the tree, then store it...
|
||||
if (!args.found) {
|
||||
glm::vec3 position = particle.getPosition();
|
||||
float size = particle.getRadius();
|
||||
float size = std::max(MINIMUM_PARTICLE_ELEMENT_SIZE, particle.getRadius());
|
||||
ParticleTreeElement* element = (ParticleTreeElement*)getOrCreateChildElementAt(position.x, position.y, position.z, size);
|
||||
|
||||
element->storeParticle(particle, senderNode);
|
||||
|
@ -127,7 +127,7 @@ public:
|
|||
|
||||
|
||||
bool ParticleTree::findByIDOperation(OctreeElement* element, void* extraData) {
|
||||
qDebug() << "ParticleTree::findByIDOperation()....";
|
||||
//qDebug() << "ParticleTree::findByIDOperation()....";
|
||||
|
||||
FindByIDArgs* args = static_cast<FindByIDArgs*>(extraData);
|
||||
ParticleTreeElement* particleTreeElement = static_cast<ParticleTreeElement*>(element);
|
||||
|
@ -153,9 +153,9 @@ qDebug() << "ParticleTree::findByIDOperation()....";
|
|||
const Particle* ParticleTree::findParticleByID(uint32_t id, bool alreadyLocked) {
|
||||
FindByIDArgs args = { id, false, NULL };
|
||||
if (!alreadyLocked) {
|
||||
qDebug() << "ParticleTree::findParticleByID().... about to call lockForRead()....";
|
||||
//qDebug() << "ParticleTree::findParticleByID().... about to call lockForRead()....";
|
||||
lockForRead();
|
||||
qDebug() << "ParticleTree::findParticleByID().... after call lockForRead()....";
|
||||
//qDebug() << "ParticleTree::findParticleByID().... after call lockForRead()....";
|
||||
}
|
||||
recurseTreeWithOperation(findByIDOperation, &args);
|
||||
if (!alreadyLocked) {
|
||||
|
@ -178,7 +178,7 @@ qDebug() << " got PACKET_TYPE_PARTICLE_ADD_OR_EDIT... ";
|
|||
Particle newParticle = Particle::fromEditPacket(editData, maxLength, processedBytes, this);
|
||||
qDebug() << "PACKET_TYPE_PARTICLE_ADD_OR_EDIT... calling storeParticle() ";
|
||||
storeParticle(newParticle, senderNode);
|
||||
qDebug() << "PACKET_TYPE_PARTICLE_ADD_OR_EDIT... AFTER storeParticle() ";
|
||||
qDebug() << "PACKET_TYPE_PARTICLE_ADD_OR_EDIT... AFTER storeParticle() newParticle.getShouldDie()=" << newParticle.getShouldDie();
|
||||
if (newParticle.isNewlyCreated()) {
|
||||
qDebug() << "PACKET_TYPE_PARTICLE_ADD_OR_EDIT... calling notifyNewlyCreatedParticle() ";
|
||||
notifyNewlyCreatedParticle(newParticle, senderNode);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "ParticleTree.h"
|
||||
#include "ParticleTreeElement.h"
|
||||
|
||||
ParticleTreeElement::ParticleTreeElement(unsigned char* octalCode) : OctreeElement() {
|
||||
ParticleTreeElement::ParticleTreeElement(unsigned char* octalCode) : OctreeElement() {
|
||||
init(octalCode);
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,7 @@ ParticleTreeElement::~ParticleTreeElement() {
|
|||
}
|
||||
|
||||
// This will be called primarily on addChildAt(), which means we're adding a child of our
|
||||
// own type to our own tree. This means we should initialize that child with any tree and type
|
||||
// own type to our own tree. This means we should initialize that child with any tree and type
|
||||
// specific settings that our children must have. One example is out VoxelSystem, which
|
||||
// we know must match ours.
|
||||
OctreeElement* ParticleTreeElement::createNewElement(unsigned char* octalCode) const {
|
||||
|
@ -34,8 +34,8 @@ void ParticleTreeElement::init(unsigned char* octalCode) {
|
|||
_voxelMemoryUsage += sizeof(ParticleTreeElement);
|
||||
}
|
||||
|
||||
ParticleTreeElement* ParticleTreeElement::addChildAtIndex(int index) {
|
||||
ParticleTreeElement* newElement = (ParticleTreeElement*)OctreeElement::addChildAtIndex(index);
|
||||
ParticleTreeElement* ParticleTreeElement::addChildAtIndex(int index) {
|
||||
ParticleTreeElement* newElement = (ParticleTreeElement*)OctreeElement::addChildAtIndex(index);
|
||||
newElement->setTree(_myTree);
|
||||
return newElement;
|
||||
}
|
||||
|
@ -66,17 +66,29 @@ void ParticleTreeElement::update(ParticleTreeUpdateArgs& args) {
|
|||
// update our contained particles
|
||||
uint16_t numberOfParticles = _particles.size();
|
||||
|
||||
if (numberOfParticles > 0) {
|
||||
// qDebug() << "ParticleTreeElement::update()... numberOfParticles="<< numberOfParticles;
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < numberOfParticles; i++) {
|
||||
_particles[i].update();
|
||||
|
||||
// If the particle wants to die, or if it's left our bounding box, then move it
|
||||
// into the arguments moving particles. These will be added back or deleted completely
|
||||
|
||||
// qDebug() << "ParticleTreeElement::update()... _particles[i="<< i << "].getShouldDie()="
|
||||
// << _particles[i].getShouldDie() << " getID()=" << _particles[i].getID();
|
||||
|
||||
if (_particles[i].getShouldDie() || !_box.contains(_particles[i].getPosition())) {
|
||||
args._movingParticles.push_back(_particles[i]);
|
||||
|
||||
|
||||
// if it moved out of bounds, add it to the movingParticles
|
||||
//if (!_particles[i].getShouldDie()) {
|
||||
args._movingParticles.push_back(_particles[i]);
|
||||
//}
|
||||
|
||||
// erase this particle
|
||||
_particles.erase(_particles.begin()+i);
|
||||
|
||||
|
||||
// reduce our index since we just removed this item
|
||||
i--;
|
||||
numberOfParticles--;
|
||||
|
@ -84,14 +96,14 @@ void ParticleTreeElement::update(ParticleTreeUpdateArgs& args) {
|
|||
}
|
||||
}
|
||||
|
||||
bool ParticleTreeElement::findSpherePenetration(const glm::vec3& center, float radius,
|
||||
bool ParticleTreeElement::findSpherePenetration(const glm::vec3& center, float radius,
|
||||
glm::vec3& penetration, void** penetratedObject) const {
|
||||
|
||||
|
||||
uint16_t numberOfParticles = _particles.size();
|
||||
for (uint16_t i = 0; i < numberOfParticles; i++) {
|
||||
glm::vec3 particleCenter = _particles[i].getPosition();
|
||||
float particleRadius = _particles[i].getRadius();
|
||||
|
||||
|
||||
// don't penetrate yourself
|
||||
if (particleCenter == center && particleRadius == radius) {
|
||||
return false;
|
||||
|
@ -106,7 +118,7 @@ bool ParticleTreeElement::findSpherePenetration(const glm::vec3& center, float r
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (findSphereSpherePenetration(center, radius, particleCenter, particleRadius, penetration)) {
|
||||
*penetratedObject = (void*)&_particles[i];
|
||||
return true;
|
||||
|
@ -122,7 +134,7 @@ bool ParticleTreeElement::containsParticle(const Particle& particle) const {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ParticleTreeElement::updateParticle(const Particle& particle) {
|
||||
|
@ -133,27 +145,27 @@ bool ParticleTreeElement::updateParticle(const Particle& particle) {
|
|||
int difference = _particles[i].getLastUpdated() - particle.getLastUpdated();
|
||||
bool changedOnServer = _particles[i].getLastEdited() < particle.getLastEdited();
|
||||
bool localOlder = _particles[i].getLastUpdated() < particle.getLastUpdated();
|
||||
if (changedOnServer || localOlder) {
|
||||
if (changedOnServer || localOlder) {
|
||||
if (wantDebug) {
|
||||
printf("local particle [id:%d] %s and %s than server particle by %d, particle.isNewlyCreated()=%s\n",
|
||||
printf("local particle [id:%d] %s and %s than server particle by %d, particle.isNewlyCreated()=%s\n",
|
||||
particle.getID(), (changedOnServer ? "CHANGED" : "same"),
|
||||
(localOlder ? "OLDER" : "NEWER"),
|
||||
(localOlder ? "OLDER" : "NEWER"),
|
||||
difference, debug::valueOf(particle.isNewlyCreated()) );
|
||||
}
|
||||
_particles[i].copyChangedProperties(particle);
|
||||
} else {
|
||||
if (wantDebug) {
|
||||
printf(">>> IGNORING SERVER!!! Would've caused jutter! <<< "
|
||||
"local particle [id:%d] %s and %s than server particle by %d, particle.isNewlyCreated()=%s\n",
|
||||
"local particle [id:%d] %s and %s than server particle by %d, particle.isNewlyCreated()=%s\n",
|
||||
particle.getID(), (changedOnServer ? "CHANGED" : "same"),
|
||||
(localOlder ? "OLDER" : "NEWER"),
|
||||
(localOlder ? "OLDER" : "NEWER"),
|
||||
difference, debug::valueOf(particle.isNewlyCreated()) );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
const Particle* ParticleTreeElement::getClosestParticle(glm::vec3 position) const {
|
||||
|
@ -166,7 +178,7 @@ const Particle* ParticleTreeElement::getClosestParticle(glm::vec3 position) cons
|
|||
closestParticle = &_particles[i];
|
||||
}
|
||||
}
|
||||
return closestParticle;
|
||||
return closestParticle;
|
||||
}
|
||||
|
||||
const Particle* ParticleTreeElement::getParticleWithID(uint32_t id) const {
|
||||
|
@ -178,26 +190,26 @@ const Particle* ParticleTreeElement::getParticleWithID(uint32_t id) const {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return foundParticle;
|
||||
return foundParticle;
|
||||
}
|
||||
|
||||
|
||||
int ParticleTreeElement::readElementDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args) {
|
||||
|
||||
int ParticleTreeElement::readElementDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args) {
|
||||
|
||||
const unsigned char* dataAt = data;
|
||||
int bytesRead = 0;
|
||||
uint16_t numberOfParticles = 0;
|
||||
int expectedBytesPerParticle = Particle::expectedBytes();
|
||||
|
||||
if (bytesLeftToRead >= sizeof(numberOfParticles)) {
|
||||
|
||||
|
||||
// read our particles in....
|
||||
numberOfParticles = *(uint16_t*)dataAt;
|
||||
dataAt += sizeof(numberOfParticles);
|
||||
bytesLeftToRead -= sizeof(numberOfParticles);
|
||||
bytesRead += sizeof(numberOfParticles);
|
||||
|
||||
|
||||
if (bytesLeftToRead >= (numberOfParticles * expectedBytesPerParticle)) {
|
||||
for (uint16_t i = 0; i < numberOfParticles; i++) {
|
||||
Particle tempParticle;
|
||||
|
@ -209,7 +221,7 @@ int ParticleTreeElement::readElementDataFromBuffer(const unsigned char* data, in
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
|
@ -220,7 +232,7 @@ void ParticleTreeElement::calculateAverageFromChildren() {
|
|||
|
||||
// will detect if children are leaves AND collapsable into the parent node
|
||||
// and in that case will collapse children and make this node
|
||||
// a leaf, returns TRUE if all the leaves are collapsed into a
|
||||
// a leaf, returns TRUE if all the leaves are collapsed into a
|
||||
// single node
|
||||
bool ParticleTreeElement::collapseChildren() {
|
||||
// nothing to do here yet...
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
|
||||
void ParticlesScriptingInterface::queueParticleMessage(PACKET_TYPE packetType,
|
||||
ParticleID particleID, const ParticleProperties& properties) {
|
||||
|
||||
qDebug() << "ParticlesScriptingInterface::queueParticleMessage()...";
|
||||
|
||||
getParticlePacketSender()->queueParticleEditMessage(packetType, particleID, properties);
|
||||
}
|
||||
|
||||
|
@ -32,9 +29,6 @@ ParticleID ParticlesScriptingInterface::addParticle(const ParticleProperties& pr
|
|||
}
|
||||
|
||||
void ParticlesScriptingInterface::editParticle(ParticleID particleID, const ParticleProperties& properties) {
|
||||
|
||||
qDebug() << "ParticlesScriptingInterface::editParticle() id.id=" << particleID.id << " id.creatorTokenID=" << particleID.creatorTokenID;
|
||||
|
||||
uint32_t actualID = particleID.id;
|
||||
if (!particleID.isKnownID) {
|
||||
actualID = Particle::getIDfromCreatorTokenID(particleID.creatorTokenID);
|
||||
|
@ -43,7 +37,6 @@ qDebug() << "ParticlesScriptingInterface::editParticle() id.id=" << particleID.i
|
|||
if (actualID == UNKNOWN_PARTICLE_ID) {
|
||||
return; // bailing early
|
||||
}
|
||||
qDebug() << "ParticlesScriptingInterface::editParticle() actualID=" << actualID;
|
||||
}
|
||||
|
||||
particleID.id = actualID;
|
||||
|
@ -54,4 +47,26 @@ qDebug() << "ParticlesScriptingInterface::editParticle() actualID=" << actualID;
|
|||
|
||||
|
||||
void ParticlesScriptingInterface::deleteParticle(ParticleID particleID) {
|
||||
|
||||
// setup properties to kill the particle
|
||||
ParticleProperties properties;
|
||||
properties.setScript("print('here'); Particle.setShouldDie(true);");
|
||||
//properties.setShouldDie(true);
|
||||
|
||||
uint32_t actualID = particleID.id;
|
||||
if (!particleID.isKnownID) {
|
||||
actualID = Particle::getIDfromCreatorTokenID(particleID.creatorTokenID);
|
||||
|
||||
// hmmm... we kind of want to bail if someone attempts to edit an unknown
|
||||
if (actualID == UNKNOWN_PARTICLE_ID) {
|
||||
qDebug() << "ParticlesScriptingInterface::deleteParticle(), bailing - unknown particle...";
|
||||
return; // bailing early
|
||||
}
|
||||
}
|
||||
|
||||
particleID.id = actualID;
|
||||
particleID.isKnownID = true;
|
||||
|
||||
qDebug() << "ParticlesScriptingInterface::deleteParticle(), queueParticleMessage......";
|
||||
queueParticleMessage(PACKET_TYPE_PARTICLE_ADD_OR_EDIT, particleID, properties);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
|
|||
return 3;
|
||||
|
||||
case PACKET_TYPE_PARTICLE_DATA:
|
||||
return 6;
|
||||
return 7;
|
||||
|
||||
case PACKET_TYPE_PING_REPLY:
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue