28 "Collision Volumes:CollisionParabola");
30 "Collision Tests:CollisionParabola");
40 return _parabola.calc_point(_t1);
57 return entry.
get_into()->test_intersection_from_parabola(entry);
63 void CollisionParabola::
64 xform(
const LMatrix4 &mat) {
68 mark_internal_bounds_stale();
77 return _volume_pcollector;
86 return _test_pcollector;
92 void CollisionParabola::
93 output(std::ostream &out)
const {
94 out << _parabola <<
", t1 = " << _t1 <<
", t2 = " << _t2;
101 compute_internal_bounds()
const {
102 LPoint3 p1 = _parabola.calc_point(
get_t1());
103 LPoint3 p2 = _parabola.calc_point(
get_t2());
104 LVector3 pdelta = p2 - p1;
107 PN_stdfloat d2 = pdelta.length_squared();
108 if (d2 < collision_parabola_bounds_threshold * collision_parabola_bounds_threshold) {
109 LPoint3 pmid = (p1 + p2) * 0.5f;
125 LMatrix4 from_parabola;
126 look_at(from_parabola, pdelta, -_parabola.get_a(), CS_zup_right);
127 from_parabola.set_row(3, p1);
131 LMatrix4 to_parabola;
132 to_parabola.invert_from(from_parabola);
135 LParabola psp = _parabola;
136 psp.xform(to_parabola);
138 LPoint3 pp2 = psp.calc_point(
get_t2());
139 PN_stdfloat max_y = pp2[1];
142 PN_stdfloat min_z = 0.0f;
143 PN_stdfloat max_z = 0.0f;
144 int num_points = collision_parabola_bounds_sample;
145 for (
int i = 0; i < num_points; ++i) {
146 double t = (double)(i + 1) / (double)(num_points + 1);
148 min_z = std::min(min_z, p[2]);
149 max_z = std::max(max_z, p[2]);
155 LPoint3(0.01, max_y, max_z), LPoint3(-0.01, max_y, max_z),
156 LPoint3(-0.01, 0, min_z), LPoint3(0.01, 0, min_z),
157 LPoint3(0.01, 0, max_z), LPoint3(-0.01, 0, max_z));
159 volume->xform(from_parabola);
167 void CollisionParabola::
169 if (collide_cat.is_debug()) {
171 <<
"Recomputing viz for " << *
this <<
"\n";
174 static const int num_points = 100;
182 for (
int i = 0; i < num_points; i++) {
183 double t = ((double)i / (
double)num_points);
184 vertex.add_data3(_parabola.calc_point(_t1 + t * (_t2 - _t1)));
186 color.add_data4(LColor(1.0f, 1.0f, 1.0f, 0.0f) +
187 t * LColor(0.0f, 0.0f, 0.0f, 1.0f));
191 line->add_next_vertices(num_points);
192 line->close_primitive();
195 geom->add_primitive(line);
197 _viz_geom->add_geom(geom, get_other_viz_state());
198 _bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
216 _parabola.write_datagram(me);
231 me->fillin(scan, manager);
240 void CollisionParabola::
242 CollisionSolid::fillin(scan, manager);
243 _parabola.read_datagram(scan);
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,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This defines a bounding convex hexahedron.
This defines a bounding sphere, consisting of a center and a radius.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
Defines a single collision event.
get_into
Returns the CollisionSolid pointer for the particular solid was collided into.
This defines a parabolic arc, or subset of an arc, similar to the path of a projectile or falling obj...
get_t1
Returns the starting point on the parabola.
static void register_with_read_factory()
Factory method to generate a CollisionParabola object.
virtual PStatCollector & get_test_pcollector()
Returns a PStatCollector that is used to count the number of intersection tests made against a solid ...
virtual PStatCollector & get_volume_pcollector()
Returns a PStatCollector that is used to count the number of bounding volume tests made against a sol...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Function to write the important information in the particular object to a Datagram.
get_t2
Returns the ending point on the parabola.
CollisionParabola()
Creates an invalid parabola.
virtual LPoint3 get_collision_origin() const
Returns the point in space deemed to be the "origin" of the solid for collision purposes.
The abstract base class for all things that can collide with other things in the world,...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
A class to retrieve the individual data elements previously stored in a Datagram.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Defines a series of line strips.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
A container for geometry primitives.
A lightweight class that represents a single element that may be timed and/or counted via stats.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PT(CollisionEntry) CollisionParabola
Transforms the solid by the indicated matrix.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.