diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-05 20:56:44 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2008-05-05 20:56:44 +0400 |
commit | ec906913842a9b56805b010153295419f198ed6a (patch) | |
tree | 1499a319c77b12f19ca8c717f7185f8211b7adb9 /source/gameengine | |
parent | 1cf33787932aabc9e2d812f4cf50655059dcbff2 (diff) | |
parent | 945a083e70b79d361f5a9b1be76c9722565c9fe8 (diff) |
merge to 14689, Freestyle library changes, SConscript start
Diffstat (limited to 'source/gameengine')
19 files changed, 153 insertions, 18 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 200c04bbfd3..fa8409b123e 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -264,7 +264,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, if (exitstring != "") strcpy(basedpath, exitstring.Ptr()); - BLI_convertstringcode(basedpath, pathname, 0); + BLI_convertstringcode(basedpath, pathname); bfd = load_game_data(basedpath); // if it wasn't loaded, try it forced relative @@ -275,7 +275,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, strcpy(temppath, "//"); strcat(temppath, basedpath); - BLI_convertstringcode(temppath, pathname, 0); + BLI_convertstringcode(temppath, pathname); bfd = load_game_data(temppath); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 6b0df44cb16..a656c5e5523 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -91,6 +91,10 @@ int KX_BlenderRenderTools::ProcessLighting(int layer) { if (m_clientobject) { + if (layer == RAS_LIGHT_OBJECT_LAYER) + { + layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer(); + } if (applyLights(layer)) { EnableOpenGLLights(); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 3e83ed20840..08e9e36c048 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1680,8 +1680,11 @@ static KX_GameObject *gameobject_from_blenderobject( break; } } - if (gameobj) + if (gameobj) + { gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment()); + gameobj->SetLayer(ob->lay); + } return gameobj; } diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index a575415ab05..6b594e2e70b 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -351,7 +351,7 @@ void BL_ConvertActuators(char* maggiename, else { /* but we need to convert the samplename into absolute pathname first */ - BLI_convertstringcode(soundact->sound->name, maggiename, 0); + BLI_convertstringcode(soundact->sound->name, maggiename); samplename = soundact->sound->name; /* and now we can load it */ diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index f8fc256b371..f13b1bcf4c9 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -163,6 +163,25 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { m_val=(active)?1:0; result = true; + } else + { + if (active) + { + if (m_val == 0) + { + //see comment below + //m_val = 1; + //result = true; + ; + } + } else + { + if (m_val == 1) + { + m_val = 0; + result = true; + } + } } } @@ -178,6 +197,13 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) if (inevent.m_status == SCA_InputEvent::KX_NO_INPUTSTATUS) { + if (m_val == 1) + { + // this situation may occur after a scene suspend: the keyboard release + // event was not captured, produce now the event off + m_val = 0; + result = true; + } } else { if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED) @@ -190,6 +216,23 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { m_val = 0; result = true; + } else + { + if (inevent.m_status == SCA_InputEvent::KX_ACTIVE) + { + if (m_val == 0) + { + //hmm, this abnormal situation may occur in the following cases: + //- the key was pressed while the scene was suspended + //- this is a new scene and the key is active from the start + //In the second case, it's dangerous to activate the sensor + //(think of a key to go to next scene) + //What we really need is a edge/level flag in the key sensor + //m_val = 1; + //result = true; + ; + } + } } } } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index a91cf3e0439..8810b7470ed 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -158,6 +158,25 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { m_val = 0; result = true; + } else + { + if (event.m_status == SCA_InputEvent::KX_ACTIVE) + { + if (m_val == 0) + { + //dangerous + //m_val = 1; + //result = true; + ; + } + } else + { + if (m_val == 1) + { + m_val = 0; + result = true; + } + } } } break; @@ -183,6 +202,13 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { m_val = 0; result = true; + } else + { + if (m_val == 1) + { + m_val = 0; + result = true; + } } } break; diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index a5b8d8aacdf..edda7657ef9 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -137,6 +137,10 @@ int GPC_RenderTools::ProcessLighting(int layer) { if (m_clientobject) { + if (layer == RAS_LIGHT_OBJECT_LAYER) + { + layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer(); + } if (applyLights(layer)) { EnableOpenGLLights(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 1496f7c6ad3..8817bc98886 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -579,7 +579,7 @@ int main(int argc, char** argv) // base the actuator filename with respect // to the original file working directory strcpy(basedpath, exitstring.Ptr()); - BLI_convertstringcode(basedpath, pathname, 0); + BLI_convertstringcode(basedpath, pathname); bfd = load_game_data(basedpath); } diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index cfdcba8a5d6..44727588106 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -84,6 +84,7 @@ KX_BlenderMaterial::KX_BlenderMaterial( mScene(scene), mUserDefBlend(0), mModified(0), + mConstructed(false), mPass(0) { @@ -119,7 +120,9 @@ KX_BlenderMaterial::KX_BlenderMaterial( KX_BlenderMaterial::~KX_BlenderMaterial() { // cleanup work - OnExit(); + if (mConstructed) + // clean only if material was actually used + OnExit(); } @@ -138,6 +141,10 @@ unsigned int* KX_BlenderMaterial::GetMCol(void) const void KX_BlenderMaterial::OnConstruction() { + if (mConstructed) + // when material are reused between objects + return; + // for each unique material... int i; for(i=0; i<mMaterial->num_enabled; i++) { @@ -148,19 +155,20 @@ void KX_BlenderMaterial::OnConstruction() } if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) ) spit("unable to initialize image("<<i<<") in "<< - mMaterial->matname<< ", image will not be available"); + mMaterial->matname<< ", image will not be available"); } else { if( mMaterial->img[i] ) { if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) spit("unable to initialize image("<<i<<") in "<< - mMaterial->matname<< ", image will not be available"); + mMaterial->matname<< ", image will not be available"); } } } mBlendFunc[0] =0; mBlendFunc[1] =0; + mConstructed = true; } void KX_BlenderMaterial::OnExit() diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 2b1264154d0..b9d48199520 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -93,6 +93,7 @@ private: bool mUserDefBlend; unsigned int mBlendFunc[2]; bool mModified; + bool mConstructed; // if false, don't clean on exit void ActivatGLMaterials( RAS_IRasterizer* rasty )const; void ActivateTexGen( RAS_IRasterizer *ras ) const; diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 4a61c37be06..e0cd5a3bc9e 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -1123,7 +1123,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter); ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); - + ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody; KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); //remember that we created a shape so that we can delete it when the scene is removed (bullet will not delete it) kxscene->AddShape(bm); @@ -1147,6 +1147,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, //{ // rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); //} + if (objprop->m_dyna && !objprop->m_angular_rigidbody) { /* @@ -1161,8 +1162,10 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, */ //env->createConstraint(physicscontroller,0,PHY_ANGULAR_CONSTRAINT,0,0,0,0,0,1); - physicscontroller->GetRigidBody()->setAngularFactor(0.f); - + + //Now done directly in ci.m_bRigid so that it propagates to replica + //physicscontroller->GetRigidBody()->setAngularFactor(0.f); + ; } bool isActor = objprop->m_isactor; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index cf621e04f99..4c6ba448ebf 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -74,6 +74,7 @@ KX_GameObject::KX_GameObject( ) : SCA_IObject(T), m_bDyna(false), + m_layer(0), m_bSuspendDynamics(false), m_bUseObjectColor(false), m_bVisible(true), @@ -228,7 +229,7 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj) NodeSetLocalScale(scale1); NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2])); - NodeSetLocalOrientation(NodeGetWorldOrientation()*invori); + NodeSetLocalOrientation(invori*NodeGetWorldOrientation()); NodeUpdateGS(0.f,true); // object will now be a child, it must be removed from the parent list CListValue* rootlist = scene->GetRootParentList(); @@ -479,6 +480,22 @@ KX_GameObject::SetVisible( m_bVisible = v; } +void +KX_GameObject::SetLayer( + int l + ) +{ + m_layer = l; +} + +int +KX_GameObject::GetLayer( + void + ) +{ + return m_layer; +} + // used by Python, and the actuatorshould _not_ be misused by the // scene! void diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 87775e81216..da0cd69e129 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -70,6 +70,7 @@ protected: KX_ClientObjectInfo* m_pClient_info; STR_String m_name; STR_String m_text; + int m_layer; std::vector<RAS_MeshObject*> m_meshes; bool m_bSuspendDynamics; @@ -571,6 +572,22 @@ public: bool b ); + /** + * Change the layer of the object (when it is added in another layer + * than the original layer) + */ + void + SetLayer( + int l + ); + + /** + * Get the object layer + */ + int + GetLayer( + void + ); /** * @section Logic bubbling methods. diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 54003284e03..e4054e07475 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -650,6 +650,8 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) { (*git)->Relink(&m_map_gameobject_to_replica); + // add the object in the layer of the parent + (*git)->SetLayer(parentobj->GetLayer()); } // now replicate logic diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index d99b75482b9..e444c4c73be 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -137,6 +137,10 @@ void CcdPhysicsController::CreateRigidbody() m_body->setGravity( m_cci.m_gravity); m_body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping); + if (!m_cci.m_bRigid) + { + m_body->setAngularFactor(0.f); + } } CcdPhysicsController::~CcdPhysicsController() diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 54b4bcc40ee..37fa465351f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -60,6 +60,7 @@ struct CcdConstructionInfo m_linearDamping(0.1f), m_angularDamping(0.1f), m_collisionFlags(0), + m_bRigid(false), m_collisionFilterGroup(DefaultFilter), m_collisionFilterMask(AllFilter), m_collisionShape(0), @@ -78,6 +79,7 @@ struct CcdConstructionInfo btScalar m_linearDamping; btScalar m_angularDamping; int m_collisionFlags; + bool m_bRigid; ///optional use of collision group/mask: ///only collision with object goups that match the collision mask. diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 6c3e89fa69d..50df1a1e2ea 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -113,6 +113,7 @@ void RAS_BucketManager::RenderAlphaBuckets( std::multiset< alphamesh, backtofront>::iterator msit = alphameshset.begin(); for (; msit != alphameshset.end(); ++msit) { + rendertools->SetClientObject((*(*msit).m_ms).m_clientObj); while ((*msit).m_bucket->ActivateMaterial(cameratrans, rasty, rendertools, drawingmode)) (*msit).m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(*msit).m_ms, drawingmode); } diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index 30c96d02847..16e15653c82 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -61,6 +61,10 @@ public: RAS_TEXT_PADDED, RAS_TEXT_MAX }; + enum RAS_LIGHT_MODE { + RAS_LIGHT_NONE = -1, + RAS_LIGHT_OBJECT_LAYER = 0 + }; RAS_IRenderTools( ) : diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 4642ffbaeb8..02e84f8a243 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -189,7 +189,7 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I } else { - rendertools->ProcessLighting(m_material->GetLightLayer()); + rendertools->ProcessLighting(RAS_IRenderTools::RAS_LIGHT_OBJECT_LAYER/*m_material->GetLightLayer()*/); } drawmode = (rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID ? @@ -204,7 +204,6 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa if (!ms.m_bVisible) return; - rendertools->SetClientObject(ms.m_clientObj); m_material->ActivateMeshSlot(ms, rasty); /* __NLA Do the deformation */ @@ -317,15 +316,12 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans, //rasty->SetMaterial(*m_material); - if (m_meshSlots.size() >0) - { - rendertools->SetClientObject((*m_meshSlots.begin()).m_clientObj); - } int drawmode; for (T_MeshSlotList::const_iterator it = m_meshSlots.begin(); ! (it == m_meshSlots.end()); ++it) { + rendertools->SetClientObject((*it).m_clientObj); while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode)) RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode); } |