From f1cb508349b919be05c99bbf07c4a3104428d9a0 Mon Sep 17 00:00:00 2001 From: Zachary Pavlov Date: Wed, 28 Apr 2010 01:57:32 +0000 Subject: [PATCH] using a hexy to keep the segment non-axis-aligned --- panda/src/collide/collisionSegment.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/panda/src/collide/collisionSegment.cxx b/panda/src/collide/collisionSegment.cxx index f4e9dc517e..78c97d8031 100644 --- a/panda/src/collide/collisionSegment.cxx +++ b/panda/src/collide/collisionSegment.cxx @@ -28,6 +28,7 @@ #include "bamWriter.h" #include "geom.h" #include "geomLines.h" +#include "boundingHexahedron.h" #include "geomVertexWriter.h" TypeHandle CollisionSegment::_type_handle; @@ -135,10 +136,20 @@ compute_internal_bounds() const { LPoint3f pmid = (_a + _b) * 0.5f; return new BoundingSphere(pmid, csqrt(d2) * 0.5f); } - LPoint3f min_p(min(_a[0], _b[0]) - .01, min(_a[1], _b[1]) - .01, min(_a[2],_b[2]) - .01); - LPoint3f max_p(max(_a[0], _b[0]) + .01, max(_a[1], _b[1]) + .01, max(_a[2],_b[2]) + .01); + + LMatrix4f from_segment; + look_at(from_segment, pdelta, LPoint3f(0,0,1), CS_zup_right); + from_segment.set_row(3, _a); - return new BoundingBox(min_p, max_p); + float max_y = sqrt(d2) + 0.01; + PT(BoundingHexahedron) volume = + new BoundingHexahedron(LPoint3f(-0.01, max_y, -0.01), LPoint3f(0.01, max_y, -0.01), + LPoint3f(0.01, max_y, 0.01), LPoint3f(-0.01, max_y, 0.01), + LPoint3f(-0.01, -0.01, -0.01), LPoint3f(0.01, 0.01, -0.01), + LPoint3f(0.01, -0.01, 0.01), LPoint3f(-0.01, -0.01, 0.01)); + + volume->xform(from_segment); + return volume.p(); } ////////////////////////////////////////////////////////////////////