mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-10-31 22:26:45 +00:00 
			
		
		
		
	shapes. It doesn't work in the case of spheres (used by projectiles):
resulting shape is malformed. It can also leads to this error which
makes the debug drawer non-working till game restart:
CullVisitor::apply(Geode&) detected NaN,
    depth=nan, center=(nan nan nan),
    matrix={
       -0.265814 -0.0639702 0.9619 0
       0.964024 -0.0176387 0.265228 0
       -4.29769e-09 0.997796 0.0663574 0
       18178.6 -3550.91 42154.4 1
}
Avoid this issue by using osg::Sphere
While here, remove an unused function. We don't use Bullet's solver so
we never have any contact points (in Bullet parlance).
		
	
			
		
			
				
	
	
		
			81 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #ifndef OPENMW_MWRENDER_BULLETDEBUGDRAW_H
 | |
| #define OPENMW_MWRENDER_BULLETDEBUGDRAW_H
 | |
| 
 | |
| #include <chrono>
 | |
| #include <vector>
 | |
| 
 | |
| #include <osg/ref_ptr>
 | |
| #include <osg/Array>
 | |
| #include <osg/PrimitiveSet>
 | |
| 
 | |
| #include <LinearMath/btIDebugDraw.h>
 | |
| 
 | |
| class btCollisionWorld;
 | |
| 
 | |
| namespace osg
 | |
| {
 | |
|     class Group;
 | |
|     class Geometry;
 | |
| }
 | |
| 
 | |
| namespace MWRender
 | |
| {
 | |
| 
 | |
| class DebugDrawer : public btIDebugDraw
 | |
| {
 | |
| private:
 | |
|     struct CollisionView
 | |
|     {
 | |
|         btVector3 mOrig;
 | |
|         btVector3 mEnd;
 | |
|         std::chrono::time_point<std::chrono::steady_clock> mCreated;
 | |
|         CollisionView(btVector3 orig, btVector3 normal) : mOrig(orig), mEnd(orig + normal * 20), mCreated(std::chrono::steady_clock::now()) {};
 | |
|     };
 | |
|     std::vector<CollisionView> mCollisionViews;
 | |
|     osg::ref_ptr<osg::Group> mShapesRoot;
 | |
| 
 | |
| protected:
 | |
|     osg::ref_ptr<osg::Group> mParentNode;
 | |
|     btCollisionWorld *mWorld;
 | |
|     osg::ref_ptr<osg::Geometry> mGeometry;
 | |
|     osg::ref_ptr<osg::Vec3Array> mVertices;
 | |
|     osg::ref_ptr<osg::Vec4Array> mColors;
 | |
|     osg::ref_ptr<osg::DrawArrays> mDrawArrays;
 | |
| 
 | |
|     bool mDebugOn;
 | |
| 
 | |
|     void createGeometry();
 | |
|     void destroyGeometry();
 | |
| 
 | |
| public:
 | |
| 
 | |
|     DebugDrawer(osg::ref_ptr<osg::Group> parentNode, btCollisionWorld *world, int debugMode = 1);
 | |
|     ~DebugDrawer();
 | |
| 
 | |
|     void step();
 | |
| 
 | |
|     void drawLine(const btVector3& from,const btVector3& to,const btVector3& color) override;
 | |
| 
 | |
|     void addCollision(const btVector3& orig, const btVector3& normal);
 | |
| 
 | |
|     void showCollisions();
 | |
| 
 | |
|     void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color) override {};
 | |
|     void drawSphere(btScalar radius, const btTransform& transform, const btVector3& color) override;
 | |
| 
 | |
|     void reportErrorWarning(const char* warningString) override;
 | |
| 
 | |
|     void draw3dText(const btVector3& location,const char* textString) override {}
 | |
| 
 | |
|     //0 for off, anything else for on.
 | |
|     void setDebugMode(int isOn) override;
 | |
| 
 | |
|     //0 for off, anything else for on.
 | |
|     int getDebugMode() const override;
 | |
| 
 | |
| };
 | |
| 
 | |
| 
 | |
| }
 | |
| 
 | |
| #endif
 |