From a1b0bfd01871203b0a4da585585c627eaf9fd723 Mon Sep 17 00:00:00 2001 From: enn0x Date: Wed, 3 Aug 2011 22:29:55 +0000 Subject: [PATCH] Bullet debug node now considers absolute transform. --- panda/src/bullet/bulletBodyNode.cxx | 3 +++ panda/src/bullet/bulletDebugNode.cxx | 18 ++++++++++-------- panda/src/bullet/bulletTriangleMesh.cxx | 10 ---------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 43da97f9e7..2c204403ac 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -188,6 +188,9 @@ add_shape(BulletShape *shape, CPT(TransformState) xform) { nassertv(get_object()); + nassertv(!(shape->ptr()->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE + && ((btConvexHullShape *)shape->ptr())->getNumVertices() == 0)); + // Transform btTransform trans; if (xform) { diff --git a/panda/src/bullet/bulletDebugNode.cxx b/panda/src/bullet/bulletDebugNode.cxx index 20c5be14a7..4a29d0be0c 100644 --- a/panda/src/bullet/bulletDebugNode.cxx +++ b/panda/src/bullet/bulletDebugNode.cxx @@ -198,6 +198,11 @@ post_step(btDynamicsWorld *world) { // Collect debug geometry data world->debugDrawWorld(); + // Get inverse of this node's net transform + NodePath np = NodePath::any_path(this); + LMatrix4f m = np.get_net_transform()->get_mat(); + m.invert_in_place(); + // Render collected data _prim_lines->clear_vertices(); _prim_triangles->clear_vertices(); @@ -213,31 +218,29 @@ post_step(btDynamicsWorld *world) { for (lit = _drawer._lines.begin(); lit != _drawer._lines.end(); lit++) { Line line = *lit; - vwriter.add_data3f(line._p0); + vwriter.add_data3f(m.xform_point(line._p0)); + vwriter.add_data3f(m.xform_point(line._p1)); cwriter.add_data4f(line._color); - vwriter.add_data3f(line._p1); cwriter.add_data4f(line._color); _prim_lines->add_vertex(v++); _prim_lines->add_vertex(v++); - _prim_lines->close_primitive(); } for (tit = _drawer._triangles.begin(); tit != _drawer._triangles.end(); tit++) { Triangle tri = *tit; - vwriter.add_data3f(tri._p0); + vwriter.add_data3f(m.xform_point(tri._p0)); + vwriter.add_data3f(m.xform_point(tri._p1)); + vwriter.add_data3f(m.xform_point(tri._p2)); cwriter.add_data4f(tri._color); - vwriter.add_data3f(tri._p1); cwriter.add_data4f(tri._color); - vwriter.add_data3f(tri._p2); cwriter.add_data4f(tri._color); _prim_triangles->add_vertex(v++); _prim_triangles->add_vertex(v++); _prim_triangles->add_vertex(v++); - _prim_triangles->close_primitive(); } @@ -246,7 +249,6 @@ post_step(btDynamicsWorld *world) { _drawer._triangles.clear(); // Force recompute of bounds - NodePath np = NodePath::any_path(this); np.force_recompute_bounds(); } diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 35e040358f..e340260132 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -205,16 +205,6 @@ write(ostream &out, int indent_level) const { indent(out, indent_level + 4) << "num triangles:" << meshPart.m_numTriangles << endl; indent(out, indent_level + 4) << "num vertices:" << meshPart.m_numVertices << endl; - - // TODO print imesh info... -/* -int m_numTriangles -const unsigned char * m_triangleIndexBase -int m_triangleIndexStride -int m_numVertices -const unsigned char * m_vertexBase -int m_vertexStride -*/ } }