Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2015-07-27 11:58:19 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2015-07-27 14:49:06 +0300
commit76beb7b7d4d3e8777b3cbf9eb0f85f991dd147bc (patch)
tree322ac5e13d182204a7c53e86c0802c9dfb4338e5 /source/gameengine/Rasterizer
parentba146899c8ff40f61819265082781ef4048c631f (diff)
BGE: Fix T19241: draw debug shape with overlay/background scene.
It's for the function render.drawLine and physics debug.
Diffstat (limited to 'source/gameengine/Rasterizer')
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h9
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp35
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h16
3 files changed, 30 insertions, 30 deletions
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
index aadecd56992..7fbaf076d25 100644
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h
@@ -54,6 +54,7 @@ class RAS_ICanvas;
class RAS_IPolyMaterial;
class RAS_MeshSlot;
class RAS_ILightObject;
+class SCA_IScene;
typedef vector<unsigned short> KX_IndexArray;
typedef vector<RAS_TexVert> KX_VertexArray;
@@ -384,10 +385,10 @@ 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 DrawDebugCircle(const MT_Vector3 &center, const MT_Scalar radius, const MT_Vector3 &color,
- const MT_Vector3 &normal, int nsector) = 0;
- virtual void FlushDebugShapes() = 0;
+ virtual void DrawDebugLine(SCA_IScene *scene, const MT_Vector3 &from, const MT_Vector3 &to, const MT_Vector3& color) = 0;
+ virtual void DrawDebugCircle(SCA_IScene *scene, const MT_Vector3 &center, const MT_Scalar radius,
+ const MT_Vector3 &color, const MT_Vector3 &normal, int nsector) = 0;
+ virtual void FlushDebugShapes(SCA_IScene *scene) = 0;
virtual void SetTexCoordNum(int num) = 0;
virtual void SetAttribNum(int num) = 0;
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 5b7b752ee98..269cd7dec0a 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -356,9 +356,10 @@ void RAS_OpenGLRasterizer::ClearCachingInfo(void)
m_materialCachingInfo = 0;
}
-void RAS_OpenGLRasterizer::FlushDebugShapes()
+void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene)
{
- if (m_debugShapes.empty())
+ std::vector<OglDebugShape> &debugShapes = m_debugShapes[scene];
+ if (debugShapes.empty())
return;
// DrawDebugLines
@@ -372,28 +373,26 @@ void RAS_OpenGLRasterizer::FlushDebugShapes()
//draw lines
glBegin(GL_LINES);
- for (unsigned int i=0;i<m_debugShapes.size();i++)
- {
- if (m_debugShapes[i].m_type != OglDebugShape::LINE)
+ for (unsigned int i = 0; i < debugShapes.size(); i++) {
+ if (debugShapes[i].m_type != OglDebugShape::LINE)
continue;
- glColor4f(m_debugShapes[i].m_color[0],m_debugShapes[i].m_color[1],m_debugShapes[i].m_color[2],1.f);
- const MT_Scalar* fromPtr = &m_debugShapes[i].m_pos.x();
- const MT_Scalar* toPtr= &m_debugShapes[i].m_param.x();
+ glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f);
+ const MT_Scalar *fromPtr = &debugShapes[i].m_pos.x();
+ const MT_Scalar *toPtr= &debugShapes[i].m_param.x();
glVertex3dv(fromPtr);
glVertex3dv(toPtr);
}
glEnd();
//draw circles
- for (unsigned int i=0;i<m_debugShapes.size();i++)
- {
- if (m_debugShapes[i].m_type != OglDebugShape::CIRCLE)
+ for (unsigned int i = 0; i < debugShapes.size(); i++) {
+ if (debugShapes[i].m_type != OglDebugShape::CIRCLE)
continue;
glBegin(GL_LINE_LOOP);
- glColor4f(m_debugShapes[i].m_color[0],m_debugShapes[i].m_color[1],m_debugShapes[i].m_color[2],1.f);
+ glColor4f(debugShapes[i].m_color[0], debugShapes[i].m_color[1], debugShapes[i].m_color[2], 1.0f);
static const MT_Vector3 worldUp(0.0, 0.0, 1.0);
- MT_Vector3 norm = m_debugShapes[i].m_param;
+ MT_Vector3 norm = debugShapes[i].m_param;
MT_Matrix3x3 tr;
if (norm.fuzzyZero() || norm == worldUp)
{
@@ -408,14 +407,14 @@ void RAS_OpenGLRasterizer::FlushDebugShapes()
yaxis.x(), yaxis.y(), yaxis.z(),
norm.x(), norm.y(), norm.z());
}
- MT_Scalar rad = m_debugShapes[i].m_param2.x();
- int n = (int) m_debugShapes[i].m_param2.y();
+ MT_Scalar rad = debugShapes[i].m_param2.x();
+ int n = (int)debugShapes[i].m_param2.y();
for (int j = 0; j<n; j++)
{
MT_Scalar theta = j*M_PI*2/n;
MT_Vector3 pos(cos(theta) * rad, sin(theta) * rad, 0.0);
pos = pos*tr;
- pos += m_debugShapes[i].m_pos;
+ pos += debugShapes[i].m_pos;
const MT_Scalar* posPtr = &pos.x();
glVertex3dv(posPtr);
}
@@ -425,13 +424,11 @@ void RAS_OpenGLRasterizer::FlushDebugShapes()
if (light) glEnable(GL_LIGHTING);
if (tex) glEnable(GL_TEXTURE_2D);
- m_debugShapes.clear();
+ debugShapes.clear();
}
void RAS_OpenGLRasterizer::EndFrame()
{
- FlushDebugShapes();
-
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDisable(GL_MULTISAMPLE_ARB);
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
index b034315e3d6..ad49ebe5179 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
@@ -38,6 +38,7 @@
#include "MT_CmMatrix4x4.h"
#include <vector>
+#include <map>
using namespace std;
#include "RAS_IRasterizer.h"
@@ -223,20 +224,20 @@ public:
virtual void SetPolygonOffset(float mult, float add);
- virtual void FlushDebugShapes();
+ virtual void FlushDebugShapes(SCA_IScene *scene);
- virtual void DrawDebugLine(const MT_Vector3 &from,const MT_Vector3 &to, const MT_Vector3 &color)
+ virtual void DrawDebugLine(SCA_IScene *scene, const MT_Vector3 &from,const MT_Vector3 &to, const MT_Vector3 &color)
{
OglDebugShape line;
line.m_type = OglDebugShape::LINE;
line.m_pos= from;
line.m_param = to;
line.m_color = color;
- m_debugShapes.push_back(line);
+ m_debugShapes[scene].push_back(line);
}
- virtual void DrawDebugCircle(const MT_Vector3 &center, const MT_Scalar radius, const MT_Vector3 &color,
- const MT_Vector3 &normal, int nsector)
+ virtual void DrawDebugCircle(SCA_IScene *scene, const MT_Vector3 &center, const MT_Scalar radius,
+ const MT_Vector3 &color, const MT_Vector3 &normal, int nsector)
{
OglDebugShape line;
line.m_type = OglDebugShape::CIRCLE;
@@ -245,10 +246,11 @@ public:
line.m_color = color;
line.m_param2.x() = radius;
line.m_param2.y() = (float) nsector;
- m_debugShapes.push_back(line);
+ m_debugShapes[scene].push_back(line);
}
- std::vector <OglDebugShape> m_debugShapes;
+ // We store each debug shape by scene.
+ std::map<SCA_IScene *, std::vector<OglDebugShape> > m_debugShapes;
virtual void SetTexCoordNum(int num);
virtual void SetAttribNum(int num);