summaryrefslogtreecommitdiff
path: root/common/boundbox.h
blob: 5354396728e089f9903d17424304cfdeae427861 (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
//
//	boundbox.h
////////////////////////////////////////////////////

#ifndef _BOUNDBOX_H_
#define _BOUNDBOX_H_

class Matrix;
class BoundingBox;

// Callback "closure" struct, used to make the necessary parameters known to
// the callback function.
typedef struct {
	double a1,b1,c1;
	double a2,b2,c2;
	double mindist;
	BoundingBox *pClosest;
} CLICKLINE;

class BoundingBox
{
public:
	BoundingBox();
	~BoundingBox();

	int GetOwnerType()
		{ return m_nParentType; }
	void* GetOwner()
		{ return m_pOwner; }

	void Initialize(void* pOwner, unsigned char nType);
	double FindIntersectDist(CLICKLINE* pLine);
	void CalculateBoundingBox(float pos[3]);
	void CalculateBoundingBox(Matrix *mat);
	void CalculateBoundingBox(Matrix *mat, float Dimensions[6]);

protected:
	void* m_pOwner;
	unsigned char m_nParentType;
	float m_fPlanes[4][6];

	bool IntersectionbyLine(double a1, double b1, double c1, double a2, double b2, double c2, double *x, double *y, double *z);
	bool PointInside(double x, double y, double z);
};

#endif // _BOUNDBOX_H_