diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 8697710b02d..2d9f4bbadf3 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -341,7 +341,7 @@ void KX_KetsjiEngine::RenderDome() m_rendertools->MotionBlur(m_rasterizer); scene->Render2DFilters(m_canvas); // no RunDrawingCallBacks - // no FlushDebugLines + // no FlushDebugShapes } m_dome->BindImages(i); } @@ -1336,7 +1336,7 @@ void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene) #ifndef DISABLE_PYTHON scene->RunDrawingCallbacks(scene->GetPostDrawCB()); #endif - m_rasterizer->FlushDebugLines(); + m_rasterizer->FlushDebugShapes(); } void KX_KetsjiEngine::StopEngine() diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp index bad38513167..3a2d27de911 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp @@ -246,13 +246,11 @@ void KX_ObstacleSimulation::DrawObstacles() { KX_RasterizerDrawDebugLine(m_obstacles[i]->m_pos, m_obstacles[i]->m_pos2, bluecolor); } -/* else if (m_obstacles[i]->m_shape==KX_OBSTACLE_CIRCLE) { KX_RasterizerDrawDebugCircle(m_obstacles[i]->m_pos, m_obstacles[i]->m_rad, bluecolor, normal.normalized(), SECTORS_NUM); - }*/ - + } } } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 0198555753e..4fbc63150ae 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -156,6 +156,13 @@ void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,cons gp_Rasterizer->DrawDebugLine(from,to,color); } +void KX_RasterizerDrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color, + const MT_Vector3& normal, int nsector) +{ + if (gp_Rasterizer) + gp_Rasterizer->DrawDebugCircle(center, radius, color, normal, nsector); +} + #ifndef DISABLE_PYTHON static PyObject *gp_OrigPythonSysPath= NULL; diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index fb59a2f21eb..d46776eb9da 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -71,6 +71,8 @@ class KX_KetsjiEngine* KX_GetActiveEngine(); #include "MT_Vector3.h" void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color); +void KX_RasterizerDrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color, + const MT_Vector3& normal, int nsector); #endif //__KX_PYTHON_INIT diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 3ffbfcd5a8a..e9aacadece3 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -386,7 +386,9 @@ public: virtual void SetPolygonOffset(float mult, float add) = 0; virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)=0; - virtual void FlushDebugLines()=0; + virtual void DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color, + const MT_Vector3& normal, int nsector)=0; + virtual void FlushDebugShapes()=0; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 122a738e4f3..bedddb748fe 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -50,6 +50,10 @@ #include "BKE_DerivedMesh.h" +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + /** * 32x32 bit masks for vinterlace stereo mode */ @@ -343,9 +347,9 @@ void RAS_OpenGLRasterizer::ClearCachingInfo(void) m_materialCachingInfo = 0; } -void RAS_OpenGLRasterizer::FlushDebugLines() +void RAS_OpenGLRasterizer::FlushDebugShapes() { - if(!m_debugLines.size()) + if(!m_debugShapes.size()) return; // DrawDebugLines @@ -357,29 +361,93 @@ void RAS_OpenGLRasterizer::FlushDebugLines() if(light) glDisable(GL_LIGHTING); if(tex) glDisable(GL_TEXTURE_2D); + //draw lines glBegin(GL_LINES); - for (unsigned int i=0;iEndFrame(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 6bbf65f72a4..fe63a854275 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -44,10 +44,15 @@ using namespace std; #define RAS_MAX_TEXCO 8 // match in BL_Material #define RAS_MAX_ATTRIB 16 // match in BL_BlenderShader -struct OglDebugLine +struct OglDebugShape { - MT_Vector3 m_from; - MT_Vector3 m_to; + enum SHAPE_TYPE{ + LINE, CIRCLE + }; + SHAPE_TYPE m_type; + MT_Vector3 m_pos; + MT_Vector3 m_param; + MT_Vector3 m_param2; MT_Vector3 m_color; }; @@ -249,18 +254,13 @@ public: virtual void SetPolygonOffset(float mult, float add); - virtual void FlushDebugLines(); + virtual void FlushDebugShapes(); + virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color); + virtual void DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color, + const MT_Vector3& normal, int nsector); - virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color) - { - OglDebugLine line; - line.m_from = from; - line.m_to = to; - line.m_color = color; - m_debugLines.push_back(line); - } - std::vector m_debugLines; + std::vector m_debugShapes; virtual void SetTexCoordNum(int num); virtual void SetAttribNum(int num);