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);