Browse Source

Minor code formatting. Document that we have returned to the old behavior of not notifying dirty node transform if it was already dirty before, and users of the TransformChanged() function should read the node's world transform to ensure continued notifications.

Lasse Öörni 10 years ago
parent
commit
e6e16b90ed
2 changed files with 4 additions and 3 deletions
  1. 1 1
      Docs/Reference.dox
  2. 3 2
      Source/Urho3D/Scene/Node.cpp

+ 1 - 1
Docs/Reference.dox

@@ -540,7 +540,7 @@ The Start() and Stop() methods do not have direct counterparts in C++ components
 
 When a scene node hierarchy with script objects is instantiated (such as when loading a scene) any child nodes may not have been created yet when Start() is executed, and can thus not be relied upon for initialization. The DelayedStart() method can be used in this case instead: if defined, it is called immediately before any of the Update() calls.
 
-TransformChanged() is called whenever the scene node transform changes, similar to C++ components' OnMarkedDirty() function.
+TransformChanged() is called whenever the scene node transform changes and the node was not dirty before, similar to C++ components' OnMarkedDirty() function. The function should read the node's world transform (or rotation / position / scale) to reset the dirty status and ensure the next dirty notification is also sent.
 
 Subscribing to \ref Events "events" in script behaves differently depending on whether \ref Object::SubscribeToEvent "SubscribeToEvent()" is called from a script object's method, or from a procedural script function. If called from an instantiated script object, the ScriptInstance becomes the event receiver on the C++ side, and calls the specified handler method when the event arrives. If called from a function, the ScriptFile will be the event receiver and the handler must be a free function in the same script file. The third case is if the event is subscribed to from a script object that does not belong to a ScriptInstance. In that case the ScriptFile will create a proxy C++ object on demand to be able to forward the event to the script object.
 

+ 3 - 2
Source/Urho3D/Scene/Node.cpp

@@ -568,7 +568,8 @@ void Node::MarkDirty()
         // Therefore if we are recursing here to mark this node dirty, and it already was,
         // then all children of this node must also be already dirty, and we don't need to
         // reflag them again.
-        if (cur->dirty_) return;
+        if (cur->dirty_)
+            return;
         cur->dirty_ = true;
 
         // Notify listener components first, then mark child nodes
@@ -1891,4 +1892,4 @@ void Node::HandleAttributeAnimationUpdate(StringHash eventType, VariantMap& even
     UpdateAttributeAnimations(eventData[P_TIMESTEP].GetFloat());
 }
 
-}
+}