Richard Boegli's CnC_Generals_Zero_Hour Fork
WIP
This is documentation of Richard Boegil's Zero Hour Fork
Loading...
Searching...
No Matches
colmathaabox.h
Go to the documentation of this file.
1
/*
2
** Command & Conquer Generals Zero Hour(tm)
3
** Copyright 2025 Electronic Arts Inc.
4
**
5
** This program is free software: you can redistribute it and/or modify
6
** it under the terms of the GNU General Public License as published by
7
** the Free Software Foundation, either version 3 of the License, or
8
** (at your option) any later version.
9
**
10
** This program is distributed in the hope that it will be useful,
11
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
** GNU General Public License for more details.
14
**
15
** You should have received a copy of the GNU General Public License
16
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
/***********************************************************************************************
20
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21
***********************************************************************************************
22
* *
23
* Project Name : WWMath *
24
* *
25
* $Archive:: /Commando/Code/wwmath/colmathaabox.h $*
26
* *
27
* Original Author:: Greg Hjelstrom *
28
* *
29
* $Author:: Jani_p $*
30
* *
31
* $Modtime:: 5/08/01 5:01p $*
32
* *
33
* $Revision:: 8 $*
34
* *
35
*---------------------------------------------------------------------------------------------*
36
* Functions: *
37
* CollisionMath::Overlap_Test -- test overlap between an AABox and a point *
38
* CollisionMath::Overlap_Test -- Tests overlap between two AABoxes *
39
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
40
41
#if defined(_MSC_VER)
42
#pragma once
43
#endif
44
45
#ifndef COLMATHAABOX_H
46
#define COLMATHAABOX_H
47
48
#include "always.h"
49
#include "
aabox.h
"
50
#include "
vector3.h
"
51
#include "
lineseg.h
"
52
53
54
/***********************************************************************************************
55
* CollisionMath::Overlap_Test -- test overlap between an AABox and a point *
56
* *
57
* INPUT: *
58
* *
59
* OUTPUT: *
60
* *
61
* WARNINGS: *
62
* *
63
* HISTORY: *
64
* 3/14/2000 gth : Created. *
65
*=============================================================================================*/
66
WWINLINE
CollisionMath::OverlapType
CollisionMath::Overlap_Test
(
const
AABoxClass
& box,
const
Vector3
& point)
67
{
68
if
(
WWMath::Fabs
(point.
X
- box.
Center
.
X
) > box.
Extent
.
X
)
return
POS
;
69
if
(
WWMath::Fabs
(point.
Y
- box.
Center
.
Y
) > box.
Extent
.
Y
)
return
POS
;
70
if
(
WWMath::Fabs
(point.
Z
- box.
Center
.
Z
) > box.
Extent
.
Z
)
return
POS
;
71
72
return
NEG
;
73
}
74
75
/***********************************************************************************************
76
* CollisionMath::Overlap_Test -- Tests overlap between two AABoxes *
77
* *
78
* INPUT: *
79
* *
80
* OUTPUT: *
81
* *
82
* WARNINGS: *
83
* *
84
* HISTORY: *
85
* 11/19/99 gth : Created. *
86
*=============================================================================================*/
87
WWINLINE
CollisionMath::OverlapType
CollisionMath::Overlap_Test
(
const
AABoxClass
& box,
const
AABoxClass
& box2)
88
{
89
Vector3
dc;
90
Vector3::Subtract
(box2.
Center
,box.
Center
,&dc);
91
92
if
(box.
Extent
.
X
+ box2.
Extent
.
X
<
WWMath::Fabs
(dc.
X
))
return
POS
;
93
if
(box.
Extent
.
Y
+ box2.
Extent
.
Y
<
WWMath::Fabs
(dc.
Y
))
return
POS
;
94
if
(box.
Extent
.
Z
+ box2.
Extent
.
Z
<
WWMath::Fabs
(dc.
Z
))
return
POS
;
95
96
if
( (dc.
X
+ box2.
Extent
.
X
<= box.
Extent
.
X
) &&
97
(dc.
Y
+ box2.
Extent
.
Y
<= box.
Extent
.
Y
) &&
98
(dc.
Z
+ box2.
Extent
.
Z
<= box.
Extent
.
Z
) &&
99
(dc.
X
- box2.
Extent
.
X
>= -box.
Extent
.
X
) &&
100
(dc.
Y
- box2.
Extent
.
Y
>= -box.
Extent
.
Y
) &&
101
(dc.
Z
- box2.
Extent
.
Z
>= -box.
Extent
.
Z
))
102
{
103
return
NEG
;
// inside;
104
}
105
106
return
BOTH
;
107
}
108
109
#endif
110
WWINLINE
#define WWINLINE
Definition
always.h:172
vector3.h
aabox.h
AABoxClass
Definition
aabox.h:83
AABoxClass::Center
Vector3 Center
Definition
aabox.h:123
AABoxClass::Extent
Vector3 Extent
Definition
aabox.h:124
CollisionMath::Overlap_Test
static OverlapType Overlap_Test(const AAPlaneClass &plane, const Vector3 &point)
Definition
colmathplane.cpp:55
CollisionMath::OverlapType
OverlapType
Definition
colmath.h:106
CollisionMath::POS
@ POS
Definition
colmath.h:107
CollisionMath::BOTH
@ BOTH
Definition
colmath.h:110
CollisionMath::NEG
@ NEG
Definition
colmath.h:108
Vector3
Definition
vector3.h:85
Vector3::X
float X
Definition
vector3.h:90
Vector3::Z
float Z
Definition
vector3.h:92
Vector3::Y
float Y
Definition
vector3.h:91
Vector3::Subtract
static WWINLINE void Subtract(const Vector3 &a, const Vector3 &b, Vector3 *c)
Definition
vector3.h:576
WWMath::Fabs
static WWINLINE float Fabs(float val)
Definition
wwmath.h:113
lineseg.h
Code
Libraries
Source
WWVegas
WWMath
colmathaabox.h
Generated by
1.13.2