Josh Engebretson 9 anos atrás
pai
commit
192286b1bc

+ 1 - 1
CMakeLists.txt

@@ -9,7 +9,7 @@ include(AtomicUtils)
 
 add_definitions(-DATOMIC_ROOT_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DATOMIC_ROOT_BUILD_DIR="${CMAKE_BINARY_DIR}")
 
-add_definitions( -DATOMIC_API= -DATOMIC_STATIC_DEFINE -DATOMIC_ATOMIC2D -DATOMIC_LOGGING -DATOMIC_PROFILING)
+add_definitions( -DATOMIC_API= -DATOMIC_STATIC_DEFINE -DATOMIC_ATOMIC2D -DATOMIC_LOGGING -DATOMIC_PROFILING -DATOMIC_THREADING)
 
 if (NOT DEFINED ATOMIC_DEV_BUILD)
     set(ATOMIC_DEV_BUILD 1)

+ 15 - 0
Source/Atomic/Core/Context.h

@@ -226,6 +226,21 @@ private:
     VariantMap globalVars_;
 
     // ATOMIC BEGIN
+
+    /// Begin event send.
+    void GlobalBeginSendEvent(Object* sender, StringHash eventType, VariantMap& eventData) {
+        for (unsigned i = 0; i < globalEventListeners_.Size(); i++)
+            globalEventListeners_[i]->BeginSendEvent(this, sender, eventType, eventData);
+        eventSenders_.Push(sender);
+    }
+
+    /// End event send. Clean up event receivers removed in the meanwhile.
+    void GlobalEndSendEvent(Object* sender, StringHash eventType, VariantMap& eventData) {
+        for (unsigned i = 0; i < globalEventListeners_.Size(); i++)
+            globalEventListeners_[i]->EndSendEvent(this, sender, eventType, eventData);
+        eventSenders_.Pop();
+    }
+
     PODVector<GlobalEventListener*> globalEventListeners_;
     bool editorContext_;
     // ATOMIC END

+ 8 - 0
Source/Atomic/Core/Object.cpp

@@ -320,6 +320,10 @@ void Object::SendEvent(StringHash eventType, VariantMap& eventData)
     Context* context = context_;
     HashSet<Object*> processed;
 
+// ATOMIC BEGIN
+    context->GlobalBeginSendEvent(this, eventType, eventData);
+// ATOMIC END
+
     context->BeginSendEvent(this);
 
     // Check first the specific event receivers
@@ -423,6 +427,10 @@ void Object::SendEvent(StringHash eventType, VariantMap& eventData)
 
     context->EndSendEvent();
 
+// ATOMIC BEGIN
+    context->GlobalEndSendEvent(this,eventType, eventData);
+// ATOMIC END
+
 #ifdef ATOMIC_PROFILING
     if (eventProfiler)
         eventProfiler->EndBlock();

+ 2 - 0
Source/Atomic/Core/WorkQueue.cpp

@@ -34,6 +34,8 @@ namespace Atomic
 /// Worker thread managed by the work queue.
 class WorkerThread : public Thread, public RefCounted
 {
+    ATOMIC_REFCOUNTED(WorkerThread)
+
 public:
     /// Construct.
     WorkerThread(WorkQueue* owner, unsigned index) :

+ 7 - 1
Source/Atomic/Graphics/Material.cpp

@@ -235,7 +235,8 @@ bool Material::BeginLoad(Deserializer& source)
     String extension = GetExtension(source.GetName());
 
     bool success = false;
-    if (extension == ".xml")
+    // ATOMIC BEGIN
+    if (extension == ".xml" || extension == ".material")
     {
         success = BeginLoadXML(source);
         if (!success)
@@ -248,11 +249,16 @@ bool Material::BeginLoad(Deserializer& source)
     {
         success = BeginLoadJSON(source);
         if (!success)
+        {
+            // reset position
+            source.Seek(0);
             success = BeginLoadXML(source);
+        }
 
         if (success)
             return true;
     }
+    // ATOMIC END
 
     // All loading failed
     ResetToDefaults();

+ 2 - 0
Source/Atomic/Resource/BackgroundLoader.h

@@ -52,6 +52,8 @@ struct BackgroundLoadItem
 /// Background loader of resources. Owned by the ResourceCache.
 class BackgroundLoader : public RefCounted, public Thread
 {
+    ATOMIC_REFCOUNTED(BackgroundLoader
+                      )
 public:
     /// Construct.
     BackgroundLoader(ResourceCache* owner);

+ 15 - 2
Source/Atomic/Scene/Node.cpp

@@ -1305,16 +1305,23 @@ void Node::GetComponents(PODVector<Component*>& dest, StringHash type, bool recu
 {
     dest.Clear();
 
+// ATOMIC BEGIN
+
+    bool all = type == Component::GetTypeStatic();
+
     if (!recursive)
     {
         for (Vector<SharedPtr<Component> >::ConstIterator i = components_.Begin(); i != components_.End(); ++i)
         {
-            if ((*i)->GetType() == type)
+            if (all || (*i)->GetType() == type)
                 dest.Push(*i);
         }
     }
     else
         GetComponentsRecursive(dest, type);
+
+    // ATOMIC END
+
 }
 
 bool Node::HasComponent(StringHash type) const
@@ -2093,13 +2100,19 @@ void Node::GetChildrenWithComponentRecursive(PODVector<Node*>& dest, StringHash
 
 void Node::GetComponentsRecursive(PODVector<Component*>& dest, StringHash type) const
 {
+    // ATOMIC BEGIN
+
+    bool all = type == Component::GetTypeStatic();
+
     for (Vector<SharedPtr<Component> >::ConstIterator i = components_.Begin(); i != components_.End(); ++i)
     {
-        if ((*i)->GetType() == type)
+        if (all || (*i)->GetType() == type)
             dest.Push(*i);
     }
     for (Vector<SharedPtr<Node> >::ConstIterator i = children_.Begin(); i != children_.End(); ++i)
         (*i)->GetComponentsRecursive(dest, type);
+
+    // ATOMIC END
 }
 
 void Node::GetChildrenWithTagRecursive(PODVector<Node*>& dest, const String& tag) const

+ 2 - 2
Source/AtomicWebView/WebTexture2D.cpp

@@ -121,7 +121,7 @@ public:
 
         if (type == PET_VIEW)
         {
-            glBindTexture(GL_TEXTURE_2D, (GLuint) ((GPUObjectHandle*)webTexture2D_->GetTexture2D()->GetGPUObject())->name_);
+            glBindTexture(GL_TEXTURE_2D, (GLuint) webTexture2D_->GetTexture2D()->GetGPUObjectName());
 
             glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
 
@@ -186,7 +186,7 @@ public:
                 h -= y + h - viewheight;
             }
 
-            glBindTexture(GL_TEXTURE_2D, (GLuint) ((GPUObjectHandle*)webTexture2D_->GetTexture2D()->GetGPUObject())->name_);
+            glBindTexture(GL_TEXTURE_2D, (GLuint) webTexture2D_->GetTexture2D()->GetGPUObjectName());
 
             // Update the popup rectangle.
             glPixelStorei(GL_UNPACK_ROW_LENGTH, width);