aboutsummaryrefslogtreecommitdiff
path: root/tool_src/BspLib/BoundingBox.h
blob: 417d8546d7ecea0a294ee60887f735e7e0f738e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//-----------------------------------------------------------------------------
//	BSPLIB HEADER: BoundingBox.h
//
//  Copyright (c) 1997-1998 by Markus Hadwiger
//  All Rights Reserved.
//-----------------------------------------------------------------------------

#ifndef _BOUNDINGBOX_H_
#define _BOUNDINGBOX_H_

// bsplib header files
#include "BspLibDefs.h"
#include "BspObject.h"
#include "Vertex.h"


BSPLIB_NAMESPACE_BEGIN


// axial bounding box; can be part of singly linked list ----------------------
//
class BoundingBox {

	friend class ObjectBSPNode;

public:
	BoundingBox() { containedobject = NULL; nextbox = NULL; }
	BoundingBox( BspObject *cobj, BoundingBox *next = NULL );
	BoundingBox( const Vertex3& minvert, const Vertex3& maxvert, BoundingBox *next = NULL );
	~BoundingBox() { delete nextbox; }

	void			ApplyScaleFactor( double sfac );
	void			GrowBoundingBox( BoundingBox *otherbox );
	void			BoundingBoxListUnion( BoundingBox& unionbox );
	class ObjectBSPNode*	PartitionSpace();

	Vertex3			getMinVertex() const { return minvertex; }
	Vertex3			getMaxVertex() const { return maxvertex; }
	BspObject*		getContainedObject() const { return containedobject; }
	BoundingBox*	getNext() const { return nextbox; }

private:
	Vertex3			minvertex;
	Vertex3			maxvertex;
	BspObject*		containedobject;
	BoundingBox*	nextbox;
};

// construct bounding box by calculating its extents --------------------------
inline BoundingBox::BoundingBox( BspObject *cobj, BoundingBox *next )
{
	if ( ( containedobject = cobj ) != NULL ) {
		cobj->CalcBoundingBox( minvertex, maxvertex );
	}
	nextbox = next;
}

// construct bounding box directly --------------------------------------------
inline BoundingBox::BoundingBox( const Vertex3& minvert, const Vertex3& maxvert, BoundingBox *next )
{
	minvertex		= minvert;
	maxvertex		= maxvert;
	containedobject	= NULL;
	nextbox			= next;
}


BSPLIB_NAMESPACE_END


#endif // _BOUNDINGBOX_H_