15 #include "collisionParabola.h" 16 #include "collisionEntry.h" 18 #include "datagramIterator.h" 19 #include "bamReader.h" 20 #include "bamWriter.h" 22 #include "geomLinestrips.h" 23 #include "geomVertexWriter.h" 24 #include "boundingHexahedron.h" 25 #include "boundingSphere.h" 29 "Collision Volumes:CollisionParabola");
31 "Collision Tests:CollisionParabola");
44 return _parabola.calc_point(_t1);
65 return entry.
get_into()->test_intersection_from_parabola(entry);
73 void CollisionParabola::
78 mark_internal_bounds_stale();
90 return _volume_pcollector;
102 return _test_pcollector;
110 void CollisionParabola::
111 output(ostream &out)
const {
112 out << _parabola <<
", t1 = " << _t1 <<
", t2 = " << _t2;
121 compute_internal_bounds()
const {
129 if (d2 < collision_parabola_bounds_threshold * collision_parabola_bounds_threshold) {
130 LPoint3 pmid = (p1 + p2) * 0.5f;
148 look_at(from_parabola, pdelta, -_parabola.get_a(), CS_zup_right);
157 LParabola psp = _parabola;
158 psp.xform(to_parabola);
161 PN_stdfloat max_y = pp2[1];
165 PN_stdfloat min_z = 0.0f;
166 PN_stdfloat max_z = 0.0f;
167 int num_points = collision_parabola_bounds_sample;
168 for (
int i = 0; i < num_points; ++i) {
169 double t = (double)(i + 1) / (double)(num_points + 1);
171 min_z = min(min_z, p[2]);
172 max_z = max(max_z, p[2]);
182 volume->xform(from_parabola);
192 void CollisionParabola::
194 if (collide_cat.is_debug()) {
196 <<
"Recomputing viz for " << *
this <<
"\n";
199 static const int num_points = 100;
202 (
"collision", GeomVertexFormat::get_v3cp(),
207 for (
int i = 0; i < num_points; i++) {
208 double t = ((double)i / (
double)num_points);
209 vertex.
add_data3(_parabola.calc_point(_t1 + t * (_t2 - _t1)));
212 t *
LColor(0.0f, 0.0f, 0.0f, 1.0f));
216 line->add_next_vertices(num_points);
217 line->close_primitive();
220 geom->add_primitive(line);
222 _viz_geom->add_geom(geom, get_other_viz_state());
223 _bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
245 _parabola.write_datagram(me);
261 parse_params(params, scan, manager);
262 me->fillin(scan, manager);
274 void CollisionParabola::
276 CollisionSolid::fillin(scan, manager);
277 _parabola.read_datagram(scan);
float length_squared() const
Returns the square of the vector's length, cheap and easy.
PN_stdfloat get_t1() const
Returns the starting point on the parabola.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
PN_stdfloat get_t2() const
Returns the ending point on the parabola.
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).
This defines a bounding sphere, consisting of a center and a radius.
virtual PStatCollector & get_volume_pcollector()
Returns a PStatCollector that is used to count the number of bounding volume tests made against a sol...
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.
void add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w)
Sets the write row to a particular 4-component value, and advances the write row. ...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A lightweight class that represents a single element that may be timed and/or counted via stats...
const CollisionSolid * get_into() const
Returns the CollisionSolid pointer for the particular solid was collided into.
This is a 4-by-4 transform matrix.
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...
bool invert_from(const LMatrix4f &other)
Computes the inverse of the other matrix, and stores the result in this matrix.
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. ...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
This is the base class for all three-component vectors and points.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
CollisionParabola()
Creates an invalid parabola.
This defines a parabolic arc, or subset of an arc, similar to the path of a projectile or falling obj...
Defines a series of line strips.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Function to write the important information in the particular object to a Datagram.
static void register_with_read_factory()
Factory method to generate a CollisionParabola object.
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. ...
virtual LPoint3 get_collision_origin() const
Returns the point in space deemed to be the "origin" of the solid for collision purposes.
TypeHandle is the identifier used to differentiate C++ class types.
virtual PStatCollector & get_test_pcollector()
Returns a PStatCollector that is used to count the number of intersection tests made against a solid ...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This defines a bounding convex hexahedron.