- Timestamp:
- Dec 10, 2008, 10:08:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/gamestates/GSRoot.cc
r2344 r2400 32 32 #include "util/Exception.h" 33 33 #include "util/Debug.h" 34 #include "core/Core.h" 34 35 #include "core/Factory.h" 35 36 #include "core/ConfigValueIncludes.h" … … 43 44 #include "tools/Timer.h" 44 45 #include "objects/Tickable.h" 46 #include "objects/worldentities/Backlight.h" 47 #include "tools/ParticleInterface.h" 45 48 #include "Settings.h" 46 49 … … 67 70 GSRoot::GSRoot() 68 71 : RootGameState("root") 72 , timeFactor_(1.0f) 69 73 , settings_(0) 70 74 , tclBind_(0) … … 74 78 RegisterRootObject(GSRoot); 75 79 setConfigValues(); 80 81 this->ccSetTimeFactor_ = 0; 76 82 } 77 83 … … 88 94 // creates the class hierarchy for all classes with factories 89 95 Factory::createClassHierarchy(); 96 97 // reset game speed to normal 98 timeFactor_ = 1.0f; 90 99 91 100 // Create the lua interface … … 129 138 ccSelectGameState_ = createConsoleCommand(functor2, "selectGameState"); 130 139 CommandExecutor::addConsoleCommandShortcut(ccSelectGameState_); 140 141 // time factor console command 142 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor); 143 functor->setObject(this); 144 ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor"); 145 CommandExecutor::addConsoleCommandShortcut(ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);; 131 146 } 132 147 … … 143 158 delete this->settings_; 144 159 delete this->luaBind_; 160 161 if (this->ccSetTimeFactor_) 162 { 163 delete this->ccSetTimeFactor_; 164 this->ccSetTimeFactor_ = 0; 165 } 145 166 } 146 167 … … 155 176 // Call the Tickable objects 156 177 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 157 it->tick(time.getDeltaTime() );178 it->tick(time.getDeltaTime() * this->timeFactor_); 158 179 /*** HACK *** HACK ***/ 159 180 … … 168 189 169 190 Copyright (c) 2000-2008 Torus Knot Software Ltd 170 191 171 192 OGRE is licensed under the LGPL. For more info, see OGRE license. 172 193 */ … … 175 196 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 176 197 // Get the current process core mask 177 178 198 DWORD procMask; 199 DWORD sysMask; 179 200 # if _MSC_VER >= 1400 && defined (_M_X64) 180 201 GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask); 181 202 # else 182 183 # endif 184 185 186 187 188 203 GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask); 204 # endif 205 206 // If procMask is 0, consider there is only one core available 207 // (using 0 as procMask will cause an infinite loop below) 208 if (procMask == 0) 209 procMask = 1; 189 210 190 211 // if the core specified with limitToCPU is not available, take the lowest one … … 192 213 limitToCPU = 0; 193 214 194 215 // Find the lowest core that this process uses and limitToCPU suggests 195 216 DWORD threadMask = 1; 196 197 198 199 200 217 while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU))) 218 threadMask <<= 1; 219 220 // Set affinity to the first core 221 SetThreadAffinityMask(GetCurrentThread(), threadMask); 201 222 #endif 202 223 } 224 225 /** 226 @brief 227 Changes the speed of Orxonox 228 */ 229 void GSRoot::setTimeFactor(float factor) 230 { 231 if (Core::isMaster()) 232 { 233 float change = factor / this->timeFactor_; 234 235 this->timeFactor_ = factor; 236 /* 237 for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it != ObjectList<ParticleInterface>::end(); ++it) 238 it->setSpeedFactor(it->getSpeedFactor() * change); 239 240 for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it != ObjectList<Backlight>::end(); ++it) 241 it->setTimeFactor(timeFactor_); 242 */ 243 } 244 } 203 245 }
Note: See TracChangeset
for help on using the changeset viewer.