~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to intern/boolop/intern/BOP_BBox.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * ***** BEGIN GPL LICENSE BLOCK *****
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU General Public License
6
 
 * as published by the Free Software Foundation; either version 2
7
 
 * of the License, or (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software Foundation,
16
 
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
 
 *
18
 
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19
 
 * All rights reserved.
20
 
 *
21
 
 * The Original Code is: all of this file.
22
 
 *
23
 
 * Contributor(s): none yet.
24
 
 *
25
 
 * ***** END GPL LICENSE BLOCK *****
26
 
 */
27
 
 
28
 
/** \file boolop/intern/BOP_BBox.h
29
 
 *  \ingroup boolopintern
30
 
 */
31
 
 
32
 
 
33
 
#ifndef __BOP_BBOX_H__
34
 
#define __BOP_BBOX_H__
35
 
 
36
 
#include "MT_Point3.h"
37
 
#include "BOP_MathUtils.h"
38
 
 
39
 
#define BOP_MAX(a, b) ((a > b) ? a : b)
40
 
#define BOP_MIN(a, b) ((a < b) ? a : b)
41
 
#define BOP_ABS(a) ((a < 0) ? -(a) : a)
42
 
 
43
 
class BOP_BBox
44
 
{
45
 
public:
46
 
        MT_Scalar m_minX;
47
 
        MT_Scalar m_minY;
48
 
        MT_Scalar m_minZ;
49
 
        MT_Scalar m_maxX;
50
 
        MT_Scalar m_maxY;
51
 
        MT_Scalar m_maxZ;
52
 
        MT_Scalar m_centerX;
53
 
        MT_Scalar m_centerY;
54
 
        MT_Scalar m_centerZ;
55
 
        MT_Scalar m_extentX;
56
 
        MT_Scalar m_extentY;
57
 
        MT_Scalar m_extentZ;
58
 
        
59
 
public:
60
 
        BOP_BBox();
61
 
        BOP_BBox(const MT_Point3& p1,const MT_Point3& p2,const MT_Point3& p3);
62
 
        inline void add(const MT_Point3& p)
63
 
        {
64
 
                m_minX = BOP_MIN(m_minX,p[0]);
65
 
                m_minY = BOP_MIN(m_minY,p[1]);
66
 
                m_minZ = BOP_MIN(m_minZ,p[2]);
67
 
                m_maxX = BOP_MAX(m_maxX,p[0]);
68
 
                m_maxY = BOP_MAX(m_maxY,p[1]);
69
 
                m_maxZ = BOP_MAX(m_maxZ,p[2]);
70
 
        };
71
 
 
72
 
        inline const MT_Scalar getCenterX() const {return m_centerX;};
73
 
        inline const MT_Scalar getCenterY() const {return m_centerY;};
74
 
        inline const MT_Scalar getCenterZ() const {return m_centerZ;};
75
 
 
76
 
        inline const MT_Scalar getExtentX() const {return m_extentX;};
77
 
        inline const MT_Scalar getExtentY() const {return m_extentY;};
78
 
        inline const MT_Scalar getExtentZ() const {return m_extentZ;};
79
 
        
80
 
        inline void compute() {
81
 
                m_extentX = (m_maxX-m_minX)/2.0f;
82
 
                m_extentY = (m_maxY-m_minY)/2.0f;
83
 
                m_extentZ = (m_maxZ-m_minZ)/2.0f;
84
 
                m_centerX = m_minX+m_extentX;
85
 
                m_centerY = m_minY+m_extentY;
86
 
                m_centerZ = m_minZ+m_extentZ;
87
 
        };
88
 
 
89
 
        inline const bool intersect(const BOP_BBox& b) const {
90
 
          return (!((BOP_comp(m_maxX,b.m_minX)<0) || (BOP_comp(b.m_maxX,m_minX)<0) ||
91
 
                    (BOP_comp(m_maxY,b.m_minY)<0) || (BOP_comp(b.m_maxY,m_minY)<0) ||
92
 
                    (BOP_comp(m_maxZ,b.m_minZ)<0) || (BOP_comp(b.m_maxZ,m_minZ)<0)));
93
 
        };
94
 
        
95
 
        
96
 
};
97
 
 
98
 
#endif