[Orxonox-commit 2245] r6961 - in code/branches/presentation3/src: libraries/network/synchronisable orxonox orxonox/graphics orxonox/interfaces
scheusso at orxonox.net
scheusso at orxonox.net
Fri May 21 18:50:08 CEST 2010
Author: scheusso
Date: 2010-05-21 18:50:07 +0200 (Fri, 21 May 2010)
New Revision: 6961
Modified:
code/branches/presentation3/src/libraries/network/synchronisable/Serialise.h
code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.cc
code/branches/presentation3/src/orxonox/Level.cc
code/branches/presentation3/src/orxonox/Scene.cc
code/branches/presentation3/src/orxonox/graphics/Model.cc
code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc
Log:
fixed to make everything network-compliant again
Modified: code/branches/presentation3/src/libraries/network/synchronisable/Serialise.h
===================================================================
--- code/branches/presentation3/src/libraries/network/synchronisable/Serialise.h 2010-05-21 16:49:29 UTC (rev 6960)
+++ code/branches/presentation3/src/libraries/network/synchronisable/Serialise.h 2010-05-21 16:50:07 UTC (rev 6961)
@@ -37,6 +37,8 @@
#include "util/Serialise.h"
#include "util/TypeTraits.h"
#include "core/CorePrereqs.h"
+#include "core/CoreIncludes.h"
+#include "core/SmartPtr.h"
namespace orxonox{
@@ -73,6 +75,41 @@
else
return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
}
+
+ // These functions implement loading / saving / etc. for SmartPtr<T>
+
+ /** @brief returns the size of the objectID needed to synchronise the pointer */
+ template <class T> inline uint32_t returnSize( const SmartPtr<T>& variable )
+ {
+ return sizeof(uint32_t);
+ }
+
+ /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
+ template <class T> inline void loadAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
+ {
+// *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
+ *const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
+ mem += returnSize( variable );
+ }
+
+ /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
+ template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
+ {
+ if ( variable.get() )
+ *(uint32_t*)(mem) = static_cast<uint32_t>(variable->getObjectID());
+ else
+ *(uint32_t*)(mem) = OBJECTID_UNKNOWN;
+ mem += returnSize( variable );
+ }
+
+ /** @brief checks whether the objectID of the variable is the same as in the bytestream */
+ template <class T> inline bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem )
+ {
+ if ( variable.get() )
+ return *(uint32_t*)(mem) == variable->getObjectID();
+ else
+ return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
+ }
}
Modified: code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.cc 2010-05-21 16:49:29 UTC (rev 6960)
+++ code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.cc 2010-05-21 16:50:07 UTC (rev 6961)
@@ -176,6 +176,8 @@
//no->creatorID=header.getCreatorID(); //TODO: remove this
no->setClassID(header.getClassID());
assert(no->creatorID_ == header.getCreatorID());
+ if( creator )
+ bo->setLevel(creator->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)
//assert(no->classID_ == header.getClassID());
COUT(4) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << std::endl;
// update data and create object/entity...
Modified: code/branches/presentation3/src/orxonox/Level.cc
===================================================================
--- code/branches/presentation3/src/orxonox/Level.cc 2010-05-21 16:49:29 UTC (rev 6960)
+++ code/branches/presentation3/src/orxonox/Level.cc 2010-05-21 16:50:07 UTC (rev 6961)
@@ -126,7 +126,7 @@
{
this->objects_.push_back(object);
object->setGametype(this->getGametype());
- object->setLevel(this);
+ object->setLevel(this);
}
BaseObject* Level::getObject(unsigned int index) const
Modified: code/branches/presentation3/src/orxonox/Scene.cc
===================================================================
--- code/branches/presentation3/src/orxonox/Scene.cc 2010-05-21 16:49:29 UTC (rev 6960)
+++ code/branches/presentation3/src/orxonox/Scene.cc 2010-05-21 16:50:07 UTC (rev 6961)
@@ -46,6 +46,7 @@
#include "tools/BulletConversions.h"
#include "Radar.h"
#include "worldentities/WorldEntity.h"
+#include "Level.h"
namespace orxonox
{
@@ -132,6 +133,7 @@
registerVariable(this->gravity_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity));
registerVariable(this->bHasPhysics_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
registerVariable(this->bShadows_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
+ registerVariable(this->getLevel(), VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::changedLevel));
}
void Scene::setNegativeWorldRange(const Vector3& range)
Modified: code/branches/presentation3/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/Model.cc 2010-05-21 16:49:29 UTC (rev 6960)
+++ code/branches/presentation3/src/orxonox/graphics/Model.cc 2010-05-21 16:50:07 UTC (rev 6961)
@@ -114,11 +114,10 @@
Level* level_ = this->getLevel();
- MeshLodInformation* lodInfo = level_->getLodInfo(this->meshSrc_);
+ // TODO: make this also working on the client (there is currently no level pointer in the baseobject on the client)
+ if( level_ != 0 && level_->getLodInfo(this->meshSrc_)!=0 )
+ setLodLevel(level_->getLodInfo(this->meshSrc_)->getLodLevel());
- if(lodInfo!=0)
- setLodLevel(lodInfo->getLodLevel());
-
COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl;
#if OGRE_VERSION >= 0x010700
Modified: code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc 2010-05-21 16:49:29 UTC (rev 6960)
+++ code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc 2010-05-21 16:50:07 UTC (rev 6961)
@@ -30,6 +30,7 @@
#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
#include "worldentities/WorldEntity.h"
#include "Radar.h"
#include "Scene.h"
@@ -51,16 +52,25 @@
RegisterRootObject(RadarViewable);
this->uniqueId_=getUniqueNumberString();
- this->radar_ = this->creator_->getScene()->getRadar();
- this->radar_->addRadarObject(this);
+ if( GameMode::showsGraphics() )
+ {
+ this->radar_ = this->creator_->getScene()->getRadar();
+ this->radar_->addRadarObject(this);
+ }
this->bInitialized_ = true;
}
RadarViewable::~RadarViewable()
{
+
if( this->bInitialized_ )
- this->radar_->removeRadarObject(this);
+ {
+ if( GameMode::showsGraphics() )
+ {
+ this->radar_->removeRadarObject(this);
+ }
+ }
}
// void RadarViewable::setRadarObjectDescription(const std::string& str)
@@ -100,6 +110,9 @@
void RadarViewable::settingsChanged()
{
- this->radar_->radarObjectChanged(this);
+ if( GameMode::showsGraphics() )
+ {
+ this->radar_->radarObjectChanged(this);
+ }
}
}
More information about the Orxonox-commit
mailing list