16 #include "collisionSegment.h" 17 #include "collisionHandler.h" 18 #include "collisionEntry.h" 19 #include "config_collide.h" 24 #include "geometricBoundingVolume.h" 26 #include "datagramIterator.h" 27 #include "bamReader.h" 28 #include "bamWriter.h" 30 #include "geomLines.h" 31 #include "boundingSphere.h" 32 #include "boundingHexahedron.h" 33 #include "geomVertexWriter.h" 56 return entry.
get_into()->test_intersection_from_segment(entry);
64 void CollisionSegment::
69 CollisionSolid::xform(mat);
90 void CollisionSegment::
91 output(ostream &out)
const {
92 out <<
"segment, a (" << _a <<
"), b (" << _b <<
")";
112 if (!proj->
extrude(point, _a, _b)) {
118 mark_internal_bounds_stale();
130 compute_internal_bounds()
const {
137 if (d2 < collision_parabola_bounds_threshold * collision_parabola_bounds_threshold) {
138 LPoint3 pmid = (_a + _b) * 0.5f;
143 look_at(from_segment, pdelta,
LPoint3(0,0,1), CS_zup_right);
146 PN_stdfloat max_y = sqrt(d2) + 0.01;
153 volume->xform(from_segment);
163 void CollisionSegment::
165 if (collide_cat.is_debug()) {
167 <<
"Recomputing viz for " << *
this <<
"\n";
171 (
"collision", GeomVertexFormat::get_v3cp(),
179 line->add_next_vertices(2);
180 line->close_primitive();
183 geom->add_primitive(line);
185 _viz_geom->add_geom(geom, get_other_viz_state());
186 _bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
227 parse_params(params, scan, manager);
228 node->fillin(scan, manager);
240 void CollisionSegment::
242 CollisionSolid::fillin(scan, manager);
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
float length_squared() const
Returns the square of the vector's length, cheap and easy.
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...
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...
void read_datagram(DatagramIterator &source)
Reads the vector from the Datagram using get_stdfloat().
The abstract base class for all things that can collide with other things in the world, and all the things they can collide with (except geometry).
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.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
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.
static const LPoint3f & origin(CoordinateSystem cs=CS_default)
Returns the origin of the indicated coordinate system.
static LVector3f forward(CoordinateSystem cs=CS_default)
Returns the forward vector for the given coordinate system.
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...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A finite line segment, with two specific endpoints but no thickness.
const CollisionSolid * get_into() const
Returns the CollisionSolid pointer for the particular solid was collided into.
This is a 4-by-4 transform matrix.
void write_datagram(Datagram &destination) const
Writes the vector to the Datagram using add_stdfloat().
Defines a single collision event.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row. ...
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionSegment.
virtual LPoint3 get_collision_origin() const
Returns the point in space deemed to be the "origin" of the solid for collision purposes.
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
Defines a series of disconnected line segments.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
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 (...
void set_row(int row, const LVecBase4f &v)
Replaces the indicated row of the matrix.
A class to retrieve the individual data elements previously stored in a Datagram. ...
This is a two-component point in space.
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 ...
This defines a bounding convex hexahedron.