Panda3D
collisionSegment.I
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 collisionSegment.I
10  * @author drose
11  * @date 2001-01-30
12  */
13 
14 /**
15  * Creates an invalid segment. This isn't terribly useful; it's expected that
16  * the user will subsequently adjust the segment via
17  * set_origin()/set_direction() or set_from_lens().
18  */
19 INLINE CollisionSegment::
21  _a(LPoint3(0.0, 0.0, 0.0)),
22  _b(LPoint3(0.0, 0.0, 0.0))
23 {
24 }
25 
26 /**
27  *
28  */
29 INLINE CollisionSegment::
30 CollisionSegment(const LPoint3 &a, const LPoint3 &b) :
31  _a(a), _b(b)
32 {
33  nassertv(_a != _b);
34 }
35 
36 /**
37  *
38  */
39 INLINE CollisionSegment::
40 CollisionSegment(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az,
41  PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz) :
42  _a(ax, ay, az), _b(bx, by, bz)
43 {
44  nassertv(_a != _b);
45 }
46 
47 /**
48  *
49  */
50 INLINE CollisionSegment::
52  CollisionSolid(copy),
53  _a(copy._a),
54  _b(copy._b)
55 {
56 }
57 
58 /**
59  *
60  */
61 INLINE void CollisionSegment::
62 set_point_a(const LPoint3 &a) {
63  _a = a;
64  mark_internal_bounds_stale();
65  mark_viz_stale();
66  // We don't assert here that a != b, on the assumption that you might be
67  // about to change both at once, and you'll probably start by changing a
68  // first.
69 }
70 
71 /**
72  *
73  */
74 INLINE void CollisionSegment::
75 set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
76  set_point_a(LPoint3(x, y, z));
77 }
78 
79 /**
80  *
81  */
82 INLINE const LPoint3 &CollisionSegment::
83 get_point_a() const {
84  return _a;
85 }
86 
87 /**
88  *
89  */
90 INLINE void CollisionSegment::
91 set_point_b(const LPoint3 &b) {
92  _b = b;
93  mark_internal_bounds_stale();
94  mark_viz_stale();
95  nassertv(_a != _b);
96 }
97 
98 /**
99  *
100  */
101 INLINE void CollisionSegment::
102 set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
103  set_point_b(LPoint3(x, y, z));
104 }
105 
106 /**
107  *
108  */
109 INLINE const LPoint3 &CollisionSegment::
110 get_point_b() const {
111  return _b;
112 }
113 
114 /**
115  * Accepts a LensNode and a 2-d point in the range [-1,1]. Sets the
116  * CollisionSegment so that it begins at the LensNode's near plane and extends
117  * to the far plane, making it suitable for picking objects from the screen
118  * given a camera and a mouse location.
119  */
120 INLINE bool CollisionSegment::
121 set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py) {
122  return set_from_lens(camera, LPoint2(px, py));
123 }
bool set_from_lens(LensNode *camera, const LPoint2 &point)
Accepts a LensNode and a 2-d point in the range [-1,1].
The abstract base class for all things that can collide with other things in the world,...
A node that contains a Lens.
Definition: lensNode.h:29
CollisionSegment()
Creates an invalid segment.
A finite line segment, with two specific endpoints but no thickness.