From: Andrew R. <aar...@us...> - 2007-04-16 05:37:19
|
Update of /cvsroot/planeshift/planeshift/src/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10211/src/client Modified Files: pscelclient.cpp pscelclient.h psengine.cpp shadowmanager.cpp shadowmanager.h Log Message: - Andrew Robberts fixed up shadows. Index: pscelclient.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/pscelclient.cpp,v retrieving revision 1.295 retrieving revision 1.296 diff -C2 -d -r1.295 -r1.296 *** pscelclient.cpp 9 Apr 2007 05:23:02 -0000 1.295 --- pscelclient.cpp 16 Apr 2007 05:37:18 -0000 1.296 *************** *** 643,646 **** --- 643,650 ---- } + void psCelClient::Update() + { + shadowManager->UpdateShadows(); + } void psCelClient::HandleMessage(MsgEntry *me) Index: pscelclient.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/pscelclient.h,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -d -r1.107 -r1.108 *** pscelclient.h 23 Feb 2007 21:06:03 -0000 1.107 --- pscelclient.h 16 Apr 2007 05:37:18 -0000 1.108 *************** *** 163,166 **** --- 163,168 ---- void CheckEntityQueues(); + void Update(); + protected: void ReadKeyBindings (const char* filename, iPcCommandInput* pcinp); Index: psengine.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/psengine.cpp,v retrieving revision 1.617 retrieving revision 1.618 diff -C2 -d -r1.617 -r1.618 *** psengine.cpp 9 Feb 2007 21:50:23 -0000 1.617 --- psengine.cpp 16 Apr 2007 05:37:18 -0000 1.618 *************** *** 726,729 **** --- 726,732 ---- soundmanager->Update( celclient->GetMainPlayer()->Pos() ); } + + if (celclient) + celclient->Update(); } else if (ev.Name == event_process) Index: shadowmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/shadowmanager.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** shadowmanager.cpp 11 Mar 2007 14:23:08 -0000 1.2 --- shadowmanager.cpp 16 Apr 2007 05:37:18 -0000 1.3 *************** *** 25,28 **** --- 25,29 ---- #include <csgeom/box.h> #include <imesh/objmodel.h> + #include <iutil/cfgmgr.h> // PS INCLUDES *************** *** 34,39 **** --- 35,57 ---- #include "effects/pseffectobjtext.h" + bool psShadowManager::WithinRange(GEMClientObject * object) const + { + if (shadowRange <= 0.000001f) + return true; + + GEMClientObject * mainPlayer = psengine->GetCelClient()->GetMainPlayer(); + if (!mainPlayer) + return true; + + csVector3 diff = object->pcmesh->GetMesh()->GetMovable()->GetPosition() - + psengine->GetCelClient()->GetMainPlayer()->pcmesh->GetMesh()->GetMovable()->GetPosition(); + return (diff.SquaredNorm() <= shadowRange*shadowRange); + } + psShadowManager::psShadowManager() { + cfgmgr = psengine->GetConfig(); + shadowRange = cfgmgr->GetFloat("Planeshift.Visuals.ShadowRange", -1.0f); + RecreateAllShadows(); } *************** *** 57,60 **** --- 75,81 ---- return; + if (!WithinRange(object)) + return; + // calculate a suitable size for this shadow const csBox3& boundBox = mesh->GetMeshObject()->GetObjectModel()->GetObjectBoundingBox(); *************** *** 67,73 **** psEffect* effect = effectMgr->FindEffect(id); if (!effect) - { return; ! } effect->SetScaling(scale, 1.0f); object->SetShadow(effect); --- 88,93 ---- psEffect* effect = effectMgr->FindEffect(id); if (!effect) return; ! effect->SetScaling(scale, 1.0f); object->SetShadow(effect); *************** *** 102,103 **** --- 122,148 ---- RemoveShadow(entities[a]); } + + float psShadowManager::GetShadowRange() const + { + return shadowRange; + } + + void psShadowManager::SetShadowRange(float shadowRange) + { + this->shadowRange = shadowRange; + cfgmgr->SetFloat("Planeshift.Visuals.ShadowRange", shadowRange); + } + + void psShadowManager::UpdateShadows() + { + const csPDelArray<GEMClientObject>& entities = psengine->GetCelClient()->GetEntities(); + size_t len = entities.GetSize(); + for (size_t a=0; a<len; ++a) + { + if (!WithinRange(entities[a])) + RemoveShadow(entities[a]); + else + CreateShadow(entities[a]); + } + } + Index: shadowmanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/shadowmanager.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** shadowmanager.h 23 Feb 2007 21:06:03 -0000 1.2 --- shadowmanager.h 16 Apr 2007 05:37:18 -0000 1.3 *************** *** 24,31 **** --- 24,36 ---- #include "pscelclient.h" + struct iConfigManager; + class psShadowManager { private: + csRef<iConfigManager> cfgmgr; + float shadowRange; + bool WithinRange(GEMClientObject * object) const; public: psShadowManager(); *************** *** 37,40 **** --- 42,50 ---- void RecreateAllShadows(); void RemoveAllShadows(GEMClientObject * object); + + float GetShadowRange() const; + void SetShadowRange(float shadowRange); + + void UpdateShadows(); }; |