Browse Source

Renamed FinishUpdate() to ApplyAttributes() to be more descriptive, and to not confuse with frame updates.

Lasse Öörni 14 years ago
parent
commit
b6e09d2655

+ 4 - 7
Bin/Data/Scripts/Editor/EditorNodeWindow.as

@@ -205,9 +205,7 @@ void EditAttribute(StringHash eventType, VariantMap& eventData)
     bool intermediateEdit = eventType == StringHash("TextChanged");
 
     StoreAttributeEditor(parent, serializable, index, subIndex);
-    // Some attributes need the finish step to take effect. This is often to avoid some expensive operation,
-    // but while editing every change should happen instantly
-    serializable.FinishUpdate();
+    serializable.ApplyAttributes();
 
     // If not an intermediate edit, reload the editor fields with validated values
     // (attributes may have interactions; therefore we load everything, not just the value being edited)
@@ -215,8 +213,7 @@ void EditAttribute(StringHash eventType, VariantMap& eventData)
         UpdateAttributes(false);
 
     // If a model was loaded, update the scene hierarchy in case bones were recreated
-    if (serializable.attributeInfos[index].type == VAR_RESOURCEREF && serializable.attributes[index].GetResourceRef().type ==
-        ShortStringHash("Model"))
+    if (serializable.attributes[index].GetResourceRef().type == ShortStringHash("Model"))
     {
         if (selectedNode !is null)
             UpdateSceneWindowNode(selectedNode);
@@ -893,7 +890,7 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
         ref.type = ShortStringHash(resourcePicker.resourceType);
         ref.id = StringHash(resourceName);
         target.attributes[resourcePickIndex] = Variant(ref);
-        target.FinishUpdate();
+        target.ApplyAttributes();
         isModel = ref.type == ShortStringHash("Model");
     }
     else if (info.type == VAR_RESOURCEREFLIST)
@@ -903,7 +900,7 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
         {
             refList.ids[resourcePickSubIndex] = StringHash(resourceName);
             target.attributes[resourcePickIndex] = Variant(refList);
-            target.FinishUpdate();
+            target.ApplyAttributes();
         }
     }
 

+ 3 - 3
Bin/Data/Scripts/Editor/EditorSceneWindow.as

@@ -737,7 +737,7 @@ void ScenePaste()
     if (mode == "component")
     {
         BeginModify(selectedNode.id);
-        
+
         // If this is the root node, do not allow to create duplicate scene-global components
         if (selectedNode is editorScene && CheckForExistingGlobalComponent(selectedNode, rootElem.GetAttribute("type")))
             return;
@@ -751,7 +751,7 @@ void ScenePaste()
             return;
         }
         newComponent.LoadXML(rootElem);
-        newComponent.FinishUpdate();
+        newComponent.ApplyAttributes();
         EndModify(selectedNode.id);
 
         UpdateSceneWindowNode(selectedNode);
@@ -765,7 +765,7 @@ void ScenePaste()
         Node@ newNode = editorScene.CreateChild("", copyBufferLocal ? LOCAL : REPLICATED);
         BeginModify(newNode.id);
         newNode.LoadXML(rootElem);
-        newNode.FinishUpdate();
+        newNode.ApplyAttributes();
         EndModify(newNode.id);
         EndModify(editorScene.id);
 

+ 1 - 1
Docs/Reference.dox

@@ -273,7 +273,7 @@ The following methods that implement the component behaviour will be checked for
 - void FixedPostUpdate(float)
 - void Save(Serializer&)
 - void Load(Deserializer&)
-- void FinishUpdate()
+- void ApplyAttributes()
 
 The update methods above correspond to the variable timestep scene update and post-update, and the fixed timestep physics world update and post-update. The application-wide update events are not handled by default.
 

+ 24 - 24
Docs/ScriptAPI.dox

@@ -981,7 +981,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 
@@ -1000,7 +1000,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1022,7 +1022,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void SetScale(float)
@@ -1100,7 +1100,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void SetScale(float)
@@ -1197,7 +1197,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1467,7 +1467,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1493,7 +1493,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1552,7 +1552,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1602,7 +1602,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1641,7 +1641,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1679,7 +1679,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1735,7 +1735,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1790,7 +1790,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1849,7 +1849,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1890,7 +1890,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -1930,7 +1930,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -2086,7 +2086,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -2122,7 +2122,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -3517,7 +3517,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -3597,7 +3597,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -3638,7 +3638,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -3679,7 +3679,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -3718,7 +3718,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()
@@ -3775,7 +3775,7 @@ Methods:<br>
 - bool Save(File@)
 - bool LoadXML(const XMLElement&)
 - bool SaveXML(XMLElement&)
-- void FinishUpdate()
+- void ApplyAttributes()
 - bool SetAttribute(const String&, const Variant&)
 - Variant GetAttribute(const String&)
 - void Remove()

+ 1 - 1
Engine/Engine/APITemplates.h

@@ -356,7 +356,7 @@ template <class T> void RegisterSerializable(asIScriptEngine* engine, const char
     engine->RegisterObjectMethod(className, "bool Save(File@+)", asFUNCTION(SerializableSave), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "bool LoadXML(const XMLElement&)", asMETHODPR(T, LoadXML, (const XMLElement&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool SaveXML(XMLElement&)", asMETHODPR(T, SaveXML, (XMLElement&), bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void FinishUpdate()", asMETHODPR(T, FinishUpdate, (), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void ApplyAttributes()", asMETHODPR(T, ApplyAttributes, (), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool SetAttribute(const String&in, const Variant&in)", asMETHODPR(T, SetAttribute, (const String&, const Variant&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Variant GetAttribute(const String&in)", asMETHODPR(T, GetAttribute, (const String&), Variant), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_numAttributes() const", asMETHODPR(T, GetNumAttributes, () const, unsigned), asCALL_THISCALL);

+ 1 - 1
Engine/Graphics/AnimatedModel.cpp

@@ -94,7 +94,7 @@ void AnimatedModel::RegisterObject(Context* context)
     ACCESSOR_ATTRIBUTE(AnimatedModel, VAR_VARIANTVECTOR, "Animation States", GetAnimationStatesAttr, SetAnimationStatesAttr, VariantVector, VariantVector(), AM_FILE | AM_NOEDIT);
 }
 
-void AnimatedModel::FinishUpdate()
+void AnimatedModel::ApplyAttributes()
 {
     if (assignBonesPending_)
     {

+ 3 - 3
Engine/Graphics/AnimatedModel.h

@@ -46,8 +46,8 @@ public:
     /// Register object factory. Drawable must be registered first.
     static void RegisterObject(Context* context);
     
-    /// Perform finalization after a scene load or network update.
-    virtual void FinishUpdate();
+    /// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
+    virtual void ApplyAttributes();
     /// Process renderer raycast.
     virtual void ProcessRayQuery(RayOctreeQuery& query, float initialDistance);
     /// Update before octree reinsertion. Animation is updated here.
@@ -143,7 +143,7 @@ protected:
     virtual void OnWorldBoundingBoxUpdate();
     
 private:
-    /// Assign skeleton and animation bone node references as a postprocess. Called by FinishUpdate.
+    /// Assign skeleton and animation bone node references as a postprocess. Called by ApplyAttributes.
     void AssignBoneNodes();
     /// Mark animation and skinning to require an update.
     void MarkAnimationDirty();

+ 15 - 8
Engine/Network/Connection.cpp

@@ -350,6 +350,8 @@ void Connection::ProcessPendingLatestData()
             MemoryBuffer msg(current->second_);
             msg.ReadNetID(); // Skip the node ID
             node->ReadLatestDataUpdate(msg);
+            // ApplyAttributes() is deliberately skipped, as Node has no attributes that require late applying.
+            // Furthermore it would propagate to components and child nodes, which is not desired in this case
             nodeLatestData_.Erase(current);
         }
     }
@@ -364,7 +366,7 @@ void Connection::ProcessPendingLatestData()
             MemoryBuffer msg(current->second_);
             msg.ReadNetID(); // Skip the component ID
             component->ReadLatestDataUpdate(msg);
-            component->FinishUpdate();
+            component->ApplyAttributes();
             componentLatestData_.Erase(current);
         }
     }
@@ -547,9 +549,9 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
                     return;
                 }
                 
-                // Read initial attributes, then perform finalization
+                // Read initial attributes and apply
                 component->ReadDeltaUpdate(msg, deltaUpdateBits_);
-                component->FinishUpdate();
+                component->ApplyAttributes();
             }
         }
         break;
@@ -561,7 +563,8 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
             if (node)
             {
                 node->ReadDeltaUpdate(msg, deltaUpdateBits_);
-                
+                // ApplyAttributes() is deliberately skipped, as Node has no attributes that require late applying.
+                // Furthermore it would propagate to components and child nodes, which is not desired in this case
                 unsigned changedVars = msg.ReadVLE();
                 VariantMap& vars = node->GetVars();
                 while (changedVars)
@@ -582,7 +585,11 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
             unsigned nodeID = msg.ReadNetID();
             Node* node = scene_->GetNode(nodeID);
             if (node)
+            {
                 node->ReadLatestDataUpdate(msg);
+                // ApplyAttributes() is deliberately skipped, as Node has no attributes that require late applying.
+                // Furthermore it would propagate to components and child nodes, which is not desired in this case
+            }
             else
             {
                 // Latest data messages may be received out-of-order relative to node creation, so cache if necessary
@@ -628,9 +635,9 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
                     return;
                 }
                 
-                // Read initial attributes, then perform finalization
+                // Read initial attributes and apply
                 component->ReadDeltaUpdate(msg, deltaUpdateBits_);
-                component->FinishUpdate();
+                component->ApplyAttributes();
             }
             else
                 LOGWARNING("CreateComponent message received for missing node " + String(nodeID));
@@ -644,7 +651,7 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
             if (component)
             {
                 component->ReadDeltaUpdate(msg, deltaUpdateBits_);
-                component->FinishUpdate();
+                component->ApplyAttributes();
             }
             else
                 LOGWARNING("ComponentDeltaUpdate message received for missing component " + String(componentID));
@@ -658,7 +665,7 @@ void Connection::ProcessSceneUpdate(int msgID, MemoryBuffer& msg)
             if (component)
             {
                 component->ReadLatestDataUpdate(msg);
-                component->FinishUpdate();
+                component->ApplyAttributes();
             }
             else
             {

+ 1 - 1
Engine/Physics/CollisionShape.cpp

@@ -360,7 +360,7 @@ void CollisionShape::OnSetAttribute(const AttributeInfo& attr, const Variant& sr
     }
 }
 
-void CollisionShape::FinishUpdate()
+void CollisionShape::ApplyAttributes()
 {
     if (recreateGeometry_)
     {

+ 2 - 2
Engine/Physics/CollisionShape.h

@@ -101,8 +101,8 @@ public:
     
     /// Handle attribute write access.
     virtual void OnSetAttribute(const AttributeInfo& attr, const Variant& src);
-    /// Perform finalization after a scene load or network update.
-    virtual void FinishUpdate();
+    /// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
+    virtual void ApplyAttributes();
     
     /// Clear the collision geometry.
     void Clear();

+ 1 - 1
Engine/Physics/Joint.cpp

@@ -78,7 +78,7 @@ void Joint::OnSetAttribute(const AttributeInfo& attr, const Variant& src)
         recreateJoint_ = true;
 }
 
-void Joint::FinishUpdate()
+void Joint::ApplyAttributes()
 {
     if (recreateJoint_)
     {

+ 2 - 2
Engine/Physics/Joint.h

@@ -53,8 +53,8 @@ public:
     
     /// Handle attribute write access.
     virtual void OnSetAttribute(const AttributeInfo& attr, const Variant& src);
-    /// Perform finalization after a scene load or network update.
-    virtual void FinishUpdate();
+    /// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
+    virtual void ApplyAttributes();
     /// Return the depended on nodes to order network updates.
     virtual void GetDependencyNodes(PODVector<Node*>& dest);
     

+ 3 - 3
Engine/Scene/Node.cpp

@@ -167,13 +167,13 @@ bool Node::SaveXML(XMLElement& dest)
     return true;
 }
 
-void Node::FinishUpdate()
+void Node::ApplyAttributes()
 {
     for (unsigned i = 0; i < components_.Size(); ++i)
-        components_[i]->FinishUpdate();
+        components_[i]->ApplyAttributes();
     
     for (unsigned i = 0; i < children_.Size(); ++i)
-        children_[i]->FinishUpdate();
+        children_[i]->ApplyAttributes();
 }
 
 void Node::SetName(const String& name)

+ 2 - 2
Engine/Scene/Node.h

@@ -70,8 +70,8 @@ public:
     virtual bool Save(Serializer& dest);
     /// Save as XML data. Return true if successful.
     virtual bool SaveXML(XMLElement& dest);
-    /// Perform finalization for components and child nodes. Called after scene load, but not for network updates.
-    virtual void FinishUpdate();
+    /// Apply attribute changes that can not be applied immediately recursively to child nodes and components.
+    virtual void ApplyAttributes();
     
     /// %Set name.
     void SetName(const String& name);

+ 1 - 1
Engine/Scene/Scene.cpp

@@ -589,7 +589,7 @@ void Scene::FinishAsyncLoading()
 
 void Scene::FinishLoading(Deserializer* source)
 {
-    FinishUpdate();
+    ApplyAttributes();
     if (source)
     {
         fileName_ = source->GetName();

+ 1 - 1
Engine/Scene/Scene.h

@@ -156,7 +156,7 @@ private:
     void UpdateAsyncLoading();
     /// Finish asynchronous loading.
     void FinishAsyncLoading();
-    /// Finish loading.
+    /// Finish loading. Calls ApplyAttributes() recursively to the whole scene.
     void FinishLoading(Deserializer* source);
     
     /// Map of scene nodes by ID.

+ 2 - 2
Engine/Scene/Serializable.h

@@ -53,8 +53,8 @@ public:
     virtual bool LoadXML(const XMLElement& source);
     /// Save as XML data. Return true if successful.
     virtual bool SaveXML(XMLElement& dest);
-    /// Perform finalization after a scene load or network update.
-    virtual void FinishUpdate() {}
+    /// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
+    virtual void ApplyAttributes() {}
     
     /// %Set attribute by index. Return true if successfully set.
     bool SetAttribute(unsigned index, const Variant& value);

+ 2 - 2
Engine/Script/ScriptInstance.cpp

@@ -48,7 +48,7 @@ static const String methodDeclarations[] = {
     "void FixedPostUpdate(float)",
     "void Load(Deserializer&)",
     "void Save(Serializer&)",
-    "void FinishUpdate()"
+    "void ApplyAttributes()"
 };
 
 OBJECTTYPESTATIC(ScriptInstance);
@@ -84,7 +84,7 @@ void ScriptInstance::RegisterObject(Context* context)
     ACCESSOR_ATTRIBUTE(ScriptInstance, VAR_BUFFER, "Script Data", GetScriptDataAttr, SetScriptDataAttr, PODVector<unsigned char>, PODVector<unsigned char>(), AM_DEFAULT | AM_NOEDIT);
 }
 
-void ScriptInstance::FinishUpdate()
+void ScriptInstance::ApplyAttributes()
 {
     if (scriptObject_ && methods_[METHOD_FINISHUPDATE])
         scriptFile_->Execute(scriptObject_, methods_[METHOD_FINISHUPDATE]);

+ 2 - 2
Engine/Script/ScriptInstance.h

@@ -70,8 +70,8 @@ public:
     /// Register object factory.
     static void RegisterObject(Context* context);
     
-    /// Perform post-load after the whole scene has been loaded.
-    virtual void FinishUpdate();
+    /// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
+    virtual void ApplyAttributes();
     /// Add an event handler. Called by script exposed version of SubscribeToEvent().
     virtual void AddEventHandler(StringHash eventType, const String& handlerName);
     /// Add an event handler for a specific sender. Called by script exposed version of SubscribeToEvent().