diff options
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Converter/KX_BlenderSceneConverter.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/Converter/KX_ConvertControllers.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/GameLogic/SCA_RandomActuator.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_Material.h | 3 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_Shader.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 13 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp | 5 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_IPolygonMaterial.h | 4 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/VideoTexture/Exception.cpp | 2 |
13 files changed, 40 insertions, 11 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index aa11e78077a..4daed538b39 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -350,6 +350,8 @@ bool ConvertMaterial( // use lighting? material->ras_mode |= ( mat->mode & MA_SHLESS )?0:USE_LIGHT; + // cast shadows? + material->ras_mode |= ( mat->mode & MA_SHADBUF )?CAST_SHADOW:0; MTex *mttmp = 0; numchan = getNumTexChannels(mat); int valid_index = 0; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 8f17cd0391b..ffb9a8ce691 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -1083,7 +1083,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha * most are temp and NewRemoveObject frees m_map_gameobject_to_blender */ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) { - int maggie_index; + int maggie_index= -1; int i=0; if(maggie==NULL) @@ -1101,6 +1101,10 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) i++; } + /* should never happen but just to be safe */ + if(maggie_index == -1) + return false; + m_DynamicMaggie.erase(m_DynamicMaggie.begin() + maggie_index); tag_main(maggie, 1); diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 98afc3a690a..fafaaf5cef6 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -210,7 +210,11 @@ void BL_ConvertControllers( CIntValue* uniqueval = new CIntValue(uniqueint); uniquename += uniqueval->GetText(); uniqueval->Release(); - gamecontroller->SetName(uniquename); + //unique name was never implemented for sensors and actuators, only for controllers + //and it's producing difference in the keys for the lists: obj.controllers/sensors/actuators + //at some point it should either be implemented globally (and saved as a separate var) or removed. + //gamecontroller->SetName(uniquename); + gamecontroller->SetName(bcontr->name); gameobj->AddController(gamecontroller); converter->RegisterGameController(gamecontroller, bcontr); diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 3a6b00198e1..d76f3f775a5 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -152,7 +152,7 @@ bool SCA_RandomActuator::Update() /* If x_1, x_2, ... is a sequence of random numbers with uniform */ /* distribution between zero and one, k is the first integer for */ /* which the product x_1*x_2*...*x_k < exp(-\lamba). */ - float a = 0.0, b = 0.0; + float a, b; int res = 0; /* The - sign is important here! The number to test for, a, must be */ /* between 0 and 1. */ diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index ef25c9218a3..c0440e66501 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -157,7 +157,8 @@ enum BL_ras_mode ALPHA=8, // TRIANGLE=16, USE_LIGHT=32, - WIRE=64 + WIRE=64, + CAST_SHADOW=128 }; // ------------------------------------- diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 621cabfe0cf..aea33246a3f 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -690,7 +690,7 @@ void BL_Shader::SetUniform(int uniform, const MT_Matrix3x3& vec, bool transpose) float value[9]; value[0] = (float)vec[0][0]; value[1] = (float)vec[1][0]; value[2] = (float)vec[2][0]; value[3] = (float)vec[0][1]; value[4] = (float)vec[1][1]; value[5] = (float)vec[2][1]; - value[6] = (float)vec[0][2]; value[7] = (float)vec[1][2]; value[7] = (float)vec[2][2]; + value[6] = (float)vec[0][2]; value[7] = (float)vec[1][2]; value[8] = (float)vec[2][2]; glUniformMatrix3fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); } } diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 9ff32ba57c5..4226896aec0 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -85,6 +85,7 @@ void KX_BlenderMaterial::Initialize( m_flag |= (mMaterial->IdMode>=ONETEX)? RAS_MULTITEX: 0; m_flag |= ((mMaterial->ras_mode & USE_LIGHT)!=0)? RAS_MULTILIGHT: 0; m_flag |= (mMaterial->glslmat)? RAS_BLENDERGLSL: 0; + m_flag |= ((mMaterial->ras_mode & CAST_SHADOW)!=0)? RAS_CASTSHADOW: 0; // figure max int enabled = mMaterial->num_enabled; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 0864fc84a28..d51e2aa5386 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1917,7 +1917,7 @@ PyObject* KX_GameObject::pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBU { KX_GameObject* self= static_cast<KX_GameObject*>(self_v); KX_IPhysicsController *spc = self->GetPhysicsController(); - return PyFloat_FromDouble(spc ? spc->GetLinVelocityMax() : 0.0f); + return PyFloat_FromDouble(spc ? spc->GetLinVelocityMin() : 0.0f); } int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 620f46e743e..b1a214b7c1c 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -886,6 +886,8 @@ void KX_KetsjiEngine::Render() { if((*it)->GetViewport()) { + // Change the active camera so Python scripts can figure out what viewport they're in + scene->SetActiveCamera(*it); if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); @@ -897,6 +899,10 @@ void KX_KetsjiEngine::Render() it++; } + + // Now change the camera back + scene->SetActiveCamera(cam); + PostRenderScene(scene); } @@ -1316,6 +1322,10 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) if (scene->GetPhysicsEnvironment()) scene->GetPhysicsEnvironment()->debugDrawWorld(); + +#ifdef WITH_PYTHON + scene->RunDrawingCallbacks(scene->GetPostDrawCB()); +#endif } void KX_KetsjiEngine::RenderFonts(KX_Scene* scene) @@ -1337,9 +1347,6 @@ void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene) { m_rendertools->MotionBlur(m_rasterizer); scene->Render2DFilters(m_canvas); -#ifdef WITH_PYTHON - scene->RunDrawingCallbacks(scene->GetPostDrawCB()); -#endif m_rasterizer->FlushDebugLines(); } diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index 47f1dcb412a..5a1b52489b4 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -246,6 +246,11 @@ bool RAS_IPolyMaterial::UsesLighting(RAS_IRasterizer *rasty) const return dolights; } +bool RAS_IPolyMaterial::CastsShadows() const +{ + return (m_flag & RAS_CASTSHADOW) != 0; +} + bool RAS_IPolyMaterial::UsesObjectColor() const { return !(m_flag & RAS_BLENDERGLSL); diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index b0e7daf81d7..2a5c6a179b6 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -62,7 +62,8 @@ enum MaterialProps RAS_AUTOGEN =128, RAS_NORMAL =256, RAS_DEFMULTI =512, - RAS_BLENDERGLSL =1024 + RAS_BLENDERGLSL =1024, + RAS_CASTSHADOW =2048 }; /** @@ -169,6 +170,7 @@ public: virtual void GetMaterialRGBAColor(unsigned char *rgba) const; virtual bool UsesLighting(RAS_IRasterizer *rasty) const; virtual bool UsesObjectColor() const; + virtual bool CastsShadows() const; virtual void Replace_IScene(SCA_IScene *val) {}; /* overridden by KX_BlenderMaterial */ diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 7647f7d3f27..85284096bb9 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -586,6 +586,9 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I RAS_IRenderTools *rendertools) { bool uselights; + + if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && !m_material->CastsShadows()) + return false; if(!rasty->SetMaterial(*m_material)) return false; diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index 8c8258585a5..fc316f1c3f0 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -105,7 +105,7 @@ Exception::Exception (ExceptionID & expID, RESULT rslt, const char * fil, int li : m_expID (&expID), m_hRslt (rslt) { // set file and line - if (strlen(fil) > 0 || lin > 0) + if (fil[0] != '\0' || lin > 0) setFileLine (fil, lin); } |