소스 검색

Fixed erroneous event bitmasks. Optimize LogicComponent memory footprint.

Lasse Öörni 11 년 전
부모
커밋
c96f313dbd
2개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 3 3
      Source/Engine/Scene/LogicComponent.cpp
  2. 8 8
      Source/Engine/Scene/LogicComponent.h

+ 3 - 3
Source/Engine/Scene/LogicComponent.cpp

@@ -48,7 +48,7 @@ void LogicComponent::OnSetEnabled()
     UpdateEventSubscription();
     UpdateEventSubscription();
 }
 }
 
 
-void LogicComponent::SetUpdateEventMask(unsigned mask)
+void LogicComponent::SetUpdateEventMask(unsigned char mask)
 {
 {
     if (updateEventMask_ != mask)
     if (updateEventMask_ != mask)
     {
     {
@@ -122,7 +122,7 @@ void LogicComponent::UpdateEventSubscription()
         SubscribeToEvent(world, E_PHYSICSPRESTEP, HANDLER(LogicComponent, HandlePhysicsPreStep));
         SubscribeToEvent(world, E_PHYSICSPRESTEP, HANDLER(LogicComponent, HandlePhysicsPreStep));
         currentEventMask_ |= USE_FIXEDUPDATE;
         currentEventMask_ |= USE_FIXEDUPDATE;
     }
     }
-    else if (!needFixedUpdate && (currentEventMask_ & USE_POSTUPDATE))
+    else if (!needFixedUpdate && (currentEventMask_ & USE_FIXEDUPDATE))
     {
     {
         UnsubscribeFromEvent(world, E_PHYSICSPRESTEP);
         UnsubscribeFromEvent(world, E_PHYSICSPRESTEP);
         currentEventMask_ &= ~USE_FIXEDUPDATE;
         currentEventMask_ &= ~USE_FIXEDUPDATE;
@@ -134,7 +134,7 @@ void LogicComponent::UpdateEventSubscription()
         SubscribeToEvent(world, E_PHYSICSPOSTSTEP, HANDLER(LogicComponent, HandlePhysicsPostStep));
         SubscribeToEvent(world, E_PHYSICSPOSTSTEP, HANDLER(LogicComponent, HandlePhysicsPostStep));
         currentEventMask_ |= USE_FIXEDPOSTUPDATE;
         currentEventMask_ |= USE_FIXEDPOSTUPDATE;
     }
     }
-    else if (!needFixedPostUpdate && (currentEventMask_ & USE_POSTUPDATE))
+    else if (!needFixedPostUpdate && (currentEventMask_ & USE_FIXEDPOSTUPDATE))
     {
     {
         UnsubscribeFromEvent(world, E_PHYSICSPOSTSTEP);
         UnsubscribeFromEvent(world, E_PHYSICSPOSTSTEP);
         currentEventMask_ &= ~USE_FIXEDPOSTUPDATE;
         currentEventMask_ &= ~USE_FIXEDPOSTUPDATE;

+ 8 - 8
Source/Engine/Scene/LogicComponent.h

@@ -26,13 +26,13 @@ namespace Urho3D
 {
 {
 
 
 /// Bitmask for using the scene update event.
 /// Bitmask for using the scene update event.
-static const unsigned USE_UPDATE = 0x1;
+static const unsigned char USE_UPDATE = 0x1;
 /// Bitmask for using the scene post-update event.
 /// Bitmask for using the scene post-update event.
-static const unsigned USE_POSTUPDATE = 0x2;
+static const unsigned char USE_POSTUPDATE = 0x2;
 /// Bitmask for using the physics update event.
 /// Bitmask for using the physics update event.
-static const unsigned USE_FIXEDUPDATE = 0x4;
+static const unsigned char USE_FIXEDUPDATE = 0x4;
 /// Bitmask for using the physics post-update event.
 /// Bitmask for using the physics post-update event.
-static const unsigned USE_FIXEDPOSTUPDATE = 0x8;
+static const unsigned char USE_FIXEDPOSTUPDATE = 0x8;
 
 
 /// Helper base class for user-defined game logic components that hooks up to update events and forwards them to virtual functions similar to ScriptInstance class.
 /// Helper base class for user-defined game logic components that hooks up to update events and forwards them to virtual functions similar to ScriptInstance class.
 class URHO3D_API LogicComponent : public Component
 class URHO3D_API LogicComponent : public Component
@@ -62,10 +62,10 @@ class URHO3D_API LogicComponent : public Component
     virtual void FixedPostUpdate(float timeStep) {}
     virtual void FixedPostUpdate(float timeStep) {}
     
     
     /// Set what update events should be subscribed to. Use this for optimization: by default all are in use. Note that this is not an attribute and is not saved or network-serialized, therefore it should always be called eg. in the subclass constructor.
     /// Set what update events should be subscribed to. Use this for optimization: by default all are in use. Note that this is not an attribute and is not saved or network-serialized, therefore it should always be called eg. in the subclass constructor.
-    void SetUpdateEventMask(unsigned mask);
+    void SetUpdateEventMask(unsigned char mask);
     
     
     /// Return what update events are subscribed to.
     /// Return what update events are subscribed to.
-    unsigned GetUpdateEventMask() const { return updateEventMask_; }
+    unsigned char GetUpdateEventMask() const { return updateEventMask_; }
     /// Return whether the DelayedStart() function has been called.
     /// Return whether the DelayedStart() function has been called.
     bool IsDelayedStartCalled() const { return delayedStartCalled_; }
     bool IsDelayedStartCalled() const { return delayedStartCalled_; }
     
     
@@ -86,9 +86,9 @@ private:
     void HandlePhysicsPostStep(StringHash eventType, VariantMap& eventData);
     void HandlePhysicsPostStep(StringHash eventType, VariantMap& eventData);
     
     
     /// Requested event subscription mask.
     /// Requested event subscription mask.
-    unsigned updateEventMask_;
+    unsigned char updateEventMask_;
     /// Current event subscription mask.
     /// Current event subscription mask.
-    unsigned currentEventMask_;
+    unsigned char currentEventMask_;
     /// Flag for delayed start.
     /// Flag for delayed start.
     bool delayedStartCalled_;
     bool delayedStartCalled_;
 };
 };