Panda3D
Loading...
Searching...
No Matches
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 */
21is_valid() const {
22
23 return _sphere.IsValid();
24}
25
26/**
27 * Tests if a point is contained within the sphere.
28 */
30contains(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 */
41contains(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 */
51contains(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 */
65intersect(const PhysxSphere &sphere) const {
66
67 return _sphere.Intersect(sphere._sphere);
68}
69
70/**
71 * Returns the center of the sphere.
72 */
74get_center() const {
75
76 return PhysxManager::nxVec3_to_vec3(_sphere.center);
77}
78
79/**
80 * Sets the center of the sphere.
81 */
83set_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 */
94get_radius() const {
95
96 return _sphere.radius;
97}
98
99/**
100 * Sets the sphere's radius.
101 */
103set_radius(float radius) {
104
105 _sphere.radius = radius;
106}
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
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.
LPoint3f get_center() const
Returns the center of the sphere.
bool contains(const LPoint3f &p) const
Tests if a point is contained within the sphere.
void set_radius(float value)
Sets the sphere's radius.
bool is_valid() const
Returns TRUE if this sphere is valid.
float get_radius() const
Returns the sphere's radius.
bool intersect(const PhysxSphere &sphere) const
Tests if the sphere intersects another sphere.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.