NLS Engine  v0.1
The Next Logical Step in game engine design.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines
PhysicsModule.h
Go to the documentation of this file.
00001 
00011 #pragma once
00012 
00013 // System Library Includes
00014 #include <set>
00015 #include <string>
00016 
00017 // Application Library Includes
00018 #include <threading.h>
00019 
00020 // Local Includes
00021 #include "../sharedbase/ModuleInterface.h"
00022 #include "../sharedbase/Envelope_fwd.h"
00023 
00024 // Forward Declarations
00026 namespace Physics {
00027   class InterfaceUpdateable;
00028   class InterfaceCollider;
00029 }
00030 
00031 // Typedefs
00032 namespace Physics {
00033   typedef std::set<ComponentInterface*> ComponentListType;
00034   typedef std::set<InterfaceCollider*> CollidableListType;
00035   typedef std::set<InterfaceUpdateable*> UpdateableListType;
00036 }
00037 
00038 // DLL Interface
00039 extern "C" {
00040   __declspec(dllexport) ModuleInterface* ModuleFactory(PropertyMap*, MessageRouter*, EntityList*, EventLogger*);
00041 }
00042 
00043 // Classes
00044 namespace Physics {
00045   class PhysicsModule: public ModuleInterface {
00046   public:
00047     
00048     PhysicsModule(PropertyMap*, MessageRouter*, EntityList*);
00049     ~PhysicsModule(void);
00050     
00051   private: // Inherited methods
00052     void Update(double dt);
00053     void CreateComponent(std::string, std::map<std::string, boost::any> &, EntitySPTR);
00054     WHO_DELETES::TYPE RemoveComponent(ComponentInterface*);
00055     
00056   private: // Member methods
00058     void RegisterMessageHandlers();
00059     
00061     void ReportCollisions() const;
00062     
00063     // Message handlers
00064     void HandlerStartup(EnvelopeSPTR);
00065     
00066     EnvelopeSPTR HandleRayCast(EnvelopeSPTR) const;
00067     
00068   private: // Member data
00069     double deltaAccumulator; 
00070     float updateDelay;
00071     
00072     ComponentListType physicsComponents;
00073     mutable Threading::ReadWriteMutex physicsComponentsMutex;
00074     
00075     CollidableListType collidableObjects;
00076     mutable Threading::ReadWriteMutex collidableObjectsMutex;
00077     
00078     UpdateableListType updateableObjects;
00079     mutable Threading::ReadWriteMutex updateableObjectsMutex;
00080   };
00081 }