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 */
31get_p0() const {
32
33 return PhysxManager::nxVec3_to_vec3(_segment.p0);
34}
35
36/**
37 * Sets the start point of the segment.
38 */
40set_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 */
51get_p1() const {
52
53 return PhysxManager::nxVec3_to_vec3(_segment.p1);
54}
55
56/**
57 * Sets the end point of the segment.
58 */
60set_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 */
71get_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 */
81compute_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 */
94compute_length() const {
95
96 return _segment.computeLength();
97}
98
99/**
100 * Computes a point on the segment.
101 */
103compute_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 */
117compute_square_length() const {
118
119 return _segment.computeSquareLength();
120}
121
122/**
123 * Setup this segment from origin (start point) and direction vector.
124 */
126set_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),
133}
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 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.
void compute_point(LPoint3f &p, float t) const
Computes a point on the segment.
void set_origin_direction(const LPoint3f &origin, const LVector3f &direction)
Setup this segment from origin (start point) and direction vector.
void compute_direction(LPoint3f &dir) const
Returns the direction vector from the segment's start point to it's end point.
float compute_length() const
Returns the distance from the segment's start point to it's end point.
void set_p1(LPoint3f p)
Sets the end point of the segment.
LPoint3f get_origin() const
Returns the start point of the segment.
void set_p0(LPoint3f p)
Sets the start point of the segment.
LPoint3f get_p1() const
Returns the end point of the segment.
LPoint3f get_p0() const
Returns the start point of the segment.
float compute_square_length() const
Returns the square distance from the segment's start point to it's end point.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.