Panda3D
 All Classes Functions Variables Enumerations
physxSphere.cxx
1 // Filename: physxSphere.cxx
2 // Created by: enn0x (31Oct09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "physxSphere.h"
16 #include "physxManager.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: PhysxSphere::is_valid
20 // Access: Published
21 // Description: Returns TRUE if this sphere is valid.
22 ////////////////////////////////////////////////////////////////////
23 bool PhysxSphere::
24 is_valid() const {
25 
26  return _sphere.IsValid();
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: PhysxSphere::contains
31 // Access: Published
32 // Description: Tests if a point is contained within the sphere.
33 ////////////////////////////////////////////////////////////////////
34 bool PhysxSphere::
35 contains(const LPoint3f &p) const {
36 
37  nassertr(!p.is_nan(), false);
38 
39  return _sphere.Contains(PhysxManager::vec3_to_nxVec3(p));
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: PhysxSphere::contains
44 // Access: Published
45 // Description: Tests if a sphere is contained within the sphere.
46 ////////////////////////////////////////////////////////////////////
47 bool PhysxSphere::
48 contains(const PhysxSphere &sphere) const {
49 
50  return _sphere.Contains(sphere._sphere);
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: PhysxSphere::contains
55 // Access: Published
56 // Description: Tests if an axis aligned box is contained within
57 // the sphere. The axis aligned box is defined by the
58 // minimum corner and the maximum corner.
59 ////////////////////////////////////////////////////////////////////
60 bool PhysxSphere::
61 contains(const LPoint3f &min, const LPoint3f &max) const {
62 
63  nassertr(!min.is_nan(), false);
64  nassertr(!max.is_nan(), false);
65 
66  return _sphere.Contains(PhysxManager::vec3_to_nxVec3(min),
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function: PhysxSphere::intersect
72 // Access: Published
73 // Description: Tests if the sphere intersects another sphere.
74 // Returns TRUE if the spheres overlap.
75 ////////////////////////////////////////////////////////////////////
76 bool PhysxSphere::
77 intersect(const PhysxSphere &sphere) const {
78 
79  return _sphere.Intersect(sphere._sphere);
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: PhysxSphere::get_center
84 // Access: Published
85 // Description: Returns the center of the sphere.
86 ////////////////////////////////////////////////////////////////////
88 get_center() const {
89 
90  return PhysxManager::nxVec3_to_vec3(_sphere.center);
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: PhysxSphere::set_center
95 // Access: Published
96 // Description: Sets the center of the sphere.
97 ////////////////////////////////////////////////////////////////////
98 void PhysxSphere::
100 
101  nassertv(!center.is_nan());
102 
103  _sphere.center = PhysxManager::vec3_to_nxVec3(center);
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: PhysxSphere::get_radius
108 // Access: Published
109 // Description: Returns the sphere's radius.
110 ////////////////////////////////////////////////////////////////////
111 float PhysxSphere::
112 get_radius() const {
113 
114  return _sphere.radius;
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: PhysxSphere::set_radius
119 // Access: Published
120 // Description: Sets the sphere's radius.
121 ////////////////////////////////////////////////////////////////////
122 void PhysxSphere::
123 set_radius(float radius) {
124 
125  _sphere.radius = radius;
126 }
127 
LPoint3f get_center() const
Returns the center of the sphere.
Definition: physxSphere.cxx:88
Represents a sphere defined by its center point and radius.
Definition: physxSphere.h:28
bool contains(const LPoint3f &p) const
Tests if a point is contained within the sphere.
Definition: physxSphere.cxx:35
void set_center(LPoint3f value)
Sets the center of the sphere.
Definition: physxSphere.cxx:99
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
Definition: lvecBase3.h:463
bool intersect(const PhysxSphere &sphere) const
Tests if the sphere intersects another sphere.
Definition: physxSphere.cxx:77
float get_radius() const
Returns the sphere's radius.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:33
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:44
void set_radius(float value)
Sets the sphere's radius.
bool is_valid() const
Returns TRUE if this sphere is valid.
Definition: physxSphere.cxx:24