Panda3D
Loading...
Searching...
No Matches
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 */
20float PhysxPlane::
21distance(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 */
31bool PhysxPlane::
32belongs(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 */
42LPoint3f PhysxPlane::
43point_in_plane() const {
44
45 return PhysxManager::nxVec3_to_point3(_plane.pointInPlane());
46}
47
48/**
49 *
50 */
51LPoint3f PhysxPlane::
52project(const LPoint3f &p) const {
53
54 nassertr(!p.is_nan(), LPoint3f::zero());
55
57}
58
59/**
60 *
61 */
62void PhysxPlane::
63inverse_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 */
73void PhysxPlane::
74normalize() {
75
76 _plane.normalize();
77}
78
79/**
80 *
81 */
82void PhysxPlane::
83transform(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 */
93float PhysxPlane::
94get_d() const {
95
96 return _plane.d;
97}
98
99/**
100 *
101 */
102void PhysxPlane::
103set_d(float value) {
104
105 _plane.d = value;
106}
107
108/**
109 *
110 */
111LVector3f PhysxPlane::
112get_normal() const {
113
114 return PhysxManager::nxVec3_to_vec3(_plane.normal);
115}
116
117/**
118 *
119 */
120void PhysxPlane::
121set_normal(LVector3f normal) {
122
123 nassertv(!normal.is_nan());
124
125 _plane.normal = PhysxManager::vec3_to_nxVec3(normal);
126}
127
128/**
129 *
130 */
131PhysxPlane PhysxPlane::
132set(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 */
149PhysxPlane PhysxPlane::
150zero() {
151
152 PhysxPlane plane;
153 plane._plane = _plane.zero();
154 return plane;
155}
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.