mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 22:47:07 +02:00
added easy access to creating a ParticleEditHandle for a know particle ID
This commit is contained in:
parent
cd830efdd4
commit
50b93d1e2b
6 changed files with 32 additions and 8 deletions
|
@ -1523,11 +1523,17 @@ void Application::shootParticle() {
|
||||||
delete particleEditHandle;
|
delete particleEditHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Caller is responsible for managing this EditableParticle
|
||||||
|
ParticleEditHandle* Application::newParticleEditHandle(uint32_t id) {
|
||||||
|
ParticleEditHandle* particleEditHandle = new ParticleEditHandle(&_particleEditSender, _particles.getTree());
|
||||||
|
return particleEditHandle;
|
||||||
|
}
|
||||||
|
|
||||||
// Caller is responsible for managing this EditableParticle
|
// Caller is responsible for managing this EditableParticle
|
||||||
ParticleEditHandle* Application::makeParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity,
|
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, QString updateScript) {
|
||||||
|
|
||||||
ParticleEditHandle* particleEditHandle = new ParticleEditHandle(&_particleEditSender, _particles.getTree());
|
ParticleEditHandle* particleEditHandle = newParticleEditHandle();
|
||||||
particleEditHandle->createParticle(position, radius, color, velocity, gravity, damping, updateScript);
|
particleEditHandle->createParticle(position, radius, color, velocity, gravity, damping, updateScript);
|
||||||
return particleEditHandle;
|
return particleEditHandle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@ public:
|
||||||
void wheelEvent(QWheelEvent* event);
|
void wheelEvent(QWheelEvent* event);
|
||||||
|
|
||||||
void shootParticle(); // shoots a particle in the direction you're looking
|
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,
|
ParticleEditHandle* makeParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity,
|
||||||
glm::vec3 gravity, float damping, QString updateScript);
|
glm::vec3 gravity, float damping, QString updateScript);
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,12 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
|
||||||
|
|
||||||
if (closestParticle) {
|
if (closestParticle) {
|
||||||
printf("potentially caught... particle ID:%d\n", closestParticle->getID());
|
printf("potentially caught... particle ID:%d\n", closestParticle->getID());
|
||||||
|
|
||||||
|
// you can create a ParticleEditHandle by doing this...
|
||||||
|
ParticleEditHandle* caughtParticle = Application::getInstance()->newParticleEditHandle(closestParticle->getID());
|
||||||
|
|
||||||
|
// but make sure you clean it up, when you're done
|
||||||
|
delete caughtParticle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the controller button being held down....
|
// Is the controller button being held down....
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include <OctreePacketData.h>
|
#include <OctreePacketData.h>
|
||||||
|
|
||||||
const uint32_t NEW_PARTICLE = 0xFFFFFFFF;
|
const uint32_t NEW_PARTICLE = 0xFFFFFFFF;
|
||||||
|
const uint32_t UNKNOWN_TOKEN = 0xFFFFFFFF;
|
||||||
|
|
||||||
class ParticleDetail {
|
class ParticleDetail {
|
||||||
public:
|
public:
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
|
@ -16,15 +16,22 @@ std::map<uint32_t,ParticleEditHandle*> ParticleEditHandle::_allHandles;
|
||||||
uint32_t ParticleEditHandle::_nextCreatorTokenID = 0;
|
uint32_t ParticleEditHandle::_nextCreatorTokenID = 0;
|
||||||
|
|
||||||
|
|
||||||
ParticleEditHandle::ParticleEditHandle(ParticleEditPacketSender* packetSender, ParticleTree* localTree) {
|
ParticleEditHandle::ParticleEditHandle(ParticleEditPacketSender* packetSender, ParticleTree* localTree, uint32_t id) {
|
||||||
_creatorTokenID = _nextCreatorTokenID;
|
if (id == NEW_PARTICLE) {
|
||||||
_nextCreatorTokenID++;
|
_creatorTokenID = _nextCreatorTokenID;
|
||||||
_id = NEW_PARTICLE;
|
_nextCreatorTokenID++;
|
||||||
_isKnownID = false;
|
_id = NEW_PARTICLE;
|
||||||
|
_isKnownID = false;
|
||||||
|
_allHandles[_creatorTokenID] = this;
|
||||||
|
} else {
|
||||||
|
_creatorTokenID = UNKNOWN_TOKEN;
|
||||||
|
_id = id;
|
||||||
|
_isKnownID = true;
|
||||||
|
// don't add to _allHandles because we already know it...
|
||||||
|
}
|
||||||
_packetSender = packetSender;
|
_packetSender = packetSender;
|
||||||
_localTree = localTree;
|
_localTree = localTree;
|
||||||
|
|
||||||
_allHandles[_creatorTokenID] = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleEditHandle::~ParticleEditHandle() {
|
ParticleEditHandle::~ParticleEditHandle() {
|
||||||
|
|
|
@ -19,12 +19,14 @@
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <OctreePacketData.h>
|
#include <OctreePacketData.h>
|
||||||
|
|
||||||
|
#include "Particle.h"
|
||||||
|
|
||||||
class ParticleEditPacketSender;
|
class ParticleEditPacketSender;
|
||||||
class ParticleTree;
|
class ParticleTree;
|
||||||
|
|
||||||
class ParticleEditHandle {
|
class ParticleEditHandle {
|
||||||
public:
|
public:
|
||||||
ParticleEditHandle(ParticleEditPacketSender* packetSender, ParticleTree* localTree);
|
ParticleEditHandle(ParticleEditPacketSender* packetSender, ParticleTree* localTree, uint32_t id = NEW_PARTICLE);
|
||||||
~ParticleEditHandle();
|
~ParticleEditHandle();
|
||||||
|
|
||||||
uint32_t getCreatorTokenID() const { return _creatorTokenID; }
|
uint32_t getCreatorTokenID() const { return _creatorTokenID; }
|
||||||
|
|
Loading…
Reference in a new issue