Browse Source

2D updates

Josh Engebretson 9 years ago
parent
commit
ead31a1741

+ 16 - 0
Source/Atomic/Atomic2D/Atomic2D.cpp

@@ -52,6 +52,12 @@
 #include "../Atomic2D/TileMapLayer2D.h"
 #include "../Atomic2D/TmxFile2D.h"
 
+// ATOMIC BEGIN
+
+#include "../Atomic2D/Light2D.h"
+
+// ATOMIC END
+
 #include "../DebugNew.h"
 
 namespace Atomic
@@ -102,6 +108,16 @@ void RegisterAtomic2DLibrary(Context* context)
     ConstraintRope2D::RegisterObject(context);
     ConstraintWeld2D::RegisterObject(context);
     ConstraintWheel2D::RegisterObject(context);
+
+// ATOMIC BEGIN
+
+    Light2DGroup::RegisterObject(context);
+    Light2D::RegisterObject(context);
+    DirectionalLight2D::RegisterObject(context);
+    PositionalLight2D::RegisterObject(context);
+    PointLight2D::RegisterObject(context);
+
+// ATOMIC END
 }
 
 }

+ 4 - 1
Source/Atomic/Atomic2D/Drawable2D.cpp

@@ -35,7 +35,10 @@
 namespace Atomic
 {
 
-const float PIXEL_SIZE = 0.01f;
+// ATOMIC BEGIN
+// defined in header
+// const float PIXEL_SIZE = 0.01f;
+// ATOMIC END
 
 SourceBatch2D::SourceBatch2D() :
     distance_(0.0f),

+ 4 - 1
Source/Atomic/Atomic2D/Drawable2D.h

@@ -62,8 +62,11 @@ struct SourceBatch2D
     Vector<Vertex2D> vertices_;
 };
 
+// ATOMIC BEGIN
+// Defined in header to be consistent with other constants
 /// Pixel size (equal 0.01f).
-extern ATOMIC_API const float PIXEL_SIZE;
+static const float PIXEL_SIZE = 0.01f;
+// ATOMIC END
 
 /// Base class for 2D visible components.
 class ATOMIC_API Drawable2D : public Drawable

+ 2 - 3
Source/Atomic/Atomic2D/Light2D.cpp

@@ -564,9 +564,7 @@ void Light2DGroup::OnSceneSet(Scene* scene)
 
         renderer_ = node_->GetOrCreateComponent<Renderer2D>();
         renderer_->SetTemporary(true);
-// ATOMIC_UPDATE_FIX_BEGIN
-        //renderer_->SetUseTris(true);
-// ATOMIC_UPDATE_FIX_END
+        renderer_->SetUseTris(true);
 
         if (light2DMaterial_.Null())
             CreateLight2DMaterial();
@@ -590,6 +588,7 @@ Light2DGroup::Light2DGroup(Context* context) : Drawable2D(context),
     frustum_(0)
 {
     sourceBatches_.Resize(1);
+    sourceBatches_[0].owner_ = this;
     SubscribeToEvent(E_BEGINRENDERING, ATOMIC_HANDLER(Light2DGroup, HandleBeginRendering));
     SubscribeToEvent(E_BEGINVIEWUPDATE, ATOMIC_HANDLER(Light2DGroup, HandleBeginViewUpdate));
 }

+ 27 - 1
Source/Atomic/Atomic2D/PhysicsEvents2D.h

@@ -24,13 +24,39 @@
 
 #include "../Core/Object.h"
 
+// ATOMIC BEGIN
+
+//  Discrete Physics2D Events
+
 // For prestep / poststep events, which are the same for 2D and 3D physics. The events themselves don't depend
 // on whether 3D physics support or Bullet has been compiled in.
-#include "../Physics/PhysicsEvents.h"
+// #include "../Physics/PhysicsEvents.h"
+
+// ATOMIC END
 
 namespace Atomic
 {
 
+
+// ATOMIC BEGIN
+
+/// Physics world is about to be stepped.
+ATOMIC_EVENT(E_PHYSICSPRESTEP2D, PhysicsPreStep2D)
+{
+    ATOMIC_PARAM(P_WORLD, World);                  // PhysicsWorld2D pointer
+    ATOMIC_PARAM(P_TIMESTEP, TimeStep);            // float
+}
+
+/// Physics world has been stepped.
+ATOMIC_EVENT(E_PHYSICSPOSTSTEP2D, PhysicsPostStep2D)
+{
+    ATOMIC_PARAM(P_WORLD, World);                  // PhysicsWorld2D pointer
+    ATOMIC_PARAM(P_TIMESTEP, TimeStep);            // float
+}
+
+// ATOMIC END
+
+
 /// Physics begin contact.
 ATOMIC_EVENT(E_PHYSICSBEGINCONTACT2D, PhysicsBeginContact2D)
 {

+ 17 - 6
Source/Atomic/Atomic2D/PhysicsWorld2D.cpp

@@ -66,8 +66,12 @@ PhysicsWorld2D::PhysicsWorld2D(Context* context) :
     // Set debug draw
     world_->SetDebugDraw(this);
 
-    world_->SetContinuousPhysics(true);
-    world_->SetSubStepping(true);
+    // BEGIN ATOMIC
+    // These should be false, as per the attribute defaults
+    world_->SetContinuousPhysics(false);
+    world_->SetSubStepping(false);
+    // END ATOMIC
+
 }
 
 PhysicsWorld2D::~PhysicsWorld2D()
@@ -228,12 +232,17 @@ void PhysicsWorld2D::Update(float timeStep)
 {
     ATOMIC_PROFILE(UpdatePhysics2D);
 
-    using namespace PhysicsPreStep;
+// ATOMIC BEGIN
+
+    using namespace PhysicsPreStep2D;
+
 
     VariantMap& eventData = GetEventDataMap();
     eventData[P_WORLD] = this;
     eventData[P_TIMESTEP] = timeStep;
-    SendEvent(E_PHYSICSPRESTEP, eventData);
+    SendEvent(E_PHYSICSPRESTEP2D, eventData);
+
+// ATOMIC END
 
     physicsStepping_ = true;
     world_->Step(timeStep, velocityIterations_, positionIterations_);
@@ -276,8 +285,10 @@ void PhysicsWorld2D::Update(float timeStep)
     SendBeginContactEvents();
     SendEndContactEvents();
 
-    using namespace PhysicsPostStep;
-    SendEvent(E_PHYSICSPOSTSTEP, eventData);
+// ATOMIC BEGIN
+    using namespace PhysicsPostStep2D;
+    SendEvent(E_PHYSICSPOSTSTEP2D, eventData);
+// ATOMIC END
 }
 
 void PhysicsWorld2D::DrawDebugGeometry()

+ 42 - 13
Source/Atomic/Atomic2D/Renderer2D.cpp

@@ -63,7 +63,10 @@ Renderer2D::Renderer2D(Context* context) :
     Drawable(context, DRAWABLE_GEOMETRY),
     material_(new Material(context)),
     indexBuffer_(new IndexBuffer(context_)),
-    viewMask_(DEFAULT_VIEWMASK)
+    viewMask_(DEFAULT_VIEWMASK),
+    // ATOMIC BEGIN
+    useTris_(false)
+    // ATOMIC END
 {
     material_->SetName("Atomic2D");
 
@@ -146,20 +149,30 @@ void Renderer2D::UpdateGeometry(const FrameInfo& frame)
         void* buffer = indexBuffer_->Lock(0, indexCount, true);
         if (buffer)
         {
-            unsigned quadCount = indexCount / 6;
+            // ATOMIC BEGIN
+            unsigned quadCount =  useTris_ ? indexCount/3 : indexCount / 6;
+            // ATOMIC END
+
             if (largeIndices)
             {
                 unsigned* dest = reinterpret_cast<unsigned*>(buffer);
                 for (unsigned i = 0; i < quadCount; ++i)
                 {
-                    unsigned base = i * 4;
+                    // ATOMIC BEGIN
+                    unsigned base = i * (useTris_ ? 3 : 4);
                     dest[0] = base;
                     dest[1] = base + 1;
                     dest[2] = base + 2;
-                    dest[3] = base;
-                    dest[4] = base + 2;
-                    dest[5] = base + 3;
-                    dest += 6;
+                    if (!useTris_)
+                    {
+                        dest[3] = base;
+                        dest[4] = base + 2;
+                        dest[5] = base + 3;
+                        dest += 6;
+                    }
+                    else
+                        dest += 3;
+                    // ATOMIC END
                 }
             }
             else
@@ -167,14 +180,21 @@ void Renderer2D::UpdateGeometry(const FrameInfo& frame)
                 unsigned short* dest = reinterpret_cast<unsigned short*>(buffer);
                 for (unsigned i = 0; i < quadCount; ++i)
                 {
-                    unsigned base = i * 4;
+                    // ATOMIC BEGIN
+                    unsigned base = i * (useTris_ ? 3 : 4);
                     dest[0] = (unsigned short)(base);
                     dest[1] = (unsigned short)(base + 1);
                     dest[2] = (unsigned short)(base + 2);
-                    dest[3] = (unsigned short)(base);
-                    dest[4] = (unsigned short)(base + 2);
-                    dest[5] = (unsigned short)(base + 3);
-                    dest += 6;
+                    if (!useTris_)
+                    {
+                        dest[3] = (unsigned short)(base);
+                        dest[4] = (unsigned short)(base + 2);
+                        dest[5] = (unsigned short)(base + 3);
+                        dest += 6;
+                    }
+                    else
+                        dest += 3;
+                    // ATOMIC END
                 }
             }
 
@@ -478,7 +498,16 @@ void Renderer2D::UpdateViewBatchInfo(ViewBatchInfo2D& viewBatchInfo, Camera* cam
             currMaterial = material;
         }
 
-        iCount += vertices.Size() * 6 / 4;
+        // ATOMIC BEGIN
+        unsigned indices;
+        if (useTris_)
+            indices = vertices.Size();
+        else
+            indices = vertices.Size() * 6 / 4;
+
+        iCount += indices;
+        // ATOMIC END
+
         vCount += vertices.Size();
     }
 

+ 15 - 0
Source/Atomic/Atomic2D/Renderer2D.h

@@ -98,6 +98,14 @@ public:
     /// Check visibility.
     bool CheckVisibility(Drawable2D* drawable) const;
 
+    // ATOMIC BEGIN
+
+    /// Whether this renderer uses triangles (instead of quads)
+    void SetUseTris(bool useTris) { useTris_ = useTris; }
+    bool GetUseTris() const { return useTris_; }
+
+    // ATOMIC END
+
 private:
     /// Recalculate the world-space bounding box.
     virtual void OnWorldBoundingBoxUpdate();
@@ -131,6 +139,13 @@ private:
     HashMap<Texture2D*, HashMap<int, SharedPtr<Material> > > cachedMaterials_;
     /// Cached techniques per blend mode.
     HashMap<int, SharedPtr<Technique> > cachedTechniques_;
+
+    // ATOMIC BEGIN
+
+    /// Whether or not the renderer containts tris (default is quads)
+    bool useTris_;
+
+    // ATOMIC END
 };
 
 }

+ 5 - 1
Source/Atomic/Atomic2D/RigidBody2D.cpp

@@ -52,7 +52,7 @@ RigidBody2D::RigidBody2D(Context* context) :
     useFixtureMass_(true),
     body_(0),
 // ATOMIC BEGIN
-    castShadows_(false)
+    castShadows_(true)
 // ATOMIC END
 {
     // Make sure the massData members are zero-initialized.
@@ -90,6 +90,10 @@ void RigidBody2D::RegisterObject(Context* context)
     ATOMIC_ACCESSOR_ATTRIBUTE("Awake", IsAwake, SetAwake, bool, true, AM_DEFAULT);
     ATOMIC_MIXED_ACCESSOR_ATTRIBUTE("Linear Velocity", GetLinearVelocity, SetLinearVelocity, Vector2, Vector2::ZERO, AM_DEFAULT);
     ATOMIC_ACCESSOR_ATTRIBUTE("Angular Velocity", GetAngularVelocity, SetAngularVelocity, float, 0.0f, AM_DEFAULT);
+
+    // ATOMIC BEGIN
+    ATOMIC_ACCESSOR_ATTRIBUTE("CastShadows", GetCastShadows, SetCastShadows, bool, true, AM_DEFAULT);
+    // ATOMIC END
 }
 
 

+ 1 - 1
Source/Atomic/Atomic2D/SpriteSheet2D.cpp

@@ -329,7 +329,7 @@ bool SpriteSheet2D::EndLoadFromJSONFile()
         JSONValue frameWidthVal = subTextureVal.Get("frameWidth");
         JSONValue frameHeightVal = subTextureVal.Get("frameHeight");
 
-        if (!frameHeightVal.IsNull() && !frameHeightVal.IsNull())
+        if (!frameWidthVal.IsNull() && !frameHeightVal.IsNull())
         {
             offset.x_ = subTextureVal.Get("frameX").GetInt();
             offset.y_ = subTextureVal.Get("frameY").GetInt();

+ 19 - 1
Source/Atomic/Atomic2D/TileMap2D.cpp

@@ -36,7 +36,10 @@
 namespace Atomic
 {
 
-extern const float PIXEL_SIZE;
+// ATOMIC BEGIN
+// extern const float PIXEL_SIZE;
+// ATOMIC END
+
 extern const char* ATOMIC2D_CATEGORY;
 
 TileMap2D::TileMap2D(Context* context) :
@@ -185,4 +188,19 @@ ResourceRef TileMap2D::GetTmxFileAttr() const
     return GetResourceRef(tmxFile_, TmxFile2D::GetTypeStatic());
 }
 
+// ATOMIC BEGIN
+
+TileMapLayer2D* TileMap2D::GetLayerByName(const String& name) const
+{
+    for (unsigned i = 0; i < layers_.Size(); i++)
+    {
+        if (layers_[i]->GetName() == name)
+            return layers_[i];
+    }
+
+    return 0;
+}
+
+// ATOMIC END
+
 }

+ 6 - 0
Source/Atomic/Atomic2D/TileMap2D.h

@@ -73,6 +73,12 @@ public:
     /// Return tile map file attribute.
     ResourceRef GetTmxFileAttr() const;
 
+    // ATOMIC BEGIN
+
+    TileMapLayer2D* GetLayerByName(const String& name) const;
+
+    // ATOMIC END
+
 private:
     /// Tmx file.
     SharedPtr<TmxFile2D> tmxFile_;

+ 43 - 1
Source/Atomic/Atomic2D/TileMapDefs2D.cpp

@@ -26,11 +26,21 @@
 #include "../Resource/JSONFile.h"
 #include "../Atomic2D/TileMapDefs2D.h"
 
+// ATOMIC BEGIN
+#include "../Scene/Node.h"
+#include "../Atomic2D/CollisionBox2D.h"
+#include "../Atomic2D/Drawable2D.h"
+#include "../Atomic2D/TmxFile2D.h"
+// ATOMIC END
+
 #include "../DebugNew.h"
 
 namespace Atomic
 {
-extern ATOMIC_API const float PIXEL_SIZE;
+
+// ATOMIC BEGIN
+// extern ATOMIC_API const float PIXEL_SIZE;
+// ATOMIC END
 
 float TileMapInfo2D::GetMapWidth() const
 {
@@ -229,4 +239,36 @@ const String& TileMapObject2D::GetProperty(const String& name) const
     return propertySet_->GetProperty(name);
 }
 
+// ATOMIC BEGIN
+
+TmxObjectGroup2D* Tile2D::GetObjectGroup() const
+{
+    return objectGroup_;
+}
+
+bool TileMapObject2D::ValidCollisionShape() const
+{
+    if (objectType_ == OT_RECTANGLE)
+        return true;
+
+    return false;
+}
+
+CollisionShape2D* TileMapObject2D::CreateCollisionShape(Node *node) const
+{
+    CollisionShape2D* shape = NULL;
+
+    if (objectType_ == OT_RECTANGLE)
+    {
+        CollisionBox2D* box = node->CreateComponent<CollisionBox2D>();
+        box->SetSize(size_);
+        box->SetCenter(position_);
+        shape = box;
+    }
+
+    return shape;
+}
+
+// ATOMIC END
+
 }

+ 23 - 0
Source/Atomic/Atomic2D/TileMapDefs2D.h

@@ -30,6 +30,12 @@ namespace Atomic
 
 class XMLElement;
 
+// ATOMIC BEGIN
+class TmxObjectGroup2D;
+class CollisionShape2D;
+class Node;
+// ATOMIC END
+
 /// Orientation.
 enum Orientation2D
 {
@@ -138,6 +144,13 @@ public:
     /// Return property.
     const String& GetProperty(const String& name) const;
 
+    // ATOMIC BEGIN
+
+    /// Return Object Group.
+    TmxObjectGroup2D* GetObjectGroup() const;
+
+    // ATOMIC END
+
 private:
     friend class TmxTileLayer2D;
 
@@ -147,6 +160,11 @@ private:
     SharedPtr<Sprite2D> sprite_;
     /// Property set.
     SharedPtr<PropertySet2D> propertySet_;
+
+    // ATOMIC BEGIN
+    /// Object group (collision)
+    SharedPtr<TmxObjectGroup2D> objectGroup_;
+    // ATOMIC END
 };
 
 /// Tile map object.
@@ -187,6 +205,11 @@ public:
     /// Return property value.
     const String& GetProperty(const String& name) const;
 
+    // ATOMIC BEGIN
+    bool ValidCollisionShape() const;
+    CollisionShape2D* CreateCollisionShape(Node* node) const;
+    // ATOMIC END
+
 private:
     friend class TmxObjectGroup2D;
 

+ 51 - 1
Source/Atomic/Atomic2D/TileMapLayer2D.cpp

@@ -31,6 +31,10 @@
 #include "../Atomic2D/TileMapLayer2D.h"
 #include "../Atomic2D/TmxFile2D.h"
 
+// ATOMIC BEGIN
+#include "../Atomic2D/RigidBody2D.h"
+// ATOMIC END
+
 #include "../DebugNew.h"
 
 namespace Atomic
@@ -309,6 +313,35 @@ void TileMapLayer2D::SetTileLayer(const TmxTileLayer2D* tileLayer)
             staticSprite->SetLayer(drawOrder_);
             staticSprite->SetOrderInLayer(y * width + x);
 
+            // ATOMIC BEGIN
+
+            // collision
+            RigidBody2D *body = NULL;
+            TmxObjectGroup2D* group = tile->GetObjectGroup();
+            if (group)
+            {
+                for (unsigned i = 0; i < group->GetNumObjects(); i++)
+                {
+                    TileMapObject2D* o = group->GetObject(i);
+
+                    if (o->ValidCollisionShape())
+                    {
+                        if (!body)
+                        {
+                            body = tileNode->CreateComponent<RigidBody2D>();
+                            body->SetBodyType(BT_STATIC);
+                        }
+
+                        o->CreateCollisionShape(tileNode);
+
+                    }
+                }
+
+            }
+
+
+            // ATOMIC END
+
             nodes_[y * width + x] = tileNode;
         }
     }
@@ -326,7 +359,11 @@ void TileMapLayer2D::SetObjectGroup(const TmxObjectGroup2D* objectGroup)
         const TileMapObject2D* object = objectGroup->GetObject(i);
 
         // Create dummy node for all object
-        SharedPtr<Node> objectNode(GetNode()->CreateChild("Object"));
+
+        // ATOMIC BEGIN
+        SharedPtr<Node> objectNode(GetNode()->CreateChild(object->GetName()));
+        // ATOMIC END
+
         objectNode->SetTemporary(true);
         objectNode->SetPosition(object->GetPosition());
 
@@ -367,4 +404,17 @@ void TileMapLayer2D::SetImageLayer(const TmxImageLayer2D* imageLayer)
     nodes_.Push(imageNode);
 }
 
+// ATOMIC BEGIN
+
+const String& TileMapLayer2D::GetName() const
+{
+    static String none("");
+    if (tmxLayer_)
+        return tmxLayer_->GetName();
+
+    return none;
+}
+
+// ATOMIC END
+
 }

+ 4 - 0
Source/Atomic/Atomic2D/TileMapLayer2D.h

@@ -97,6 +97,10 @@ public:
     /// Return image node (for image layer only).
     Node* GetImageNode() const;
 
+    // ATOMIC BEGIN
+    const String& GetName() const;
+    // ATOMIC END
+
 private:
     /// Set tile layer.
     void SetTileLayer(const TmxTileLayer2D* tileLayer);

+ 117 - 11
Source/Atomic/Atomic2D/TmxFile2D.cpp

@@ -31,12 +31,18 @@
 #include "../Atomic2D/Sprite2D.h"
 #include "../Atomic2D/TmxFile2D.h"
 
+// ATOMIC BEGIN
+#include "../Atomic2D/Drawable2D.h"
+// ATOMIC END
+
 #include "../DebugNew.h"
 
 namespace Atomic
 {
 
-extern const float PIXEL_SIZE;
+// ATOMIC BEGIN
+// extern const float PIXEL_SIZE;
+// ATOMIC END
 
 TmxLayer2D::TmxLayer2D(TmxFile2D* tmxFile, TileMapLayerType2D type) :
     tmxFile_(tmxFile),
@@ -124,6 +130,11 @@ bool TmxTileLayer2D::Load(const XMLElement& element, const TileMapInfo2D& info)
                 tile->gid_ = gid;
                 tile->sprite_ = tmxFile_->GetTileSprite(gid);
                 tile->propertySet_ = tmxFile_->GetTilePropertySet(gid);
+
+// ATOMIC BEGIN
+                tile->objectGroup_ = tmxFile_->GetTileObjectGroup(gid);
+// ATOMIC END
+
                 tiles_[y * width_ + x] = tile;
             }
 
@@ -150,7 +161,7 @@ TmxObjectGroup2D::TmxObjectGroup2D(TmxFile2D* tmxFile) :
 {
 }
 
-bool TmxObjectGroup2D::Load(const XMLElement& element, const TileMapInfo2D& info)
+bool TmxObjectGroup2D::Load(const XMLElement& element, const TileMapInfo2D& info, bool local)
 {
     LoadInfo(element);
 
@@ -158,8 +169,15 @@ bool TmxObjectGroup2D::Load(const XMLElement& element, const TileMapInfo2D& info
     {
         SharedPtr<TileMapObject2D> object(new TileMapObject2D());
 
+        // ATOMIC BEGIN
+
         if (objectElem.HasAttribute("name"))
             object->name_ = objectElem.GetAttribute("name");
+        else
+            object->name_ = "Object";
+
+        // ATOMIC END
+
         if (objectElem.HasAttribute("type"))
             object->type_ = objectElem.GetAttribute("type");
 
@@ -181,8 +199,30 @@ bool TmxObjectGroup2D::Load(const XMLElement& element, const TileMapInfo2D& info
         {
         case OT_RECTANGLE:
         case OT_ELLIPSE:
-            object->position_ = info.ConvertPosition(Vector2(position.x_, position.y_ + size.y_));
+
+            // ATOMIC BEGIN
             object->size_ = Vector2(size.x_ * PIXEL_SIZE, size.y_ * PIXEL_SIZE);
+
+
+            if (!local)
+            {
+                object->position_ = info.ConvertPosition(Vector2(position.x_, position.y_ + size.y_));
+            }
+            else
+            {
+                Vector2 nposition = position;
+
+                nposition.x_ *= PIXEL_SIZE;
+                nposition.y_ *= PIXEL_SIZE;
+
+                nposition.x_ = nposition.x_ + object->size_.x_ / 2.0f;
+                nposition.y_ = nposition.y_ + object->size_.y_ / 2.0f;
+
+                nposition.y_ = info.tileHeight_  - nposition.y_;
+
+                object->position_ = nposition;
+            }
+            // ATOMIC END
             break;
 
         case OT_TILE:
@@ -298,8 +338,14 @@ TmxFile2D::TmxFile2D(Context* context) :
 
 TmxFile2D::~TmxFile2D()
 {
-    for (unsigned i = 0; i < layers_.Size(); ++i)
-        delete layers_[i];
+// ATOMIC BEGIN
+
+    // use shared ptr
+
+    //for (unsigned i = 0; i < layers_.Size(); ++i)
+    //    delete layers_[i];
+
+// ATOMIC END
 }
 
 void TmxFile2D::RegisterObject(Context* context)
@@ -408,16 +454,17 @@ bool TmxFile2D::EndLoad()
         String name = childElement.GetName();
         if (name == "tileset")
             ret = LoadTileSet(childElement);
+// ATOMIC BEGIN
         else if (name == "layer")
         {
-            TmxTileLayer2D* tileLayer = new TmxTileLayer2D(this);
+            SharedPtr<TmxTileLayer2D> tileLayer (new TmxTileLayer2D(this));
             ret = tileLayer->Load(childElement, info_);
 
             layers_.Push(tileLayer);
         }
         else if (name == "objectgroup")
         {
-            TmxObjectGroup2D* objectGroup = new TmxObjectGroup2D(this);
+            SharedPtr<TmxObjectGroup2D> objectGroup (new TmxObjectGroup2D(this));\
             ret = objectGroup->Load(childElement, info_);
 
             layers_.Push(objectGroup);
@@ -425,11 +472,12 @@ bool TmxFile2D::EndLoad()
         }
         else if (name == "imagelayer")
         {
-            TmxImageLayer2D* imageLayer = new TmxImageLayer2D(this);
+            SharedPtr<TmxImageLayer2D> imageLayer (new TmxImageLayer2D(this));
             ret = imageLayer->Load(childElement, info_);
 
             layers_.Push(imageLayer);
         }
+// ATOMIC END
 
         if (!ret)
         {
@@ -458,15 +506,19 @@ bool TmxFile2D::SetInfo(Orientation2D orientation, int width, int height, float
 
 void TmxFile2D::AddLayer(unsigned index, TmxLayer2D *layer)
 {
+// ATOMIC BEGIN
     if (index > layers_.Size())
-        layers_.Push(layer);
+        layers_.Push(SharedPtr<TmxLayer2D>(layer));
     else // index <= layers_.size()
-        layers_.Insert(index, layer);
+        layers_.Insert(index, SharedPtr<TmxLayer2D>(layer));
+// ATOMIC END
 }
 
 void TmxFile2D::AddLayer(TmxLayer2D *layer)
 {
-    layers_.Push(layer);
+// ATOMIC BEGIN
+    layers_.Push(SharedPtr<TmxLayer2D>(layer));
+// ATOMIC END
 }
 
 Sprite2D* TmxFile2D::GetTileSprite(int gid) const
@@ -544,6 +596,13 @@ bool TmxFile2D::LoadTileSet(const XMLElement& element)
         return false;
     }
 
+    // ATOMIC BEGIN
+
+    // reduces border tile sample errors
+    texture->SetFilterMode(FILTER_NEAREST);
+
+    // ATOMIC END
+
     tileSetTextures_.Push(texture);
 
     int tileWidth = tileSetElem.GetInt("tilewidth");
@@ -584,9 +643,56 @@ bool TmxFile2D::LoadTileSet(const XMLElement& element)
             propertySet->Load(tileElem.GetChild("properties"));
             gidToPropertySetMapping_[firstgid + tileElem.GetInt("id")] = propertySet;
         }
+
+        // ATOMIC BEGIN
+
+        // collision information
+        if (tileElem.HasChild("objectgroup"))
+        {
+            // ok, when you use multiple tile sets the "info"
+            // numbers can be different, this is a bit of a hack
+            // if something is wrong, look here... may have to need
+            // to refactor "info" to be per set
+
+            float _tileWidth = info_.tileWidth_;
+            float _tileHeight = info_.tileHeight_;
+
+            info_.tileHeight_ = (float) tileHeight * PIXEL_SIZE;
+            info_.tileWidth_ = (float) tileWidth * PIXEL_SIZE;
+
+            XMLElement groupElem = tileElem.GetChild("objectgroup");
+            TmxObjectGroup2D* objectGroup = new TmxObjectGroup2D(this);
+            if (!objectGroup->Load(groupElem, info_, true))
+            {
+                ATOMIC_LOGERROR("Could not load objectgroup");
+                objectGroup->ReleaseRef();
+            }
+            else
+            {
+                gidToObjectGroupMapping_[firstgid + tileElem.GetInt("id")] = objectGroup;
+            }
+
+            info_.tileWidth_ = _tileWidth;
+            info_.tileHeight_ = _tileHeight;
+        }
+
+        // ATOMIC END
+
     }
 
     return true;
 }
 
+// BEGIN ATOMIC
+
+TmxObjectGroup2D* TmxFile2D::GetTileObjectGroup(int gid) const
+{
+    HashMap<int, SharedPtr<TmxObjectGroup2D> >::ConstIterator i = gidToObjectGroupMapping_.Find(gid);
+    if (i == gidToObjectGroupMapping_.End())
+        return 0;
+    return i->second_;
+}
+
+// END ATOMIC
+
 }

+ 24 - 2
Source/Atomic/Atomic2D/TmxFile2D.h

@@ -92,6 +92,8 @@ protected:
 /// Tmx tile layer.
 class TmxTileLayer2D : public TmxLayer2D
 {
+    ATOMIC_REFCOUNTED(TmxTileLayer2D)
+
 public:
     TmxTileLayer2D(TmxFile2D* tmxFile);
 
@@ -108,11 +110,15 @@ protected:
 /// Tmx image layer.
 class TmxObjectGroup2D : public TmxLayer2D
 {
+    ATOMIC_REFCOUNTED(TmxObjectGroup2D)
+
 public:
     TmxObjectGroup2D(TmxFile2D* tmxFile);
 
+// ATOMIC BEGIN
     /// Load from XML element.
-    bool Load(const XMLElement& element, const TileMapInfo2D& info);
+    bool Load(const XMLElement& element, const TileMapInfo2D& info, bool local = false);
+// ATOMIC END
 
     /// Return number of objects.
     unsigned GetNumObjects() const { return objects_.Size(); }
@@ -128,6 +134,8 @@ private:
 /// Tmx image layer.
 class TmxImageLayer2D : public TmxLayer2D
 {
+    ATOMIC_REFCOUNTED(TmxImageLayer2D)
+
 public:
     TmxImageLayer2D(TmxFile2D* tmxFile);
 
@@ -194,6 +202,12 @@ public:
     /// Return layer at index.
     const TmxLayer2D* GetLayer(unsigned index) const;
 
+    // BEGIN ATOMIC
+
+    TmxObjectGroup2D* GetTileObjectGroup(int gid) const;
+
+    // END ATOMIC
+
 private:
     /// Load TSX file.
     SharedPtr<XMLFile> LoadTSXFile(const String& source);
@@ -212,8 +226,16 @@ private:
     HashMap<int, SharedPtr<Sprite2D> > gidToSpriteMapping_;
     /// Gid to tile property set mapping.
     HashMap<int, SharedPtr<PropertySet2D> > gidToPropertySetMapping_;
+
+    // ATOMIC BEGIN
+
     /// Layers.
-    Vector<TmxLayer2D*> layers_;
+    Vector<SharedPtr<TmxLayer2D>> layers_;
+
+    /// Gid to tile objectgroup  mapping.
+    HashMap<int, SharedPtr<TmxObjectGroup2D> > gidToObjectGroupMapping_;
+
+    // ATOMIC END
 };
 
 }

+ 5 - 2
Source/Atomic/Input/Input.cpp

@@ -331,8 +331,11 @@ Input::Input(Context* context) :
     mouseMoveWheel_(0),
     windowID_(0),
     toggleFullscreen_(true),
-    mouseVisible_(false),
-    lastMouseVisible_(false),
+// ATOMIC BEGIN
+    // default mouse to visible
+    mouseVisible_(true),
+    lastMouseVisible_(true),
+// ATOMIC END
     mouseGrabbed_(false),
     lastMouseGrabbed_(false),
     mouseMode_(MM_ABSOLUTE),

+ 0 - 7
Source/AtomicWebView/WebKeyboard.h

@@ -41,7 +41,6 @@ struct WebKeyEvent
     bool repeat;
     int key;
     int scanCode;
-    unsigned raw;
     int buttons;
     int qual;
     bool keyDown;
@@ -54,9 +53,6 @@ struct WebKeyEvent
             repeat = eventData[KeyDown::P_REPEAT].GetBool();
             key = eventData[KeyDown::P_KEY].GetInt();
             scanCode = eventData[KeyDown::P_SCANCODE].GetInt();
-// ATOMIC_UPDATE_FIX_BEGIN
-            //raw = eventData[KeyDown::P_RAW].GetUInt();
-// ATOMIC_UPDATE_FIX_END
             buttons = eventData[KeyDown::P_BUTTONS].GetInt();
             qual = eventData[KeyDown::P_QUALIFIERS].GetInt();
         }
@@ -65,9 +61,6 @@ struct WebKeyEvent
             keyDown = false;
             key = eventData[KeyUp::P_KEY].GetInt();
             scanCode = eventData[KeyUp::P_SCANCODE].GetInt();
-// ATOMIC_UPDATE_FIX_BEGIN
-//            raw = eventData[KeyUp::P_RAW].GetUInt();
-// ATOMIC_UPDATE_FIX_END
             buttons = eventData[KeyUp::P_BUTTONS].GetInt();
             qual = eventData[KeyUp::P_QUALIFIERS].GetInt();
         }