📄 mgcboundingvolumetree.h
字号:
// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement. The various license agreements may be found at
// the Magic Software web site. This file is subject to the license
//
// FREE SOURCE CODE
// http://www.magic-software.com/License/free.pdf
#ifndef MGCBOUNDINGVOLUMETREE_H
#define MGCBOUNDINGVOLUMETREE_H
#include "MgcVector3.h"
class MgcBoundingVolume
{
public:
virtual ~MgcBoundingVolume () { /**/ }
};
class MgcBoundingVolumeTree
{
public:
typedef void (*CreateBound)(unsigned short usVertexCount,
const MgcVector3* akVertex, const unsigned short* ausConnect,
unsigned short usI0, unsigned short usI1, unsigned short* ausISplit,
MgcBoundingVolume*& rpkBound, MgcVector3& rkOrigin,
MgcVector3& rkDirection);
MgcBoundingVolumeTree (unsigned short usVertexCount,
const MgcVector3* akVertex, unsigned short usTriangleCount,
const unsigned short* ausConnect, unsigned short usMaxTrisPerLeaf,
CreateBound oCreateBound);
virtual ~MgcBoundingVolumeTree ();
const MgcBoundingVolume* GetBound () const;
unsigned short GetTriangleCount () const;
unsigned short GetTriangle (unsigned short usI) const;
const unsigned short* GetTriangles () const;
const MgcBoundingVolumeTree* GetLChild () const;
const MgcBoundingVolumeTree* GetRChild () const;
protected:
MgcBoundingVolumeTree ();
void CreateTree (unsigned short usVertexCount, const MgcVector3* akVertex,
unsigned short usTriangleCount, const unsigned short* ausConnect,
unsigned short usMaxTrisPerLeaf, CreateBound oCreateBound,
const MgcVector3* akCentroid, unsigned short usI0,
unsigned short usI1, unsigned short* ausISplit,
unsigned short* ausOSplit);
void SplitTriangles (const MgcVector3* akCentroid, unsigned short usI0,
unsigned short usI1, unsigned short* ausISplit, unsigned short& usJ0,
unsigned short& usJ1, unsigned short* ausOSplit,
const MgcVector3& rkOrigin, const MgcVector3& rkDirection);
// for quick-sort of centroid projections on axes
class ProjectionInfo
{
public:
unsigned short m_usTriangle;
MgcReal m_fProjection;
};
static int Compare (const void* pvElement0, const void* pvElement1);
// Interior nodes set count to zero, array to null. Leaf nodes set count
// to number of triangles at that node (1 if usMaxTrianglesPerLeaf was
// set to 1) and allocate an array of triangle indices that are relative
// to the input mesh of the top level constructor.
unsigned short m_usTriangleCount;
unsigned short* m_ausTriangle;
MgcBoundingVolume* m_pkBound;
MgcBoundingVolumeTree* m_pkLChild;
MgcBoundingVolumeTree* m_pkRChild;
};
//----------------------------------------------------------------------------
inline const MgcBoundingVolume* MgcBoundingVolumeTree::GetBound () const
{
return m_pkBound;
}
//----------------------------------------------------------------------------
inline unsigned short MgcBoundingVolumeTree::GetTriangleCount () const
{
return m_usTriangleCount;
}
//----------------------------------------------------------------------------
inline unsigned short MgcBoundingVolumeTree::GetTriangle (
unsigned short usI) const
{
return m_ausTriangle[usI];
}
//----------------------------------------------------------------------------
inline const unsigned short* MgcBoundingVolumeTree::GetTriangles () const
{
return m_ausTriangle;
}
//----------------------------------------------------------------------------
inline const MgcBoundingVolumeTree* MgcBoundingVolumeTree::GetLChild () const
{
return m_pkLChild;
}
//----------------------------------------------------------------------------
inline const MgcBoundingVolumeTree* MgcBoundingVolumeTree::GetRChild () const
{
return m_pkRChild;
}
//----------------------------------------------------------------------------
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -