PageRenderTime 25ms CodeModel.GetById 17ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/llmath/llvolumeoctree.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 134 lines | 82 code | 26 blank | 26 comment | 0 complexity | 00f45f786ff493edea6ed2b5c7f0b46a MD5 | raw file
  1/** 
  2 * @file llvolumeoctree.h
  3 * @brief LLVolume octree classes.
  4 *
  5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLVOLUME_OCTREE_H
 28#define LL_LLVOLUME_OCTREE_H
 29
 30#include "linden_common.h"
 31#include "llmemory.h"
 32
 33#include "lloctree.h"
 34#include "llvolume.h"
 35#include "llvector4a.h"
 36
 37class LLVolumeTriangle : public LLRefCount
 38{
 39public:
 40	LLVolumeTriangle()
 41	{
 42		
 43	}
 44
 45	LLVolumeTriangle(const LLVolumeTriangle& rhs)
 46	{
 47		*this = rhs;
 48	}
 49
 50	const LLVolumeTriangle& operator=(const LLVolumeTriangle& rhs)
 51	{
 52		llerrs << "Illegal operation!" << llendl;
 53		return *this;
 54	}
 55
 56	~LLVolumeTriangle()
 57	{
 58	
 59	}
 60
 61	LLVector4a mPositionGroup;
 62
 63	const LLVector4a* mV[3];
 64	U16 mIndex[3];
 65
 66	F32 mRadius;
 67
 68	virtual const LLVector4a& getPositionGroup() const;
 69	virtual const F32& getBinRadius() const;
 70};
 71
 72class LLVolumeOctreeListener : public LLOctreeListener<LLVolumeTriangle>
 73{
 74public:
 75	
 76	LLVolumeOctreeListener(LLOctreeNode<LLVolumeTriangle>* node);
 77	~LLVolumeOctreeListener();
 78	
 79	LLVolumeOctreeListener(const LLVolumeOctreeListener& rhs)
 80	{
 81		*this = rhs;
 82	}
 83
 84	const LLVolumeOctreeListener& operator=(const LLVolumeOctreeListener& rhs)
 85	{
 86		llerrs << "Illegal operation!" << llendl;
 87		return *this;
 88	}
 89
 90	 //LISTENER FUNCTIONS
 91	virtual void handleChildAddition(const LLOctreeNode<LLVolumeTriangle>* parent, 
 92		LLOctreeNode<LLVolumeTriangle>* child);
 93	virtual void handleStateChange(const LLTreeNode<LLVolumeTriangle>* node) { }
 94	virtual void handleChildRemoval(const LLOctreeNode<LLVolumeTriangle>* parent, 
 95			const LLOctreeNode<LLVolumeTriangle>* child) {	}
 96	virtual void handleInsertion(const LLTreeNode<LLVolumeTriangle>* node, LLVolumeTriangle* tri) { }
 97	virtual void handleRemoval(const LLTreeNode<LLVolumeTriangle>* node, LLVolumeTriangle* tri) { }
 98	virtual void handleDestruction(const LLTreeNode<LLVolumeTriangle>* node) { }
 99	
100
101public:
102	LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
103	LLVector4a mExtents[2]; // extents (min, max) of this node and all its children
104};
105
106class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle>
107{
108public:
109	const LLVolumeFace* mFace;
110	LLVector4a mStart;
111	LLVector4a mDir;
112	LLVector4a mEnd;
113	LLVector3* mIntersection;
114	LLVector2* mTexCoord;
115	LLVector3* mNormal;
116	LLVector3* mBinormal;
117	F32* mClosestT;
118	bool mHitFace;
119
120	LLOctreeTriangleRayIntersect(const LLVector4a& start, const LLVector4a& dir, 
121								   const LLVolumeFace* face, F32* closest_t,
122								   LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal);
123
124	void traverse(const LLOctreeNode<LLVolumeTriangle>* node);
125
126	virtual void visit(const LLOctreeNode<LLVolumeTriangle>* node);
127};
128
129class LLVolumeOctreeValidate : public LLOctreeTraveler<LLVolumeTriangle>
130{
131	virtual void visit(const LLOctreeNode<LLVolumeTriangle>* branch);
132};
133
134#endif