aboutsummaryrefslogtreecommitdiff
path: root/src/core/Placeable.cpp
blob: 162148f7f62acb249bc138bd7918012c89b4589b (plain) (blame)
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
#include "common.h"
#include "Placeable.h"


CPlaceable::CPlaceable(void)
{
	m_matrix.SetScale(1.0f);
}

CPlaceable::~CPlaceable(void)
{
}

void
CPlaceable::SetHeading(float angle)
{
	CVector pos = GetMatrix().GetPosition();
	m_matrix.SetRotateZ(angle);
	GetMatrix().Translate(pos);
}

bool
CPlaceable::IsWithinArea(float x1, float y1, float x2, float y2)
{
	float tmp;

	if(x1 > x2){
		tmp = x1;
		x1 = x2;
		x2 = tmp;
	}
	if(y1 > y2){
		tmp = y1;
		y1 = y2;
		y2 = tmp;
	}

	return x1 <= GetPosition().x && GetPosition().x <= x2 &&
	       y1 <= GetPosition().y && GetPosition().y <= y2;
}

bool
CPlaceable::IsWithinArea(float x1, float y1, float z1, float x2, float y2, float z2)
{
	float tmp;

	if(x1 > x2){
		tmp = x1;
		x1 = x2;
		x2 = tmp;
	}
	if(y1 > y2){
		tmp = y1;
		y1 = y2;
		y2 = tmp;
	}
	if(z1 > z2){
		tmp = z1;
		z1 = z2;
		z2 = tmp;
	}

	return x1 <= GetPosition().x && GetPosition().x <= x2 &&
	       y1 <= GetPosition().y && GetPosition().y <= y2 &&
	       z1 <= GetPosition().z && GetPosition().z <= z2;
}