From a0b8d5758da60e4ee74dd601533e098462125d04 Mon Sep 17 00:00:00 2001 From: enn0x Date: Sat, 20 Aug 2011 11:54:39 +0000 Subject: [PATCH] Replace BulletDebugNode.setVerbose with setters for individual debug components (wireframe, bounding boxes, constraints, normals) --- panda/src/bullet/bulletDebugNode.I | 38 +++++++++++++++++++++----- panda/src/bullet/bulletDebugNode.cxx | 40 ++++++++++++++++++---------- panda/src/bullet/bulletDebugNode.h | 12 ++++++--- 3 files changed, 65 insertions(+), 25 deletions(-) diff --git a/panda/src/bullet/bulletDebugNode.I b/panda/src/bullet/bulletDebugNode.I index c30ae30c59..66f994bd4b 100644 --- a/panda/src/bullet/bulletDebugNode.I +++ b/panda/src/bullet/bulletDebugNode.I @@ -23,25 +23,49 @@ INLINE BulletDebugNode:: } //////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::set_verbose +// Function: BulletDebugNode::show_wireframe // Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE void BulletDebugNode:: -set_verbose(bool verbose) { +show_wireframe(bool show) { - _verbose = verbose; + _wireframe = show; draw_mask_changed(); } //////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::get_verbose +// Function: BulletDebugNode::show_constraints // Access: Published // Description: //////////////////////////////////////////////////////////////////// -INLINE bool BulletDebugNode:: -get_verbose() const { +INLINE void BulletDebugNode:: +show_constraints(bool show) { - return _verbose; + _constraints = show; + draw_mask_changed(); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletDebugNode::show_bounding_boxes +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletDebugNode:: +show_bounding_boxes(bool show) { + + _bounds = show; + draw_mask_changed(); +} + +//////////////////////////////////////////////////////////////////// +// Function: BulletDebugNode::show_normals +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void BulletDebugNode:: +show_normals(bool show) { + + _drawer._normals = show; } diff --git a/panda/src/bullet/bulletDebugNode.cxx b/panda/src/bullet/bulletDebugNode.cxx index b886482aed..91bc463475 100644 --- a/panda/src/bullet/bulletDebugNode.cxx +++ b/panda/src/bullet/bulletDebugNode.cxx @@ -26,7 +26,12 @@ TypeHandle BulletDebugNode::_type_handle; // Description: //////////////////////////////////////////////////////////////////// BulletDebugNode:: -BulletDebugNode(const char *name) : GeomNode(name), _verbose(false) { +BulletDebugNode(const char *name) : GeomNode(name) { + + _wireframe = true; + _constraints = true; + _bounds = false; + _drawer._normals = true; _vdata = new GeomVertexData("", GeomVertexFormat::get_v3c4(), Geom::UH_stream); @@ -167,21 +172,24 @@ draw_mask_changed() { _drawer.setDebugMode(DebugDraw::DBG_NoDebug); } else { - if (_verbose) { - _drawer.setDebugMode(DebugDraw::DBG_DrawWireframe | - DebugDraw::DBG_DrawAabb | - DebugDraw::DBG_DrawText | - DebugDraw::DBG_DrawFeaturesText | - DebugDraw::DBG_DrawContactPoints | - DebugDraw::DBG_DrawConstraints | - DebugDraw::DBG_DrawConstraintLimits); - } - else { - _drawer.setDebugMode(DebugDraw::DBG_DrawWireframe | - DebugDraw::DBG_DrawConstraints | - DebugDraw::DBG_FastWireframe); + int mode = DebugDraw::DBG_DrawText | + DebugDraw::DBG_DrawFeaturesText | + DebugDraw::DBG_DrawContactPoints; + if (_wireframe) { + mode |= DebugDraw::DBG_DrawWireframe; } + + if (_constraints) { + mode |= DebugDraw::DBG_DrawConstraints; + mode |= DebugDraw::DBG_DrawConstraintLimits; + } + + if (_bounds) { + mode |= DebugDraw::DBG_DrawAabb; + } + + _drawer.setDebugMode(mode); } } @@ -297,6 +305,10 @@ drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color) { float g = color.getY(); float b = color.getZ(); + // Hack to get rid of triangle normals. The hack is based on the + // assumption that only normals are drawn in yellow. + if (_normals==false && r==1.0f && g==1.0f && b==0.0f) return; + Line line; line._p0 = LVecBase3f(from.getX(), from.getY(), from.getZ()); diff --git a/panda/src/bullet/bulletDebugNode.h b/panda/src/bullet/bulletDebugNode.h index 167f8cc4cd..e73a8fbb46 100644 --- a/panda/src/bullet/bulletDebugNode.h +++ b/panda/src/bullet/bulletDebugNode.h @@ -37,8 +37,10 @@ PUBLISHED: virtual void draw_mask_changed(); - INLINE void set_verbose(bool verbose); - INLINE bool get_verbose() const; + INLINE void show_wireframe(bool show); + INLINE void show_constraints(bool show); + INLINE void show_bounding_boxes(bool show); + INLINE void show_normals(bool show); public: virtual bool safe_to_flatten() const; @@ -91,13 +93,15 @@ private: pvector _lines; pvector _triangles; - private: + bool _normals; int _mode; }; DebugDraw _drawer; - bool _verbose; + bool _wireframe; + bool _constraints; + bool _bounds; PT(GeomVertexData) _vdata; PT(Geom) _geom_lines;