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>2011-01-23 20:17:21 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2011-01-23 20:17:21 +0300
commitfc66b3f2efcb5b7579f06c1966900b2ecf3c1310 (patch)
tree029fa673af575ff1f3fce63e49c29fa2359be360 /source/gameengine/Rasterizer
parentfa38da021cd08409f1bda4722a6cf8a607f86838 (diff)
BGE: support modifiers without mapping to original mesh both graphically and physically, fixes bug #24942 and #25286.
Support for physics is done by skiping the modifiers that don't support mapping to original mesh. This mapping is required to report the hit polygon to the application by the rayCast() function. Support for graphics is done by using the same render function that blender uses for the 3D view. This guantees equal result. Limitation: there is still a known bug if all these conditions are met: - Display list enabled - Old tex face with a several textures mapped to the same material - no armature or shape keys - active modifiers In this case, only a part of the mesh will be rendered with the wrong texture. To avoid this bug, use the GLSL materials or make sure to have 1 material=1 texture in your old tex face objects.
Diffstat (limited to 'source/gameengine/Rasterizer')
-rw-r--r--source/gameengine/Rasterizer/RAS_Deformer.h4
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp5
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.h2
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp33
4 files changed, 43 insertions, 1 deletions
diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h
index f61ac7ea18a..37543092e68 100644
--- a/source/gameengine/Rasterizer/RAS_Deformer.h
+++ b/source/gameengine/Rasterizer/RAS_Deformer.h
@@ -76,6 +76,10 @@ public:
{
return NULL;
}
+ virtual struct DerivedMesh* GetPhysicsMesh()
+ {
+ return NULL;
+ }
virtual class RAS_MeshObject* GetRasMesh()
{
/* m_pMesh does not seem to be being used?? */
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
index 0c81d7d8274..00f1f5f2848 100644
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
+++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
@@ -208,6 +208,11 @@ Material *RAS_IPolyMaterial::GetBlenderMaterial() const
return NULL;
}
+Image *RAS_IPolyMaterial::GetBlenderImage() const
+{
+ return NULL;
+}
+
Scene* RAS_IPolyMaterial::GetBlenderScene() const
{
return NULL;
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
index e7bd78c2309..59554e31c36 100644
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
+++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
@@ -45,6 +45,7 @@
class RAS_IRasterizer;
struct MTFace;
struct Material;
+struct Image;
struct Scene;
class SCA_IScene;
@@ -160,6 +161,7 @@ public:
int GetMaterialIndex() const;
virtual Material* GetBlenderMaterial() const;
+ virtual Image* GetBlenderImage() const;
virtual Scene* GetBlenderScene() const;
virtual void ReleaseMaterial();
virtual void GetMaterialRGBAColor(unsigned char *rgba) const;
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index e8c2db5526a..c2859394176 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -731,6 +731,7 @@ static RAS_MeshSlot *current_ms;
static RAS_MeshObject *current_mesh;
static int current_blmat_nr;
static GPUVertexAttribs current_gpu_attribs;
+static Image *current_image;
static int CheckMaterialDM(int matnr, void *attribs)
{
// only draw the current material
@@ -769,6 +770,33 @@ static int CheckTexfaceDM(void *mcol, int index)
return 0;
}
+static int CheckTexDM(MTFace *tface, MCol *mcol, int matnr)
+{
+
+ // index is the original face index, retrieve the polygon
+ if (matnr == current_blmat_nr &&
+ (tface == NULL || tface->tpage == current_image)) {
+ // must handle color.
+ if (current_wireframe)
+ return 2;
+ if (current_ms->m_bObjectColor) {
+ MT_Vector4& rgba = current_ms->m_RGBAcolor;
+ glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
+ // don't use mcol
+ return 2;
+ }
+ if (!mcol) {
+ // we have to set the color from the material
+ unsigned char rgba[4];
+ current_polymat->GetMaterialRGBAColor(rgba);
+ glColor4ubv((const GLubyte *)rgba);
+ return 2;
+ }
+ return 1;
+ }
+ return 0;
+}
+
void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
{
bool obcolor = ms.m_bObjectColor;
@@ -807,7 +835,10 @@ void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
ms.m_pDerivedMesh->drawFacesGLSL(ms.m_pDerivedMesh, CheckMaterialDM);
GPU_set_material_blend_mode(current_blend_mode);
} else {
- ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol);
+ //ms.m_pDerivedMesh->drawMappedFacesTex(ms.m_pDerivedMesh, CheckTexfaceDM, mcol);
+ current_blmat_nr = current_polymat->GetMaterialIndex();
+ current_image = current_polymat->GetBlenderImage();
+ ms.m_pDerivedMesh->drawFacesTex(ms.m_pDerivedMesh, CheckTexDM);
}
return;
}