50 return entry.
get_into()->test_intersection_from_segment(entry);
56 void CollisionSegment::
57 xform(
const LMatrix4 &mat) {
61 CollisionSolid::xform(mat);
77 void CollisionSegment::
78 output(std::ostream &out)
const {
79 out <<
"segment, a (" << _a <<
"), b (" << _b <<
")";
95 if (!proj->
extrude(point, _a, _b)) {
96 _a = LPoint3::origin();
97 _b = _a + LVector3::forward();
101 mark_internal_bounds_stale();
111 compute_internal_bounds()
const {
113 LVector3 pdelta = _b - _a;
116 PN_stdfloat d2 = pdelta.length_squared();
117 if (d2 < collision_parabola_bounds_threshold * collision_parabola_bounds_threshold) {
118 LPoint3 pmid = (_a + _b) * 0.5f;
122 LMatrix4 from_segment;
123 look_at(from_segment, pdelta, LPoint3(0,0,1), CS_zup_right);
124 from_segment.set_row(3, _a);
126 PN_stdfloat max_y = sqrt(d2) + 0.01;
129 LPoint3(0.01, max_y, 0.01), LPoint3(-0.01, max_y, 0.01),
130 LPoint3(-0.01, -0.01, -0.01), LPoint3(0.01, 0.01, -0.01),
131 LPoint3(0.01, -0.01, 0.01), LPoint3(-0.01, -0.01, 0.01));
133 volume->xform(from_segment);
141 void CollisionSegment::
143 if (collide_cat.is_debug()) {
145 <<
"Recomputing viz for " << *
this <<
"\n";
153 vertex.add_data3(_a);
154 vertex.add_data3(_b);
157 line->add_next_vertices(2);
158 line->close_primitive();
161 geom->add_primitive(line);
163 _viz_geom->add_geom(geom, get_other_viz_state());
164 _bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
182 _a.write_datagram(dg);
183 _b.write_datagram(dg);
198 node->fillin(scan, manager);
207 void CollisionSegment::
209 CollisionSolid::fillin(scan, manager);
210 _a.read_datagram(scan);
211 _b.read_datagram(scan);
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
bool set_from_lens(LensNode *camera, const LPoint2 &point)
Accepts a LensNode and a 2-d point in the range [-1,1].
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for any number of different kinds of lenses, linear and otherwise.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The abstract base class for all things that can collide with other things in the world,...
A node that contains a Lens.
CollisionSegment()
Creates an invalid segment.
This defines a bounding sphere, consisting of a center and a radius.
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
Lens * get_lens(int index=0) const
Returns a pointer to the particular Lens associated with this LensNode, or NULL if there is not yet a...
PT(CollisionEntry) CollisionSegment
Transforms the solid by the indicated matrix.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
A finite line segment, with two specific endpoints but no thickness.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Defines a single collision event.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A container for geometry primitives.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionSegment.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual LPoint3 get_collision_origin() const
Returns the point in space deemed to be the "origin" of the solid for collision purposes.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Defines a series of disconnected line segments.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
get_into
Returns the CollisionSolid pointer for the particular solid was collided into.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool extrude(const LPoint2 &point2d, LPoint3 &near_point, LPoint3 &far_point) const
Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (...
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This defines a bounding convex hexahedron.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.