⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ogrecollisionmanager.h

📁 使用stl技术,(还没看,是听说的)
💻 H
字号:
#ifndef __OGRECOLLISIONMANAGER_H__
#define __OGRECOLLISIONMANAGER_H__

#include <OgreSingleton.h>
#include "OgreCollider.h"

namespace Ogre {

    class CollisionManager : public Singleton<CollisionManager>
    {
	private:
        Collider* mCollider;

    public:
        /** Processes the OpenGL extensions that the graphics card supports
        */
           
        CollisionManager() 
		  : mCollider(0)
		{ 
		  // This will eventually have to be setup on its own so 
		  createCollider();
		}

        ~CollisionManager() 
		{ 
		  if(mCollider) 
			delete mCollider;
		}

        /** Override standard Singleton retrieval.
            @remarks
                Why do we do this? Well, it's because the Singleton
                implementation is in a .h file, which means it gets compiled
                into anybody who includes it. This is needed for the
                Singleton template to work, but we actually only want it
                compiled into the implementation of the class based on the
                Singleton, not all of them. If we don't change this, we get
                link errors when trying to use the Singleton-based class from
                an outside dll.
            @par
                This method just delegates to the template version anyway,
                but the implementation stays in this single compilation unit,
                preventing link errors.
        */

		// Eventually this will accept different collider types
		bool createCollider(void)
		{
		  mCollider = new Collider();
		  if(!mCollider)
			return false;

		  return true;
		}

		CollisionEntity* createEntity(Entity* const ent) 
		{ 
            CollisionEntity* ce = new CollisionEntity(ent);
			return ce;
		}

		bool collide(CollisionEntity* ent1, CollisionEntity* ent2)
		{
		   return mCollider->collide(ent1,ent2);
		}

        static CollisionManager& getSingleton(void);
    };
};
#endif // __OGRECOLLISIONMANAGER_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -