Panda3D
physxSphere.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file physxSphere.cxx
10  * @author enn0x
11  * @date 2009-10-31
12  */
13 
14 #include "physxSphere.h"
15 #include "physxManager.h"
16 
17 /**
18  * Returns TRUE if this sphere is valid.
19  */
20 bool PhysxSphere::
21 is_valid() const {
22 
23  return _sphere.IsValid();
24 }
25 
26 /**
27  * Tests if a point is contained within the sphere.
28  */
29 bool PhysxSphere::
30 contains(const LPoint3f &p) const {
31 
32  nassertr(!p.is_nan(), false);
33 
34  return _sphere.Contains(PhysxManager::vec3_to_nxVec3(p));
35 }
36 
37 /**
38  * Tests if a sphere is contained within the sphere.
39  */
40 bool PhysxSphere::
41 contains(const PhysxSphere &sphere) const {
42 
43  return _sphere.Contains(sphere._sphere);
44 }
45 
46 /**
47  * Tests if an axis aligned box is contained within the sphere. The axis
48  * aligned box is defined by the minimum corner and the maximum corner.
49  */
50 bool PhysxSphere::
51 contains(const LPoint3f &min, const LPoint3f &max) const {
52 
53  nassertr(!min.is_nan(), false);
54  nassertr(!max.is_nan(), false);
55 
56  return _sphere.Contains(PhysxManager::vec3_to_nxVec3(min),
58 }
59 
60 /**
61  * Tests if the sphere intersects another sphere. Returns TRUE if the spheres
62  * overlap.
63  */
64 bool PhysxSphere::
65 intersect(const PhysxSphere &sphere) const {
66 
67  return _sphere.Intersect(sphere._sphere);
68 }
69 
70 /**
71  * Returns the center of the sphere.
72  */
73 LPoint3f PhysxSphere::
74 get_center() const {
75 
76  return PhysxManager::nxVec3_to_vec3(_sphere.center);
77 }
78 
79 /**
80  * Sets the center of the sphere.
81  */
82 void PhysxSphere::
83 set_center(LPoint3f center) {
84 
85  nassertv(!center.is_nan());
86 
87  _sphere.center = PhysxManager::vec3_to_nxVec3(center);
88 }
89 
90 /**
91  * Returns the sphere's radius.
92  */
93 float PhysxSphere::
94 get_radius() const {
95 
96  return _sphere.radius;
97 }
98 
99 /**
100  * Sets the sphere's radius.
101  */
102 void PhysxSphere::
103 set_radius(float radius) {
104 
105  _sphere.radius = radius;
106 }
Represents a sphere defined by its center point and radius.
Definition: physxSphere.h:25
void set_center(LPoint3f value)
Sets the center of the sphere.
Definition: physxSphere.cxx:83
bool is_valid() const
Returns TRUE if this sphere is valid.
Definition: physxSphere.cxx:21
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool contains(const LPoint3f &p) const
Tests if a point is contained within the sphere.
Definition: physxSphere.cxx:30
LPoint3f get_center() const
Returns the center of the sphere.
Definition: physxSphere.cxx:74
float get_radius() const
Returns the sphere's radius.
Definition: physxSphere.cxx:94
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
void set_radius(float value)
Sets the sphere's radius.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool intersect(const PhysxSphere &sphere) const
Tests if the sphere intersects another sphere.
Definition: physxSphere.cxx:65