diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d26e3450fa..1d845674e0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1523,7 +1523,7 @@ void Application::shootParticle() { QString updateScript(""); ParticleEditHandle* particleEditHandle = makeParticle(position / (float)TREE_SCALE, radius, color, - velocity / (float)TREE_SCALE, gravity, damping, updateScript); + velocity / (float)TREE_SCALE, gravity, damping, NOT_IN_HAND, updateScript); // If we wanted to be able to edit this particle after shooting, then we could store this value // and use it for editing later. But we don't care about that for "shooting" and therefore we just @@ -1540,10 +1540,10 @@ ParticleEditHandle* Application::newParticleEditHandle(uint32_t id) { // Caller is responsible for managing this EditableParticle ParticleEditHandle* Application::makeParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity, - glm::vec3 gravity, float damping, QString updateScript) { + glm::vec3 gravity, float damping, bool inHand, QString updateScript) { ParticleEditHandle* particleEditHandle = newParticleEditHandle(); - particleEditHandle->createParticle(position, radius, color, velocity, gravity, damping, updateScript); + particleEditHandle->createParticle(position, radius, color, velocity, gravity, damping, inHand, updateScript); return particleEditHandle; } diff --git a/interface/src/Application.h b/interface/src/Application.h index d54f9e74d8..f9ffc33781 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -125,7 +125,7 @@ public: void shootParticle(); // shoots a particle in the direction you're looking ParticleEditHandle* newParticleEditHandle(uint32_t id = NEW_PARTICLE); ParticleEditHandle* makeParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity, - glm::vec3 gravity, float damping, QString updateScript); + glm::vec3 gravity, float damping, bool inHand, QString updateScript); void makeVoxel(glm::vec3 position, float scale, diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 6b8dbdce49..f991074b94 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -23,11 +23,9 @@ const float FINGERTIP_VOXEL_SIZE = 0.05; const int TOY_BALL_HAND = 1; const float TOY_BALL_RADIUS = 0.05f; const float TOY_BALL_DAMPING = 0.99f; -const glm::vec3 NO_GRAVITY = glm::vec3(0,0,0); const glm::vec3 NO_VELOCITY = glm::vec3(0,0,0); const glm::vec3 TOY_BALL_GRAVITY = glm::vec3(0,-1,0); const QString TOY_BALL_UPDATE_SCRIPT(""); -const QString TOY_BALL_DONT_DIE_SCRIPT("Particle.setShouldDie(false);"); const float PALM_COLLISION_RADIUS = 0.03f; const xColor TOY_BALL_ON_SERVER_COLOR[] = { @@ -161,9 +159,10 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f TOY_BALL_RADIUS / (float) TREE_SCALE, TOY_BALL_ON_SERVER_COLOR[_whichBallColor[handID]], NO_VELOCITY / (float)TREE_SCALE, - NO_GRAVITY / (float) TREE_SCALE, - TOY_BALL_DAMPING, - TOY_BALL_DONT_DIE_SCRIPT); + TOY_BALL_GRAVITY / (float) TREE_SCALE, + TOY_BALL_DAMPING, + IN_HAND, + TOY_BALL_UPDATE_SCRIPT); } } else { // Ball is in hand @@ -172,9 +171,10 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f TOY_BALL_RADIUS / (float) TREE_SCALE, TOY_BALL_ON_SERVER_COLOR[_whichBallColor[handID]], NO_VELOCITY / (float)TREE_SCALE, - NO_GRAVITY / (float) TREE_SCALE, - TOY_BALL_DAMPING, - TOY_BALL_DONT_DIE_SCRIPT); + TOY_BALL_GRAVITY / (float) TREE_SCALE, + TOY_BALL_DAMPING, + IN_HAND, + TOY_BALL_UPDATE_SCRIPT); } } else { // If toy ball just released, add velocity to it! @@ -193,7 +193,8 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f TOY_BALL_ON_SERVER_COLOR[_whichBallColor[handID]], toyBallVelocity / (float)TREE_SCALE, TOY_BALL_GRAVITY / (float) TREE_SCALE, - TOY_BALL_DAMPING, + TOY_BALL_DAMPING, + NOT_IN_HAND, TOY_BALL_UPDATE_SCRIPT); // after releasing the ball, we free our ParticleEditHandle so we can't edit it further diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 6e7193f397..5bd99ee308 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -1299,6 +1299,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* node, } bool Octree::readFromSVOFile(const char* fileName) { + bool fileOk = false; std::ifstream file(fileName, std::ios::in|std::ios::binary|std::ios::ate); if(file.is_open()) { emit importSize(1.0f, 1.0f, 1.0f); @@ -1314,16 +1315,44 @@ bool Octree::readFromSVOFile(const char* fileName) { unsigned char* entireFile = new unsigned char[fileLength]; file.read((char*)entireFile, fileLength); bool wantImportProgress = true; - ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS, NULL, 0, wantImportProgress); - readBitstreamToTree(entireFile, fileLength, args); + + unsigned char* dataAt = entireFile; + unsigned long dataLength = fileLength; + + // before reading the file, check to see if this version of the Octree supports file versions + if (getWantSVOfileVersions()) { + // if so, read the first byte of the file and see if it matches the expected version code + PACKET_TYPE expectedType = expectedDataPacketType(); + PACKET_TYPE gotType = *dataAt; + if (gotType == expectedType) { + dataAt += sizeof(expectedType); + dataLength -= sizeof(expectedType); + PACKET_VERSION expectedVersion = versionForPacketType(expectedType); + PACKET_VERSION gotVersion = *dataAt; + if (gotVersion == expectedVersion) { + dataAt += sizeof(expectedVersion); + dataLength -= sizeof(expectedVersion); + fileOk = true; + } else { + qDebug("SVO file version mismatch. Expected: %d Got: %d\n", expectedVersion, gotVersion); + } + } else { + qDebug("SVO file type mismatch. Expected: %c Got: %c\n", expectedType, gotType); + } + } else { + fileOk = true; // assume the file is ok + } + if (fileOk) { + ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS, NULL, 0, wantImportProgress); + readBitstreamToTree(dataAt, dataLength, args); + } delete[] entireFile; emit importProgress(100); file.close(); - return true; } - return false; + return fileOk; } void Octree::writeToSVOFile(const char* fileName, OctreeElement* node) { @@ -1332,7 +1361,16 @@ void Octree::writeToSVOFile(const char* fileName, OctreeElement* node) { if(file.is_open()) { qDebug("saving to file %s...\n", fileName); - + + // before reading the file, check to see if this version of the Octree supports file versions + if (getWantSVOfileVersions()) { + // if so, read the first byte of the file and see if it matches the expected version code + PACKET_TYPE expectedType = expectedDataPacketType(); + PACKET_VERSION expectedVersion = versionForPacketType(expectedType); + file.write(&expectedType, sizeof(expectedType)); + file.write(&expectedVersion, sizeof(expectedType)); + } + OctreeElementBag nodeBag; // If we were given a specific node, start from there, otherwise start from root if (node) { diff --git a/libraries/octree/src/Octree.h b/libraries/octree/src/Octree.h index 0954ef1813..de74476a30 100644 --- a/libraries/octree/src/Octree.h +++ b/libraries/octree/src/Octree.h @@ -183,6 +183,8 @@ public: // These methods will allow the OctreeServer to send your tree inbound edit packets of your // own definition. Implement these to allow your octree based server to support editing + virtual bool getWantSVOfileVersions() const { return false; } + virtual PACKET_TYPE expectedDataPacketType() const { return PACKET_TYPE_UNKNOWN; } virtual bool handlesEditPacketType(PACKET_TYPE packetType) const { return false; } virtual int processEditPacketData(PACKET_TYPE packetType, unsigned char* packetData, int packetLength, unsigned char* editData, int maxLength, Node* senderNode) { return 0; } diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index 36c4d056d1..9e7d88416b 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -305,6 +305,15 @@ bool OctreePacketData::appendValue(const glm::vec3& value) { return success; } +bool OctreePacketData::appendValue(bool value) { + bool success = append((uint8_t)value); // used unsigned char version + if (success) { + _bytesOfValues++; + _totalBytesOfValues++; + } + return success; +} + bool OctreePacketData::appendPosition(const glm::vec3& value) { const unsigned char* data = (const unsigned char*)&value; int length = sizeof(value); diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index 2843790f68..87b55ace96 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -130,6 +130,9 @@ public: /// appends a non-position vector to the end of the stream, may fail if new data stream is too long to fit in packet bool appendValue(const glm::vec3& value); + /// appends a bool value to the end of the stream, may fail if new data stream is too long to fit in packet + bool appendValue(bool value); + /// appends a position to the end of the stream, may fail if new data stream is too long to fit in packet bool appendPosition(const glm::vec3& value); diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index d23815da3a..e598904ded 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -18,22 +18,23 @@ uint32_t Particle::_nextID = 0; -Particle::Particle(glm::vec3 position, float radius, rgbColor color, glm::vec3 velocity, - float damping, glm::vec3 gravity, QString updateScript, uint32_t id) { +Particle::Particle(glm::vec3 position, float radius, rgbColor color, glm::vec3 velocity, glm::vec3 gravity, + float damping, bool inHand, QString updateScript, uint32_t id) { - init(position, radius, color, velocity, damping, gravity, updateScript, id); + init(position, radius, color, velocity, gravity, damping, inHand, updateScript, id); } Particle::Particle() { rgbColor noColor = { 0, 0, 0 }; - init(glm::vec3(0,0,0), 0, noColor, glm::vec3(0,0,0), DEFAULT_DAMPING, DEFAULT_GRAVITY, DEFAULT_SCRIPT, NEW_PARTICLE); + init(glm::vec3(0,0,0), 0, noColor, glm::vec3(0,0,0), + DEFAULT_GRAVITY, DEFAULT_DAMPING, NOT_IN_HAND, DEFAULT_SCRIPT, NEW_PARTICLE); } Particle::~Particle() { } -void Particle::init(glm::vec3 position, float radius, rgbColor color, glm::vec3 velocity, - float damping, glm::vec3 gravity, QString updateScript, uint32_t id) { +void Particle::init(glm::vec3 position, float radius, rgbColor color, glm::vec3 velocity, glm::vec3 gravity, + float damping, bool inHand, QString updateScript, uint32_t id) { if (id == NEW_PARTICLE) { _created = usecTimestampNow(); _id = _nextID; @@ -50,6 +51,7 @@ void Particle::init(glm::vec3 position, float radius, rgbColor color, glm::vec3 _damping = damping; _gravity = gravity; _updateScript = updateScript; + _inHand = inHand; } @@ -83,6 +85,9 @@ bool Particle::appendParticleData(OctreePacketData* packetData) const { if (success) { success = packetData->appendValue(getDamping()); } + if (success) { + success = packetData->appendValue(getInHand()); + } if (success) { uint16_t scriptLength = _updateScript.size() + 1; // include NULL success = packetData->appendValue(scriptLength); @@ -96,7 +101,7 @@ bool Particle::appendParticleData(OctreePacketData* packetData) const { int Particle::expectedBytes() { int expectedBytes = sizeof(uint32_t) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(float) + sizeof(glm::vec3) + sizeof(rgbColor) + sizeof(glm::vec3) + - sizeof(glm::vec3) + sizeof(float); + sizeof(glm::vec3) + sizeof(float) + sizeof(bool); return expectedBytes; } @@ -150,6 +155,11 @@ int Particle::readParticleDataFromBuffer(const unsigned char* data, int bytesLef dataAt += sizeof(_damping); bytesRead += sizeof(_damping); + // inHand + memcpy(&_inHand, dataAt, sizeof(_inHand)); + dataAt += sizeof(_inHand); + bytesRead += sizeof(_inHand); + // script uint16_t scriptLength; memcpy(&scriptLength, dataAt, sizeof(scriptLength)); @@ -240,6 +250,11 @@ Particle Particle::fromEditPacket(unsigned char* data, int length, int& processe dataAt += sizeof(newParticle._damping); processedBytes += sizeof(newParticle._damping); + // inHand + memcpy(&newParticle._inHand, dataAt, sizeof(newParticle._inHand)); + dataAt += sizeof(newParticle._inHand); + processedBytes += sizeof(newParticle._inHand); + // script uint16_t scriptLength; memcpy(&scriptLength, dataAt, sizeof(scriptLength)); @@ -352,6 +367,11 @@ bool Particle::encodeParticleEditMessageDetails(PACKET_TYPE command, int count, copyAt += sizeof(details[i].damping); sizeOut += sizeof(details[i].damping); + // inHand + memcpy(copyAt, &details[i].inHand, sizeof(details[i].inHand)); + copyAt += sizeof(details[i].inHand); + sizeOut += sizeof(details[i].inHand); + // script uint16_t scriptLength = details[i].updateScript.size() + 1; memcpy(copyAt, &scriptLength, sizeof(scriptLength)); @@ -389,27 +409,31 @@ void Particle::update() { bool isStillMoving = (velocityScalar > STILL_MOVING); const uint64_t REALLY_OLD = 30 * 1000 * 1000; bool isReallyOld = (getLifetime() > REALLY_OLD); - bool shouldDie = !isStillMoving && isReallyOld; + bool isInHand = getInHand(); + bool shouldDie = !isInHand && !isStillMoving && isReallyOld; setShouldDie(shouldDie); runScript(); // allow the javascript to alter our state - - _position += _velocity * timeElapsed; - // handle bounces off the ground... - if (_position.y <= 0) { - _velocity = _velocity * glm::vec3(1,-1,1); - _position.y = 0; + // If the ball is in hand, it doesn't move or have gravity effect it + if (!isInHand) { + _position += _velocity * timeElapsed; + + // handle bounces off the ground... + if (_position.y <= 0) { + _velocity = _velocity * glm::vec3(1,-1,1); + _position.y = 0; + } + + // handle gravity.... + _velocity += _gravity * timeElapsed; + + // handle damping + glm::vec3 dampingResistance = _velocity * _damping; + _velocity -= dampingResistance * timeElapsed; + //printf("applying damping to Particle timeElapsed=%f\n",timeElapsed); } - - // handle gravity.... - _velocity += _gravity * timeElapsed; - - // handle damping - glm::vec3 dampingResistance = _velocity * _damping; - _velocity -= dampingResistance * timeElapsed; - //printf("applying damping to Particle timeElapsed=%f\n",timeElapsed); - + _lastUpdated = now; } diff --git a/libraries/particles/src/Particle.h b/libraries/particles/src/Particle.h index 1d80adabc6..d4791c566c 100644 --- a/libraries/particles/src/Particle.h +++ b/libraries/particles/src/Particle.h @@ -32,6 +32,7 @@ public: glm::vec3 velocity; glm::vec3 gravity; float damping; + bool inHand; QString updateScript; uint32_t creatorTokenID; }; @@ -39,21 +40,24 @@ public: const float DEFAULT_DAMPING = 0.99f; 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 +const bool NOT_IN_HAND = !IN_HAND; // it's not in a hand class Particle { public: Particle(); Particle(glm::vec3 position, float radius, rgbColor color, glm::vec3 velocity, - float damping = DEFAULT_DAMPING, glm::vec3 gravity = DEFAULT_GRAVITY, QString updateScript = DEFAULT_SCRIPT, - uint32_t id = NEW_PARTICLE); + glm::vec3 gravity = DEFAULT_GRAVITY, float damping = DEFAULT_DAMPING, bool inHand = NOT_IN_HAND, + QString updateScript = DEFAULT_SCRIPT, uint32_t id = NEW_PARTICLE); /// creates an NEW particle from an PACKET_TYPE_PARTICLE_ADD_OR_EDIT edit data buffer static Particle fromEditPacket(unsigned char* data, int length, int& processedBytes); virtual ~Particle(); virtual void init(glm::vec3 position, float radius, rgbColor color, glm::vec3 velocity, - float damping, glm::vec3 gravity, QString updateScript, uint32_t id); + glm::vec3 gravity = DEFAULT_GRAVITY, float damping = DEFAULT_DAMPING, bool inHand = NOT_IN_HAND, + QString updateScript = DEFAULT_SCRIPT, uint32_t id = NEW_PARTICLE); const glm::vec3& getPosition() const { return _position; } const rgbColor& getColor() const { return _color; } @@ -61,6 +65,7 @@ public: float getRadius() const { return _radius; } const glm::vec3& getVelocity() const { return _velocity; } const glm::vec3& getGravity() const { return _gravity; } + bool getInHand() const { return _inHand; } float getDamping() const { return _damping; } uint64_t getCreated() const { return _created; } uint64_t getLifetime() const { return usecTimestampNow() - _created; } @@ -81,6 +86,7 @@ public: } void setRadius(float value) { _radius = value; } void setGravity(const glm::vec3& value) { _gravity = value; } + void setInHand(bool inHand) { _inHand = inHand; } void setDamping(float value) { _damping = value; } void setShouldDie(bool shouldDie) { _shouldDie = shouldDie; } void setUpdateScript(QString updateScript) { _updateScript = updateScript; } @@ -116,6 +122,7 @@ protected: glm::vec3 _gravity; float _damping; QString _updateScript; + bool _inHand; uint32_t _creatorTokenID; bool _newlyCreated; diff --git a/libraries/particles/src/ParticleCollisionSystem.cpp b/libraries/particles/src/ParticleCollisionSystem.cpp index 3d077cc209..1a21d1231e 100644 --- a/libraries/particles/src/ParticleCollisionSystem.cpp +++ b/libraries/particles/src/ParticleCollisionSystem.cpp @@ -98,6 +98,11 @@ void ParticleCollisionSystem::updateCollisionWithParticles(Particle* particle) { void ParticleCollisionSystem::updateCollisionWithAvatars(Particle* particle) { + // particles that are in hand, don't collide with other avatar parts + if (particle->getInHand()) { + return; + } + //printf("updateCollisionWithAvatars()...\n"); glm::vec3 center = particle->getPosition() * (float)TREE_SCALE; float radius = particle->getRadius() * (float)TREE_SCALE; @@ -194,7 +199,7 @@ void ParticleCollisionSystem::applyHardCollision(Particle* particle, const glm:: } ParticleEditHandle particleEditHandle(_packetSender, _particles, particle->getID()); particleEditHandle.updateParticle(position, particle->getRadius(), particle->getXColor(), velocity, - particle->getGravity(), particle->getDamping(), particle->getUpdateScript()); + particle->getGravity(), particle->getDamping(), particle->getInHand(), particle->getUpdateScript()); } diff --git a/libraries/particles/src/ParticleEditHandle.cpp b/libraries/particles/src/ParticleEditHandle.cpp index 24700fbcba..e9606dd3cd 100644 --- a/libraries/particles/src/ParticleEditHandle.cpp +++ b/libraries/particles/src/ParticleEditHandle.cpp @@ -41,12 +41,12 @@ ParticleEditHandle::~ParticleEditHandle() { } void ParticleEditHandle::createParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity, - glm::vec3 gravity, float damping, QString updateScript) { + glm::vec3 gravity, float damping, bool inHand, QString updateScript) { // setup a ParticleDetail struct with the data ParticleDetail addParticleDetail = { NEW_PARTICLE, usecTimestampNow(), position, radius, {color.red, color.green, color.blue }, - velocity, gravity, damping, updateScript, _creatorTokenID }; + velocity, gravity, damping, inHand, updateScript, _creatorTokenID }; // queue the packet _packetSender->queueParticleEditMessages(PACKET_TYPE_PARTICLE_ADD_OR_EDIT, 1, &addParticleDetail); @@ -62,7 +62,7 @@ void ParticleEditHandle::createParticle(glm::vec3 position, float radius, xColor } bool ParticleEditHandle::updateParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity, - glm::vec3 gravity, float damping, QString updateScript) { + glm::vec3 gravity, float damping, bool inHand, QString updateScript) { if (!isKnownID()) { return false; // not allowed until we know the id @@ -71,7 +71,7 @@ bool ParticleEditHandle::updateParticle(glm::vec3 position, float radius, xColor // setup a ParticleDetail struct with the data ParticleDetail newParticleDetail = { _id, usecTimestampNow(), position, radius, {color.red, color.green, color.blue }, - velocity, gravity, damping, updateScript, _creatorTokenID }; + velocity, gravity, damping, inHand, updateScript, _creatorTokenID }; // queue the packet _packetSender->queueParticleEditMessages(PACKET_TYPE_PARTICLE_ADD_OR_EDIT, 1, &newParticleDetail); @@ -82,7 +82,7 @@ bool ParticleEditHandle::updateParticle(glm::vec3 position, float radius, xColor // if we have a local tree, also update it... if (_localTree) { rgbColor rcolor = {color.red, color.green, color.blue }; - Particle tempParticle(position, radius, rcolor, velocity, damping, gravity, updateScript, _id); + Particle tempParticle(position, radius, rcolor, velocity, gravity, damping, inHand, updateScript, _id); _localTree->storeParticle(tempParticle); } diff --git a/libraries/particles/src/ParticleEditHandle.h b/libraries/particles/src/ParticleEditHandle.h index bed8b29d14..186dc47944 100644 --- a/libraries/particles/src/ParticleEditHandle.h +++ b/libraries/particles/src/ParticleEditHandle.h @@ -35,10 +35,10 @@ public: bool isKnownID() const { return _isKnownID; } void createParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity, - glm::vec3 gravity, float damping, QString updateScript); + glm::vec3 gravity, float damping, bool inHand, QString updateScript); bool updateParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity, - glm::vec3 gravity, float damping, QString updateScript); + glm::vec3 gravity, float damping, bool inHand, QString updateScript); static void handleAddResponse(unsigned char* packetData , int packetLength); private: diff --git a/libraries/particles/src/ParticleScriptingInterface.cpp b/libraries/particles/src/ParticleScriptingInterface.cpp index cb534cc522..d4ae76e645 100644 --- a/libraries/particles/src/ParticleScriptingInterface.cpp +++ b/libraries/particles/src/ParticleScriptingInterface.cpp @@ -15,7 +15,7 @@ void ParticleScriptingInterface::queueParticleAdd(PACKET_TYPE addPacketType, Par } unsigned int ParticleScriptingInterface::queueParticleAdd(glm::vec3 position, float radius, - xColor color, glm::vec3 velocity, glm::vec3 gravity, float damping, QString updateScript) { + xColor color, glm::vec3 velocity, glm::vec3 gravity, float damping, bool inHand, QString updateScript) { // The application will keep track of creatorTokenID uint32_t creatorTokenID = _nextCreatorTokenID; @@ -24,7 +24,7 @@ unsigned int ParticleScriptingInterface::queueParticleAdd(glm::vec3 position, fl // setup a ParticleDetail struct with the data ParticleDetail addParticleDetail = { NEW_PARTICLE, usecTimestampNow(), position, radius, {color.red, color.green, color.blue }, velocity, - gravity, damping, updateScript, creatorTokenID }; + gravity, damping, inHand, updateScript, creatorTokenID }; // queue the packet queueParticleAdd(PACKET_TYPE_PARTICLE_ADD_OR_EDIT, addParticleDetail); diff --git a/libraries/particles/src/ParticleScriptingInterface.h b/libraries/particles/src/ParticleScriptingInterface.h index 85dd0c6caf..68b8318ebe 100644 --- a/libraries/particles/src/ParticleScriptingInterface.h +++ b/libraries/particles/src/ParticleScriptingInterface.h @@ -27,7 +27,7 @@ public slots: /// queues the creation of a Particle which will be sent by calling process on the PacketSender /// returns the creatorTokenID for the newly created particle unsigned int queueParticleAdd(glm::vec3 position, float radius, - xColor color, glm::vec3 velocity, glm::vec3 gravity, float damping, QString updateScript); + xColor color, glm::vec3 velocity, glm::vec3 gravity, float damping, bool inHand, QString updateScript); private: void queueParticleAdd(PACKET_TYPE addPacketType, ParticleDetail& addParticleDetails); diff --git a/libraries/particles/src/ParticleTree.h b/libraries/particles/src/ParticleTree.h index 9d7d4a98f8..0594b2f4b2 100644 --- a/libraries/particles/src/ParticleTree.h +++ b/libraries/particles/src/ParticleTree.h @@ -36,6 +36,8 @@ public: // These methods will allow the OctreeServer to send your tree inbound edit packets of your // own definition. Implement these to allow your octree based server to support editing + virtual bool getWantSVOfileVersions() const { return true; } + virtual PACKET_TYPE expectedDataPacketType() const { return PACKET_TYPE_PARTICLE_DATA; } virtual bool handlesEditPacketType(PACKET_TYPE packetType) const; virtual int processEditPacketData(PACKET_TYPE packetType, unsigned char* packetData, int packetLength, unsigned char* editData, int maxLength, Node* senderNode); diff --git a/libraries/shared/src/PacketHeaders.cpp b/libraries/shared/src/PacketHeaders.cpp index 9b5961b12f..6c6c402f39 100644 --- a/libraries/shared/src/PacketHeaders.cpp +++ b/libraries/shared/src/PacketHeaders.cpp @@ -51,7 +51,10 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) { return 1; case PACKET_TYPE_PARTICLE_ADD_OR_EDIT: - return 1; + return 2; + + case PACKET_TYPE_PARTICLE_DATA: + return 2; default: return 0; diff --git a/libraries/voxels/src/VoxelTree.h b/libraries/voxels/src/VoxelTree.h index ea841ebf90..0b93cd0dc7 100644 --- a/libraries/voxels/src/VoxelTree.h +++ b/libraries/voxels/src/VoxelTree.h @@ -53,6 +53,7 @@ public: void readCodeColorBufferToTree(const unsigned char* codeColorBuffer, bool destructive = false); + virtual PACKET_TYPE expectedDataPacketType() const { return PACKET_TYPE_VOXEL_DATA; } virtual bool handlesEditPacketType(PACKET_TYPE packetType) const; virtual int processEditPacketData(PACKET_TYPE packetType, unsigned char* packetData, int packetLength, unsigned char* editData, int maxLength, Node* senderNode);