Panda3D

Loading...
Searching...
No Matches
physxSegment.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 physxSegment.cxx
10 * @author enn0x
11 * @date 2009-10-31
12 */
13
14#include "physxSegment.h"
15#include "physxManager.h"
16
17/**
18 *
19 */
20PhysxSegment::
21PhysxSegment(const LPoint3f &p0, const LPoint3f &p1) {
22
23 _segment.p0 = PhysxManager::point3_to_nxVec3(p0);
24 _segment.p1 = PhysxManager::point3_to_nxVec3(p1);
25}
26
27/**
28 * Returns the start point of the segment.
29 */
30LPoint3f PhysxSegment::
31 get_p0() const {
32
33 return PhysxManager::nxVec3_to_vec3(_segment.p0);
34}
35
36/**
37 * Sets the start point of the segment.
38 */
39 void PhysxSegment::
40 set_p0(LPoint3f p) {
41
42 nassertv_always(!p.is_nan());
43
44 _segment.p0 = PhysxManager::vec3_to_nxVec3(p);
45}
46
47/**
48 * Returns the end point of the segment.
49 */
50LPoint3f PhysxSegment::
51 get_p1() const {
52
53 return PhysxManager::nxVec3_to_vec3(_segment.p1);
54}
55
56/**
57 * Sets the end point of the segment.
58 */
59 void PhysxSegment::
60 set_p1(LPoint3f p) {
61
62 nassertv_always(!p.is_nan());
63
64 _segment.p1 = PhysxManager::vec3_to_nxVec3(p);
65}
66
67/**
68 * Returns the start point of the segment.
69 */
70LPoint3f PhysxSegment::
71 get_origin() const {
72
73 return PhysxManager::nxVec3_to_point3(_segment.getOrigin());
74}
75
76/**
77 * Returns the direction vector from the segment's start point to it's end
78 * point.
79 */
80 void PhysxSegment::
81 compute_direction(LPoint3f &dir) const {
82
83 nassertv(!dir.is_nan());
84
85 NxVec3 nDir = PhysxManager::point3_to_nxVec3(dir);
86 _segment.computeDirection(nDir);
87 PhysxManager::update_point3_from_nxVec3(dir, nDir);
88}
89
90/**
91 * Returns the distance from the segment's start point to it's end point.
92 */
93 float PhysxSegment::
94 compute_length() const {
95
96 return _segment.computeLength();
97}
98
99/**
100 * Computes a point on the segment.
101 */
102 void PhysxSegment::
103 compute_point(LPoint3f &p, float t) const {
104
105 nassertv(!p.is_nan());
106
107 NxVec3 nP = PhysxManager::point3_to_nxVec3(p);
108 _segment.computePoint(nP, t);
109 PhysxManager::update_point3_from_nxVec3(p, nP);
110}
111
112/**
113 * Returns the square distance from the segment's start point to it's end
114 * point.
115 */
116 float PhysxSegment::
117 compute_square_length() const {
118
119 return _segment.computeSquareLength();
120}
121
122/**
123 * Setup this segment from origin (start point) and direction vector.
124 */
125 void PhysxSegment::
126 set_origin_direction(const LPoint3f &origin, const LVector3f &direction) {
127
128 nassertv_always(!origin.is_nan());
129 nassertv_always(!direction.is_nan());
130
131 _segment.setOriginDirection(PhysxManager::point3_to_nxVec3(origin),
132 PhysxManager::vec3_to_nxVec3(direction));
133}
PhysxManager::vec3_to_nxVec3
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition physxManager.I:27
PhysxManager::point3_to_nxVec3
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition physxManager.I:63
PhysxManager::nxVec3_to_point3
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition physxManager.I:72
PhysxManager::nxVec3_to_vec3
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition physxManager.I:36
PhysxSegment::compute_point
void compute_point(LPoint3f &p, float t) const
Computes a point on the segment.
Definition physxSegment.cxx:103
PhysxSegment::set_origin_direction
void set_origin_direction(const LPoint3f &origin, const LVector3f &direction)
Setup this segment from origin (start point) and direction vector.
Definition physxSegment.cxx:126
PhysxSegment::compute_direction
void compute_direction(LPoint3f &dir) const
Returns the direction vector from the segment's start point to it's end point.
Definition physxSegment.cxx:81
PhysxSegment::compute_length
float compute_length() const
Returns the distance from the segment's start point to it's end point.
Definition physxSegment.cxx:94
PhysxSegment::set_p1
void set_p1(LPoint3f p)
Sets the end point of the segment.
Definition physxSegment.cxx:60
PhysxSegment::get_origin
LPoint3f get_origin() const
Returns the start point of the segment.
Definition physxSegment.cxx:71
PhysxSegment::set_p0
void set_p0(LPoint3f p)
Sets the start point of the segment.
Definition physxSegment.cxx:40
PhysxSegment::get_p1
LPoint3f get_p1() const
Returns the end point of the segment.
Definition physxSegment.cxx:51
PhysxSegment::get_p0
LPoint3f get_p0() const
Returns the start point of the segment.
Definition physxSegment.cxx:31
PhysxSegment::compute_square_length
float compute_square_length() const
Returns the square distance from the segment's start point to it's end point.
Definition physxSegment.cxx:117
physxManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxSegment.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.