clear particles when switching domains

This commit is contained in:
ZappoMan 2014-01-24 11:07:27 -08:00
parent dbde1a29fe
commit f02bc95908
13 changed files with 25 additions and 11 deletions

View file

@ -3752,6 +3752,9 @@ void Application::domainChanged(const QString& domainHostname) {
_voxelServerJurisdictions.clear();
_octreeServerSceneStats.clear();
_particleServerJurisdictions.clear();
// reset the particle renderer
_particles.clear();
// reset our persist thread
qDebug() << "Domain changed to" << domainHostname << ". Swapping persist cache.";

View file

@ -182,7 +182,7 @@ public:
~Octree();
/// Your tree class must implement this to create the correct element type
virtual OctreeElement* createNewElement(unsigned char * octalCode = NULL) const = 0;
virtual OctreeElement* createNewElement(unsigned char * octalCode = NULL) = 0;
// 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

View file

@ -47,7 +47,7 @@ protected:
// can only be constructed by derived implementation
OctreeElement();
virtual OctreeElement* createNewElement(unsigned char * octalCode = NULL) const = 0;
virtual OctreeElement* createNewElement(unsigned char * octalCode = NULL) = 0;
public:
virtual void init(unsigned char * octalCode); /// Your subclass must call init on construction.

View file

@ -132,3 +132,12 @@ void OctreeRenderer::render() {
_tree->unlock();
}
}
void OctreeRenderer::clear() {
if (_tree) {
_tree->lockForWrite();
_tree->eraseAllOctreeElements();
_tree->unlock();
}
}

View file

@ -58,6 +58,8 @@ public:
static bool renderOperation(OctreeElement* element, void* extraData);
/// clears the tree
void clear();
protected:
Octree* _tree;
QUuid _dataSourceUUID;

View file

@ -10,12 +10,12 @@
ParticleTree::ParticleTree(bool shouldReaverage) : Octree(shouldReaverage) {
ParticleTreeElement* rootNode = createNewElement();
rootNode->setTree(this);
_rootNode = rootNode;
}
ParticleTreeElement* ParticleTree::createNewElement(unsigned char * octalCode) const {
ParticleTreeElement* ParticleTree::createNewElement(unsigned char * octalCode) {
ParticleTreeElement* newElement = new ParticleTreeElement(octalCode);
newElement->setTree(this);
return newElement;
}

View file

@ -23,7 +23,7 @@ public:
ParticleTree(bool shouldReaverage = false);
/// Implements our type specific root element factory
virtual ParticleTreeElement* createNewElement(unsigned char * octalCode = NULL) const;
virtual ParticleTreeElement* createNewElement(unsigned char * octalCode = NULL);
/// Type safe version of getRoot()
ParticleTreeElement* getRoot() { return (ParticleTreeElement*)_rootNode; }

View file

@ -25,7 +25,7 @@ ParticleTreeElement::~ParticleTreeElement() {
// 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 {
OctreeElement* ParticleTreeElement::createNewElement(unsigned char* octalCode) {
ParticleTreeElement* newChild = new ParticleTreeElement(octalCode);
newChild->setTree(_myTree);
return newChild;

View file

@ -31,7 +31,7 @@ class ParticleTreeElement : public OctreeElement {
ParticleTreeElement(unsigned char* octalCode = NULL);
virtual OctreeElement* createNewElement(unsigned char* octalCode = NULL) const;
virtual OctreeElement* createNewElement(unsigned char* octalCode = NULL);
public:
virtual ~ParticleTreeElement();

View file

@ -24,7 +24,7 @@ VoxelTree::VoxelTree(bool shouldReaverage) : Octree(shouldReaverage) {
_rootNode = createNewElement();
}
VoxelTreeElement* VoxelTree::createNewElement(unsigned char * octalCode) const {
VoxelTreeElement* VoxelTree::createNewElement(unsigned char * octalCode) {
VoxelSystem* voxelSystem = NULL;
if (_rootNode) {
voxelSystem = ((VoxelTreeElement*)_rootNode)->getVoxelSystem();

View file

@ -30,7 +30,7 @@ public:
VoxelTree(bool shouldReaverage = false);
virtual VoxelTreeElement* createNewElement(unsigned char * octalCode = NULL) const;
virtual VoxelTreeElement* createNewElement(unsigned char * octalCode = NULL);
VoxelTreeElement* getRoot() { return (VoxelTreeElement*)_rootNode; }
void deleteVoxelAt(float x, float y, float z, float s);

View file

@ -25,7 +25,7 @@ VoxelTreeElement::~VoxelTreeElement() {
// 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* VoxelTreeElement::createNewElement(unsigned char* octalCode) const {
OctreeElement* VoxelTreeElement::createNewElement(unsigned char* octalCode) {
VoxelTreeElement* newChild = new VoxelTreeElement(octalCode);
newChild->setVoxelSystem(getVoxelSystem()); // our child is always part of our voxel system NULL ok
return newChild;

View file

@ -31,7 +31,7 @@ class VoxelTreeElement : public OctreeElement {
VoxelTreeElement(unsigned char* octalCode = NULL);
virtual OctreeElement* createNewElement(unsigned char* octalCode = NULL) const;
virtual OctreeElement* createNewElement(unsigned char* octalCode = NULL);
public:
virtual ~VoxelTreeElement();