duststorm01 avatar duststorm01 committed 0a334ea Draft

Made crowd code compatible again with Ogre 1.7
by adding IFDEF switches around code using new instancing

Comments (0)

Files changed (4)

include/CrowdManager.h

 
     std::vector<Ogre::Vector2> mBorderTiles;
 
+#if OGRE_VERSION_MINOR >= 8
     Ogre::InstanceManager* mInstanceManager;
+#endif
 
 };
 

include/InstancedCharacter.h

 #ifndef INSTANCEDCHARACTER_H
 #define INSTANCEDCHARACTER_H
 
+#include <OgrePrerequisites.h>
+#if OGRE_VERSION_MINOR >= 8
 #include "Character.h"
 
 class InstancedCharacter : public Character
       **/
     Ogre::SceneNode *mDebugNode;
 };
+#endif
 
 #endif // INSTANCEDCHARACTER_H

src/CrowdManager.cpp

 #include "OgreDetourCrowd.h"
 #include "Character.h"
 #include "AnimateableCharacter.h"
+#include "TestCharacter.h"
+#if OGRE_VERSION_MINOR >= 8
 #include "InstancedCharacter.h"
-#include "TestCharacter.h"
+#endif
 
 
 const Ogre::Real CrowdManager::CROWD_PAGE_UPDATE_DELTA = 1;
     , mNbTilesInBorder(0)
     , mAreaDebug(0)
     , mBorderTiles()
+#if OGRE_VERSION_MINOR >= 8
     , mInstanceManager(0)
+#endif
 {
     // Number of tiles filled with agents
     if(mPagedAreaDistance == 0) {
     mDetourCrowd = new OgreDetourCrowd(mRecast);        // TODO add option of specifying max crowd size?
 
 
+#if OGRE_VERSION_MINOR >= 8
     if(INSTANCED_CROWD) {
         // Most compatible SM2+ technique
         Ogre::InstanceManager::InstancingTechnique instanceTechnique = Ogre::InstanceManager::ShaderBased;
                     Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, instanceTechnique,
                     mCrowdSize); // TODO experiment with batch size
     }
+#endif
 
     initAgents();
 }
                     Ogre::Vector3 position = getRandomPositionInNavmeshTile(x, y);
                     Character *character;
 // TODO make configurable which type of character is exactly instanced (maybe allow keeping sets of different populations)
+#if OGRE_VERSION_MINOR >= 8
                     if(INSTANCED_CROWD) {
                         character = new InstancedCharacter("Character_"+Ogre::StringConverter::toString(nbAgents), mSceneMgr, mDetourCrowd, mInstanceManager, false, position);
                     } else if(HUMAN_CHARACTERS) {
+#else
+                    if(HUMAN_CHARACTERS) {
+#endif
                         character = new AnimateableCharacter("Character_"+Ogre::StringConverter::toString(nbAgents), mSceneMgr, mDetourCrowd, false, position);
                     } else {
                         character = new TestCharacter("Character_"+Ogre::StringConverter::toString(nbAgents), mSceneMgr, mDetourCrowd, position);
     nbAgents++;
     while(nbAgents < mCrowdSize) {
         Character *character;
+#if OGRE_VERSION_MINOR >= 8
         if(INSTANCED_CROWD) {
             character = new InstancedCharacter("Character_"+Ogre::StringConverter::toString(nbAgents), mSceneMgr, mDetourCrowd, mInstanceManager);
         } else if(HUMAN_CHARACTERS) {
+#else
+        if(HUMAN_CHARACTERS) {
+#endif
             character = new AnimateableCharacter("Character_"+Ogre::StringConverter::toString(nbAgents), mSceneMgr, mDetourCrowd);
         } else {
             character = new TestCharacter("Character_"+Ogre::StringConverter::toString(nbAgents), mSceneMgr, mDetourCrowd);
     character->load(rndPos);
 
     // Start walking animation at random position to avoid obvious synchronized movement
+#if OGRE_VERSION_MINOR >= 8
     if(INSTANCED_CROWD)
         ((InstancedCharacter*) character)->randomizeAnimationPosition();
     else if(HUMAN_CHARACTERS)
+#else
+    if(HUMAN_CHARACTERS) {
+#endif
         ((AnimateableCharacter*) character)->randomizeAnimationPosition();
 // TODO this code replication is stupid. Fix up character classes with a better inheritance scheme, abstracting out demo specific and reusable classes
 

src/InstancedCharacter.cpp

     THE SOFTWARE.
 
 */
+#include <OgrePrerequisites.h>
+#if OGRE_VERSION_MINOR >= 8
 
 #include "InstancedCharacter.h"
 #include "OgreRecastApplication.h"  // TODO remove this dependency
 {
     mAnimState->setTimePosition( Ogre::Math::RangeRandom(0, mAnimState->getLength()) );
 }
+
+#endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.