~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/gameengine/SceneGraph/SG_BBox.h

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * $Id: SG_BBox.h,v 1.2 2004/05/21 09:21:15 kester Exp $
 
3
 *
 
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version. The Blender
 
10
 * Foundation also sells licenses for use in proprietary software under
 
11
 * the Blender License.  See http://www.blender.org/BL/ for information
 
12
 * about this.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program; if not, write to the Free Software Foundation,
 
21
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
22
 *
 
23
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 
24
 * All rights reserved.
 
25
 *
 
26
 * The Original Code is: all of this file.
 
27
 *
 
28
 * Contributor(s): none yet.
 
29
 *
 
30
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
 
31
 * Bounding Box
 
32
 */
 
33
 
 
34
#ifndef __SG_BBOX_H__
 
35
#define __SG_BBOX_H__
 
36
 
 
37
#include "MT_Scalar.h"
 
38
#include "MT_Point3.h"
 
39
#include "MT_Vector3.h"
 
40
#include "MT_Transform.h"
 
41
 
 
42
#include <vector> 
 
43
 
 
44
class SG_Node;
 
45
 
 
46
/**
 
47
 * Bounding box class.
 
48
 * Holds the minimum and maximum axis aligned points of a node's bounding box,
 
49
 * in world coordinates.
 
50
 */
 
51
class SG_BBox
 
52
{
 
53
        MT_Point3 m_min;
 
54
        MT_Point3 m_max;
 
55
public:
 
56
        typedef enum { INSIDE, INTERSECT, OUTSIDE } intersect;
 
57
        SG_BBox();
 
58
        SG_BBox(const MT_Point3 &min, const MT_Point3 &max);
 
59
        SG_BBox(const SG_BBox &other, const MT_Transform &world);
 
60
        SG_BBox(const SG_BBox &other);
 
61
        ~SG_BBox();
 
62
 
 
63
        /**
 
64
         * Enlarges the bounding box to contain the specified point.
 
65
         */
 
66
        SG_BBox& operator +=(const MT_Point3 &point);
 
67
        /**
 
68
         * Enlarges the bounding box to contain the specified bound box.
 
69
         */
 
70
        SG_BBox& operator +=(const SG_BBox &bbox);
 
71
        
 
72
        SG_BBox operator + (const SG_BBox &bbox2) const;
 
73
#if 0
 
74
        /**
 
75
         * Translates the bounding box.
 
76
         */
 
77
        void translate(const MT_Vector3 &dx);
 
78
        /**
 
79
         * Scales the bounding box about the optional point.
 
80
         */
 
81
        void scale(const MT_Vector3 &size, const MT_Point3 &point = MT_Point3(0., 0., 0.));
 
82
#endif
 
83
        SG_BBox transform(const MT_Transform &world) const;
 
84
        /**
 
85
         * Computes the volume of the bounding box.
 
86
         */
 
87
        MT_Scalar volume() const;
 
88
        
 
89
        /**
 
90
         * Test if the given point is inside this bounding box.
 
91
         */
 
92
        bool inside(const MT_Point3 &point) const;
 
93
        
 
94
        /**
 
95
         * Test if the given bounding box is inside this bounding box.
 
96
         */
 
97
        bool inside(const SG_BBox &other) const;
 
98
 
 
99
        /**
 
100
         * Test if the given bounding box is outside this bounding box.
 
101
         */
 
102
        bool outside(const SG_BBox &other) const;
 
103
        
 
104
        /**
 
105
         * Test if the given bounding box intersects this bounding box.
 
106
         */
 
107
        bool intersects(const SG_BBox &other) const;
 
108
        
 
109
        /**
 
110
         * Test the given bounding box with this bounding box.
 
111
         */
 
112
        intersect test(const SG_BBox &other) const;
 
113
        
 
114
        /**
 
115
         * Get the eight points that define this bounding box.
 
116
         *
 
117
         * @param world a world transform to apply to the produced points bounding box.
 
118
         */
 
119
        void get(MT_Point3 *box, const MT_Transform &world) const;
 
120
        /**
 
121
         * Get the eight points that define this axis aligned bounding box.
 
122
         * This differs from SG_BBox::get() in that the produced box will be world axis aligned.
 
123
         * The maximum & minimum local points will be transformed *before* splitting to 8 points.
 
124
         * @param world a world transform to be applied.
 
125
         */
 
126
        void getaa(MT_Point3 *box, const MT_Transform &world) const;
 
127
        
 
128
        void split(SG_BBox &left, SG_BBox &right) const;
 
129
        
 
130
        friend class SG_Tree;
 
131
 
 
132
};
 
133
 
 
134
#endif /* __SG_BBOX_H__ */