1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "bladerunner/boundingbox.h"
24 
25 #include "bladerunner/savefile.h"
26 
27 namespace BladeRunner {
28 
BoundingBox(float x0,float y0,float z0,float x1,float y1,float z1)29 BoundingBox::BoundingBox(float x0, float y0, float z0, float x1, float y1, float z1) {
30 	_vertices[0].x = x0;
31 	_vertices[0].y = y0;
32 	_vertices[0].z = z0;
33 
34 	_vertices[1].x = x1;
35 	_vertices[1].y = y1;
36 	_vertices[1].z = z1;
37 }
38 
expand(float x0,float y0,float z0,float x1,float y1,float z1)39 void BoundingBox::expand(float x0, float y0, float z0, float x1, float y1, float z1) {
40 	_vertices[0].x += x0;
41 	_vertices[0].y += y0;
42 	_vertices[0].z += z0;
43 
44 	_vertices[1].x += x1;
45 	_vertices[1].y += y1;
46 	_vertices[1].z += z1;
47 }
48 
inside(float x,float y,float z) const49 bool BoundingBox::inside(float x, float y, float z) const {
50 	return x >= _vertices[0].x && x <= _vertices[1].x
51 	    && y >= _vertices[0].y && y <= _vertices[1].y
52 	    && z >= _vertices[0].z && z <= _vertices[1].z;
53 }
54 
inside(Vector3 & position) const55 bool BoundingBox::inside(Vector3 &position) const {
56 	return inside(position.x, position.y, position.z);
57 }
58 
setXYZ(float x0,float y0,float z0,float x1,float y1,float z1)59 void BoundingBox::setXYZ(float x0, float y0, float z0, float x1, float y1, float z1) {
60 	_vertices[0].x = x0;
61 	_vertices[0].y = y0;
62 	_vertices[0].z = z0;
63 
64 	_vertices[1].x = x1;
65 	_vertices[1].y = y1;
66 	_vertices[1].z = z1;
67 }
68 
getXYZ(float * x0,float * y0,float * z0,float * x1,float * y1,float * z1) const69 void BoundingBox::getXYZ(float *x0, float *y0, float *z0, float *x1, float *y1, float *z1) const {
70 	*x0 = _vertices[0].x;
71 	*y0 = _vertices[0].y;
72 	*z0 = _vertices[0].z;
73 
74 	*x1 = _vertices[1].x;
75 	*y1 = _vertices[1].y;
76 	*z1 = _vertices[1].z;
77 }
78 
getZ0() const79 float BoundingBox::getZ0() const {
80 	return _vertices[0].z;
81 }
82 
getZ1() const83 float BoundingBox::getZ1() const {
84 	return _vertices[1].z;
85 }
86 
87 } // End of namespace BladeRunner
88