Beispiel #1
0
	VoxelTree6DElement<T>* createChild(float p[6])
	{
		int indx = getChildIndx(p);
		if (indx<0)
		{
			VR_ERROR << "Node do not cover this pos" << endl;
			return NULL;
		}
		if (children[indx])
		{
			// silently ignore an existing child
			return children[indx];
		}
		float newPos[6];
		float newExtends[6];
		for (int i=0;i<6;i++)
		{
			// check left / right
			if (p[i] > pos[i] + extends[i]*0.5f )
				newPos[i] = pos[i] + extends[i]*0.5f;
			else
				newPos[i] = pos[i];
			newExtends[i] = 0.5f * extends[i];
		}
		children[indx] = new VoxelTree6DElement(newPos,newExtends,level+1,maxLevels);
		return children[indx];
	};
        /*!
            Checks if there is an entry at the given position.
            True when this node is a leaf and the entry is set or the child at p exists and returns true on getChild(p)->hasEntry(p).
        */
        bool hasEntry(float p[6])
        {
            if (leaf)
            {
                if (!covers(p))
                {
                    return false;
                }

                if (entry)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }

            int indx = getChildIndx(p);

            if (indx < 0 || !children[indx])
            {
                return false;
            }

            return children[indx]->hasEntry(p);
        };
Beispiel #3
0
	/*!
		Returns pointer to element when existing. NULL if not.
	*/
	T* getEntry(float p[6])
	{
		if (leaf)
		{
			return entry;
		}

		int indx = getChildIndx(p);
		if (indx<0 || !children[indx])
		{
			return NULL;
		}
		return children[indx]->getEntry(p);
	}