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:
authorBenoit Bolsee <benoit.bolsee@online.be>2008-05-25 18:37:39 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2008-05-25 18:37:39 +0400
commitda1f38f99d3b8a07ed4ddd905f8e7d7c6e25f945 (patch)
tree71add2281425519cfd2c06e8d3d6e67cae2b83a7
parentf680b56ebfc1415334598e619ec9310ccce472c2 (diff)
Apply BGE patch 11137: Render objects with negative scaling correctly (as in Blender)
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp16
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.cpp16
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.h2
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h9
-rw-r--r--source/gameengine/Rasterizer/RAS_IRenderTools.h1
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.cpp2
8 files changed, 50 insertions, 1 deletions
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
index a656c5e5523..ffd66655069 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
@@ -125,6 +125,22 @@ void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty)
}
+void KX_BlenderRenderTools::SetClientObject(void* obj)
+{
+ if (m_clientobject != obj)
+ {
+ if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling())
+ {
+ glFrontFace(GL_CCW);
+ } else
+ {
+ glFrontFace(GL_CW);
+ }
+ m_clientobject = obj;
+ m_modified = true;
+ }
+}
+
bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
{
double* const oglmatrix = (double* const) data;
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
index 662f5bd9af1..31eaa14d66b 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
@@ -105,6 +105,8 @@ public:
virtual void Render2DFilters(RAS_ICanvas* canvas);
+ virtual void SetClientObject(void* obj);
+
};
#endif //__KX_BLENDERRENDERTOOLS
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
index edda7657ef9..885981a2898 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
@@ -462,6 +462,22 @@ int GPC_RenderTools::applyLights(int objectlayer)
}
+void GPC_RenderTools::SetClientObject(void* obj)
+{
+ if (m_clientobject != obj)
+ {
+ if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling())
+ {
+ glFrontFace(GL_CCW);
+ } else
+ {
+ glFrontFace(GL_CW);
+ }
+ m_clientobject = obj;
+ m_modified = true;
+ }
+}
+
bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
{
double* const oglmatrix = (double* const) data;
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
index 9b86869af73..ee0212da643 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
@@ -153,6 +153,8 @@ public:
virtual void Render2DFilters(RAS_ICanvas* canvas);
+ virtual void SetClientObject(void* obj);
+
protected:
/**
* Copied from KX_BlenderGL.cpp in KX_blenderhook
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 5fd5d2d5492..dada47e2fa4 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -77,6 +77,7 @@ KX_GameObject::KX_GameObject(
m_layer(0),
m_bSuspendDynamics(false),
m_bUseObjectColor(false),
+ m_bIsNegativeScaling(false),
m_bVisible(true),
m_pPhysicsController1(NULL),
m_pPhysicsEnvironment(NULL),
@@ -335,7 +336,7 @@ double* KX_GameObject::GetOpenGLMatrix()
trans.setBasis(GetSGNode()->GetWorldOrientation());
MT_Vector3 scaling = GetSGNode()->GetWorldScaling();
-
+ m_bIsNegativeScaling = ((scaling[0] < 0.0) ^ (scaling[1] < 0.0) ^ (scaling[2] < 0.0)) ? true : false;
trans.scale(scaling[0], scaling[1], scaling[2]);
trans.getValue(fl);
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index 6e765978821..3758651f53d 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -75,6 +75,7 @@ protected:
bool m_bSuspendDynamics;
bool m_bUseObjectColor;
+ bool m_bIsNegativeScaling;
MT_Vector4 m_objectColor;
// Is this object set to be visible? Only useful for the
@@ -599,6 +600,14 @@ public:
);
/**
+ * Get the negative scaling state
+ */
+ bool
+ IsNegativeScaling(
+ void
+ ) { return m_bIsNegativeScaling; }
+
+ /**
* @section Logic bubbling methods.
*/
diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h
index 16e15653c82..bcbf907741b 100644
--- a/source/gameengine/Rasterizer/RAS_IRenderTools.h
+++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h
@@ -146,6 +146,7 @@ public:
int layer
)=0;
+ virtual
void
SetClientObject(
void* obj
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
index 02e84f8a243..96ce220ae4d 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
@@ -325,6 +325,8 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans,
while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode))
RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode);
}
+ // to reset the eventual GL_CW mode
+ rendertools->SetClientObject(NULL);
}