Panda3D
physxPlane.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 physxPlane.cxx
10  * @author enn0x
11  * @date 2009-10-31
12  */
13 
14 #include "physxPlane.h"
15 #include "physxManager.h"
16 
17 /**
18  *
19  */
20 float PhysxPlane::
21 distance(const LPoint3f &p) const {
22 
23  nassertr(!p.is_nan(), 0.0f);
24 
25  return _plane.distance(PhysxManager::point3_to_nxVec3(p));
26 }
27 
28 /**
29  *
30  */
31 bool PhysxPlane::
32 belongs(const LPoint3f &p) const {
33 
34  nassertr(!p.is_nan(), false);
35 
36  return _plane.belongs(PhysxManager::point3_to_nxVec3(p));
37 }
38 
39 /**
40  *
41  */
42 LPoint3f PhysxPlane::
43 point_in_plane() const {
44 
45  return PhysxManager::nxVec3_to_point3(_plane.pointInPlane());
46 }
47 
48 /**
49  *
50  */
51 LPoint3f PhysxPlane::
52 project(const LPoint3f &p) const {
53 
54  nassertr(!p.is_nan(), LPoint3f::zero());
55 
57 }
58 
59 /**
60  *
61  */
62 void PhysxPlane::
63 inverse_transform(const LMatrix4f &transform, PhysxPlane &transformed) const {
64 
65  nassertv(!transform.is_nan());
66 
67  _plane.inverseTransform(PhysxManager::mat4_to_nxMat34(transform), transformed._plane);
68 }
69 
70 /**
71  *
72  */
73 void PhysxPlane::
74 normalize() {
75 
76  _plane.normalize();
77 }
78 
79 /**
80  *
81  */
82 void PhysxPlane::
83 transform(const LMatrix4f &transform, PhysxPlane &transformed) const {
84 
85  nassertv(!transform.is_nan());
86 
87  _plane.transform(PhysxManager::mat4_to_nxMat34(transform), transformed._plane);
88 }
89 
90 /**
91  *
92  */
93 float PhysxPlane::
94 get_d() const {
95 
96  return _plane.d;
97 }
98 
99 /**
100  *
101  */
102 void PhysxPlane::
103 set_d(float value) {
104 
105  _plane.d = value;
106 }
107 
108 /**
109  *
110  */
111 LVector3f PhysxPlane::
112 get_normal() const {
113 
114  return PhysxManager::nxVec3_to_vec3(_plane.normal);
115 }
116 
117 /**
118  *
119  */
120 void PhysxPlane::
121 set_normal(LVector3f normal) {
122 
123  nassertv(!normal.is_nan());
124 
125  _plane.normal = PhysxManager::vec3_to_nxVec3(normal);
126 }
127 
128 /**
129  *
130  */
131 PhysxPlane PhysxPlane::
132 set(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &p2) {
133 
134  PhysxPlane plane;
135 
136  nassertr(!p0.is_nan(), plane);
137  nassertr(!p1.is_nan(), plane);
138  nassertr(!p2.is_nan(), plane);
139 
140  plane._plane = _plane.set(PhysxManager::point3_to_nxVec3(p0),
143  return plane;
144 }
145 
146 /**
147  *
148  */
149 PhysxPlane PhysxPlane::
150 zero() {
151 
152  PhysxPlane plane;
153  plane._plane = _plane.zero();
154  return plane;
155 }
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:63
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:119
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:72