فهرست منبع

Merge pull request #382 from dgough/next

Bug fixes and minor API additions
Sean Paul Taylor 13 سال پیش
والد
کامیت
876d31da53
55فایلهای تغییر یافته به همراه853 افزوده شده و 748 حذف شده
  1. 2 2
      gameplay/src/Animation.cpp
  2. 4 4
      gameplay/src/AnimationTarget.cpp
  3. 1 1
      gameplay/src/AudioBuffer.cpp
  4. 1 1
      gameplay/src/Base.h
  5. 10 10
      gameplay/src/BoundingBox.h
  6. 26 26
      gameplay/src/Button.cpp
  7. 9 9
      gameplay/src/CheckBox.cpp
  8. 69 69
      gameplay/src/Container.cpp
  9. 11 11
      gameplay/src/Control.cpp
  10. 16 2
      gameplay/src/FileSystem.cpp
  11. 5 8
      gameplay/src/Font.cpp
  12. 1 1
      gameplay/src/Form.cpp
  13. 8 1
      gameplay/src/Game.h
  14. 5 0
      gameplay/src/Game.inl
  15. 4 4
      gameplay/src/Joystick.cpp
  16. 1 4
      gameplay/src/Material.cpp
  17. 7 0
      gameplay/src/MaterialParameter.cpp
  18. 7 0
      gameplay/src/MaterialParameter.h
  19. 13 13
      gameplay/src/MathUtil.h
  20. 123 123
      gameplay/src/MathUtil.inl
  21. 185 185
      gameplay/src/MathUtilNeon.inl
  22. 2 2
      gameplay/src/Matrix.cpp
  23. 4 4
      gameplay/src/PhysicsController.cpp
  24. 2 0
      gameplay/src/PhysicsRigidBody.h
  25. 15 15
      gameplay/src/PlatformLinux.cpp
  26. 1 1
      gameplay/src/PlatformMacOSX.mm
  27. 70 71
      gameplay/src/PlatformQNX.cpp
  28. 3 4
      gameplay/src/PlatformWin32.cpp
  29. 4 4
      gameplay/src/PlatformiOS.mm
  30. 8 14
      gameplay/src/Properties.cpp
  31. 1 1
      gameplay/src/Quaternion.cpp
  32. 12 12
      gameplay/src/RadioButton.cpp
  33. 1 1
      gameplay/src/Rectangle.cpp
  34. 1 1
      gameplay/src/Rectangle.h
  35. 1 1
      gameplay/src/RenderState.cpp
  36. 1 1
      gameplay/src/RenderTarget.cpp
  37. 3 9
      gameplay/src/SceneLoader.cpp
  38. 1 1
      gameplay/src/SceneLoader.h
  39. 13 13
      gameplay/src/ScriptController.cpp
  40. 55 55
      gameplay/src/ScriptController.h
  41. 32 32
      gameplay/src/ScriptController.inl
  42. 1 4
      gameplay/src/Slider.cpp
  43. 4 4
      gameplay/src/SpriteBatch.h
  44. 11 11
      gameplay/src/TextBox.cpp
  45. 1 1
      gameplay/src/TextBox.h
  46. 1 0
      gameplay/src/Texture.cpp
  47. 5 7
      gameplay/src/Theme.cpp
  48. 2 2
      gameplay/src/Transform.cpp
  49. 1 1
      gameplay/src/Vector4.cpp
  50. 1 1
      gameplay/src/gameplay-main-ios.mm
  51. 1 1
      gameplay/src/gameplay-main-macosx.mm
  52. 38 0
      gameplay/src/lua/lua_Game.cpp
  53. 1 0
      gameplay/src/lua/lua_Game.h
  54. 47 0
      gameplay/src/lua/lua_MaterialParameter.cpp
  55. 1 0
      gameplay/src/lua/lua_MaterialParameter.h

+ 2 - 2
gameplay/src/Animation.cpp

@@ -344,7 +344,7 @@ Animation::Channel* Animation::createChannel(AnimationTarget* target, int proper
     normalizedKeyTimes[i] = 1.0f;
     curve->setPoint(i, normalizedKeyTimes[i], keyValues + pointOffset, (Curve::InterpolationType) type);
 
-    SAFE_DELETE(normalizedKeyTimes);
+    SAFE_DELETE_ARRAY(normalizedKeyTimes);
 
     Channel* channel = new Channel(this, target, propertyId, curve, duration);
     curve->release();
@@ -386,7 +386,7 @@ Animation::Channel* Animation::createChannel(AnimationTarget* target, int proper
     normalizedKeyTimes[i] = 1.0f;
     curve->setPoint(i, normalizedKeyTimes[i], keyValues + pointOffset, (Curve::InterpolationType) type, keyInValue + pointOffset, keyOutValue + pointOffset);
 
-    SAFE_DELETE(normalizedKeyTimes);
+    SAFE_DELETE_ARRAY(normalizedKeyTimes);
 
     Channel* channel = new Channel(this, target, propertyId, curve, duration);
     curve->release();

+ 4 - 4
gameplay/src/AnimationTarget.cpp

@@ -261,10 +261,10 @@ Animation* AnimationTarget::createAnimation(const char* id, Properties* animatio
         animation = createAnimation(id, propertyId, keyCount, keyTimes, keyValues, (Curve::InterpolationType) curve);
     }
 
-    SAFE_DELETE(keyOut);
-    SAFE_DELETE(keyIn);
-    SAFE_DELETE(keyValues);
-    SAFE_DELETE(keyTimes);
+    SAFE_DELETE_ARRAY(keyOut);
+    SAFE_DELETE_ARRAY(keyIn);
+    SAFE_DELETE_ARRAY(keyValues);
+    SAFE_DELETE_ARRAY(keyTimes);
 
     Properties* pClip = animationProperties->getNextNamespace();
     if (pClip && std::strcmp(pClip->getNamespace(), "clip") == 0)

+ 1 - 1
gameplay/src/AudioBuffer.cpp

@@ -101,7 +101,7 @@ AudioBuffer* AudioBuffer::create(const char* path)
         goto cleanup;
     }
 
-	//NOTE: loadOgg actually sets this null, so it is expected
+    //NOTE: loadOgg actually sets this null, so it is expected
     if (file)    
         fclose(file);
 

+ 1 - 1
gameplay/src/Base.h

@@ -201,7 +201,7 @@ using std::va_list;
         #define USE_NEON
     #endif
 #elif __ANDROID__
-	#include <EGL/egl.h>
+    #include <EGL/egl.h>
     #include <GLES2/gl2.h>
     #include <GLES2/gl2ext.h>
     extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray;

+ 10 - 10
gameplay/src/BoundingBox.h

@@ -39,11 +39,11 @@ public:
     /**
      * Constructs a new bounding box from the specified values.
      * 
-     * @param minX The x coordinate of the minimum point of the bounding box.
-     * @param minY The y coordinate of the minimum point of the bounding box.
-     * @param minZ The z coordinate of the minimum point of the bounding box.
-     * @param maxX The x coordinate of the maximum point of the bounding box.
-     * @param maxY The y coordinate of the maximum point of the bounding box.
+     * @param minX The x coordinate of the minimum point of the bounding box.
+     * @param minY The y coordinate of the minimum point of the bounding box.
+     * @param minZ The z coordinate of the minimum point of the bounding box.
+     * @param maxX The x coordinate of the maximum point of the bounding box.
+     * @param maxY The y coordinate of the maximum point of the bounding box.
      * @param maxZ The z coordinate of the maximum point of the bounding box.
      */
     BoundingBox(float minX, float minY, float minZ, float maxX, float maxY, float maxZ);
@@ -178,11 +178,11 @@ public:
     /**
      * Sets this bounding box to the specified values.
      * 
-     * @param minX The x coordinate of the minimum point of the bounding box.
-     * @param minY The y coordinate of the minimum point of the bounding box.
-     * @param minZ The z coordinate of the minimum point of the bounding box.
-     * @param maxX The x coordinate of the maximum point of the bounding box.
-     * @param maxY The y coordinate of the maximum point of the bounding box.
+     * @param minX The x coordinate of the minimum point of the bounding box.
+     * @param minY The y coordinate of the minimum point of the bounding box.
+     * @param minZ The z coordinate of the minimum point of the bounding box.
+     * @param maxX The x coordinate of the maximum point of the bounding box.
+     * @param maxY The y coordinate of the maximum point of the bounding box.
      * @param maxZ The z coordinate of the maximum point of the bounding box.
      */
     void set(float minX, float minY, float minZ, float maxX, float maxY, float maxZ);

+ 26 - 26
gameplay/src/Button.cpp

@@ -40,41 +40,41 @@ bool Button::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contac
     case Touch::TOUCH_PRESS:
         if (_contactIndex == INVALID_CONTACT_INDEX)
         {
-			if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
-				y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
-			{
-				_contactIndex = (int) contactIndex;
+            if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
+                y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
+            {
+                _contactIndex = (int) contactIndex;
 
-				setState(Control::ACTIVE);
+                setState(Control::ACTIVE);
 
-				notifyListeners(Listener::PRESS);
+                notifyListeners(Listener::PRESS);
 
-				return _consumeInputEvents;
-			}
-			else
-			{
-				setState(Control::NORMAL);
-			}
+                return _consumeInputEvents;
+            }
+            else
+            {
+                setState(Control::NORMAL);
+            }
         }
         break;
 
     case Touch::TOUCH_RELEASE:
         if (_contactIndex == (int) contactIndex)
         {
-			_contactIndex = INVALID_CONTACT_INDEX;
-			notifyListeners(Listener::RELEASE);
-			if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
-				y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
-			{
-				setState(Control::FOCUS);
-
-				notifyListeners(Listener::CLICK);
-			}
-			else
-			{
-				setState(Control::NORMAL);
-			}
-			return _consumeInputEvents;
+            _contactIndex = INVALID_CONTACT_INDEX;
+            notifyListeners(Listener::RELEASE);
+            if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
+                y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
+            {
+                setState(Control::FOCUS);
+
+                notifyListeners(Listener::CLICK);
+            }
+            else
+            {
+                setState(Control::NORMAL);
+            }
+            return _consumeInputEvents;
         }
         break;
     case Touch::TOUCH_MOVE:

+ 9 - 9
gameplay/src/CheckBox.cpp

@@ -84,15 +84,15 @@ bool CheckBox::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int cont
     switch (evt)
     {
     case Touch::TOUCH_RELEASE:
-		if (_contactIndex == (int) contactIndex && _state == Control::ACTIVE)
-		{
-			if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
-				y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
-			{
-				_checked = !_checked;
-				notifyListeners(Control::Listener::VALUE_CHANGED);
-			}
-		}
+        if (_contactIndex == (int) contactIndex && _state == Control::ACTIVE)
+        {
+            if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
+                y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
+            {
+                _checked = !_checked;
+                notifyListeners(Control::Listener::VALUE_CHANGED);
+            }
+        }
         break;
     }
 

+ 69 - 69
gameplay/src/Container.cpp

@@ -730,26 +730,26 @@ bool Container::touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned i
     switch(evt)
     {
     case Touch::TOUCH_PRESS:
-    	if (_contactIndex == INVALID_CONTACT_INDEX)
-    	{
-    		_contactIndex = (int) contactIndex;
-    		_contactIndices++;
-			_scrollingLastX = _scrollingFirstX = x;
-			_scrollingLastY = _scrollingFirstY = y;
-			_scrollingVelocity.set(0, 0);
-			_scrolling = true;
-			_scrollingStartTimeX = _scrollingStartTimeY = 0;
-
-			if (_scrollBarOpacityClip && _scrollBarOpacityClip->isPlaying())
-			{
-				_scrollBarOpacityClip->stop();
-				_scrollBarOpacityClip = NULL;
-			}
-			_scrollBarOpacity = 1.0f;
+        if (_contactIndex == INVALID_CONTACT_INDEX)
+        {
+            _contactIndex = (int) contactIndex;
+            _contactIndices++;
+            _scrollingLastX = _scrollingFirstX = x;
+            _scrollingLastY = _scrollingFirstY = y;
+            _scrollingVelocity.set(0, 0);
+            _scrolling = true;
+            _scrollingStartTimeX = _scrollingStartTimeY = 0;
+
+            if (_scrollBarOpacityClip && _scrollBarOpacityClip->isPlaying())
+            {
+                _scrollBarOpacityClip->stop();
+                _scrollBarOpacityClip = NULL;
+            }
+            _scrollBarOpacity = 1.0f;
             _dirty = true;
-			return _consumeInputEvents;
-    	}
-		break;
+            return _consumeInputEvents;
+        }
+        break;
     case Touch::TOUCH_MOVE:
         if (_scrolling && _contactIndex == (int) contactIndex)
         {
@@ -814,58 +814,58 @@ bool Container::touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned i
         break;
 
     case Touch::TOUCH_RELEASE:
-    	if (_contactIndex == (int) contactIndex)
-    	{
-    		_contactIndex = INVALID_CONTACT_INDEX;
-    		_contactIndices--;
-			_scrolling = false;
-			double gameTime = Game::getAbsoluteTime();
-			float timeSinceLastMove = (float)(gameTime - _scrollingLastTime);
-			if (timeSinceLastMove > SCROLL_INERTIA_DELAY)
-			{
-				_scrollingVelocity.set(0, 0);
-				_scrollingMouseVertically = _scrollingMouseHorizontally = false;
+        if (_contactIndex == (int) contactIndex)
+        {
+            _contactIndex = INVALID_CONTACT_INDEX;
+            _contactIndices--;
+            _scrolling = false;
+            double gameTime = Game::getAbsoluteTime();
+            float timeSinceLastMove = (float)(gameTime - _scrollingLastTime);
+            if (timeSinceLastMove > SCROLL_INERTIA_DELAY)
+            {
+                _scrollingVelocity.set(0, 0);
+                _scrollingMouseVertically = _scrollingMouseHorizontally = false;
                 _dirty = true;
-				return _consumeInputEvents;
-			}
-
-			int dx = _scrollingLastX - _scrollingFirstX;
-			int dy = _scrollingLastY - _scrollingFirstY;
-
-			float timeTakenX = (float)(gameTime - _scrollingStartTimeX);
-			float elapsedSecsX = timeTakenX * 0.001f;
-			float timeTakenY = (float)(gameTime - _scrollingStartTimeY);
-			float elapsedSecsY = timeTakenY * 0.001f;
-
-			float vx = dx;
-			float vy = dy;
-			if (elapsedSecsX > 0)
-				vx = (float)dx / elapsedSecsX;
-			if (elapsedSecsY > 0)
-				vy = (float)dy / elapsedSecsY;
-
-			if (_scrollingMouseVertically)
-			{
-				float yRatio = _totalHeight / _absoluteBounds.height;
-				vy *= yRatio;
-				_scrollingVelocity.set(0, -vy);
-			}
-			else if (_scrollingMouseHorizontally)
-			{
-				float xRatio = _totalWidth / _absoluteBounds.width;
-				vx *= xRatio;
-				_scrollingVelocity.set(-vx, 0);
-			}
-			else
-			{
-				_scrollingVelocity.set(vx, vy);
-			}
-
-			_scrollingMouseVertically = _scrollingMouseHorizontally = false;
+                return _consumeInputEvents;
+            }
+
+            int dx = _scrollingLastX - _scrollingFirstX;
+            int dy = _scrollingLastY - _scrollingFirstY;
+
+            float timeTakenX = (float)(gameTime - _scrollingStartTimeX);
+            float elapsedSecsX = timeTakenX * 0.001f;
+            float timeTakenY = (float)(gameTime - _scrollingStartTimeY);
+            float elapsedSecsY = timeTakenY * 0.001f;
+
+            float vx = dx;
+            float vy = dy;
+            if (elapsedSecsX > 0)
+                vx = (float)dx / elapsedSecsX;
+            if (elapsedSecsY > 0)
+                vy = (float)dy / elapsedSecsY;
+
+            if (_scrollingMouseVertically)
+            {
+                float yRatio = _totalHeight / _absoluteBounds.height;
+                vy *= yRatio;
+                _scrollingVelocity.set(0, -vy);
+            }
+            else if (_scrollingMouseHorizontally)
+            {
+                float xRatio = _totalWidth / _absoluteBounds.width;
+                vx *= xRatio;
+                _scrollingVelocity.set(-vx, 0);
+            }
+            else
+            {
+                _scrollingVelocity.set(vx, vy);
+            }
+
+            _scrollingMouseVertically = _scrollingMouseHorizontally = false;
             _dirty = true;
-			return _consumeInputEvents;
-    	}
-    	break;
+            return _consumeInputEvents;
+        }
+        break;
     }
 
     return false;

+ 11 - 11
gameplay/src/Control.cpp

@@ -744,20 +744,20 @@ bool Control::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int conta
     case Touch::TOUCH_RELEASE:
         if (_contactIndex == (int)contactIndex)
         {
-			_contactIndex = INVALID_CONTACT_INDEX;
+            _contactIndex = INVALID_CONTACT_INDEX;
 
-			// Always trigger Listener::RELEASE
-			notifyListeners(Listener::RELEASE);
+            // Always trigger Listener::RELEASE
+            notifyListeners(Listener::RELEASE);
 
-			// Only trigger Listener::CLICK if both PRESS and RELEASE took place within the control's bounds.
-			if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
-				y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
-			{
-				// Leave this control in the FOCUS state.
-				notifyListeners(Listener::CLICK);
-			}
+            // Only trigger Listener::CLICK if both PRESS and RELEASE took place within the control's bounds.
+            if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
+                y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
+            {
+                // Leave this control in the FOCUS state.
+                notifyListeners(Listener::CLICK);
+            }
 
-			return _consumeInputEvents;
+            return _consumeInputEvents;
         }
         break;
     }

+ 16 - 2
gameplay/src/FileSystem.cpp

@@ -219,7 +219,14 @@ bool FileSystem::fileExists(const char* filePath)
         fullPath += "../../gameplay/";
         fullPath += filePath;
         
-        return stat(fullPath.c_str(), &s) == 0;
+        int result = stat(fullPath.c_str(), &s);
+        if (result != 0)
+        {
+            fullPath = __resourcePath;
+            fullPath += "../gameplay/";
+            fullPath += filePath;
+            return stat(fullPath.c_str(), &s) == 0;
+        }
     }
     return true;
 #else
@@ -248,6 +255,13 @@ FILE* FileSystem::openFile(const char* path, const char* mode)
         fullPath += path;
         
         fp = fopen(fullPath.c_str(), mode);
+        if (!fp)
+        {
+            fullPath = __resourcePath;
+            fullPath += "../gameplay/";
+            fullPath += path;
+            fp = fopen(fullPath.c_str(), mode);
+        }
     }
 #endif
 
@@ -335,7 +349,7 @@ void createFileFromAsset(const char* path)
     std::string directoryPath = fullPath.substr(0, fullPath.rfind('/'));
     struct stat s;
     if (stat(directoryPath.c_str(), &s) != 0)
-        makepath(directoryPath.c_str(), 0777);
+        makepath(directoryPath, 0777);
 
     // To ensure that the files on the file system corresponding to the assets in the APK bundle
     // are always up to date (and in sync), we copy them from the APK to the file system once

+ 5 - 8
gameplay/src/Font.cpp

@@ -139,11 +139,7 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
 
     // Create batch for the font.
     SpriteBatch* batch = SpriteBatch::create(texture, __fontEffect, 128);
-
-    // Add linear filtering for better font quality.
-    Texture::Sampler* sampler = batch->getSampler();
-    sampler->setFilterMode(Texture::LINEAR, Texture::LINEAR);
-
+    
     // Release __fontEffect since the SpriteBatch keeps a reference to it
     SAFE_RELEASE(__fontEffect);
 
@@ -153,6 +149,10 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
         return NULL;
     }
 
+    // Add linear filtering for better font quality.
+    Texture::Sampler* sampler = batch->getSampler();
+    sampler->setFilterMode(Texture::LINEAR, Texture::LINEAR);
+
     // Increase the ref count of the texture to retain it.
     texture->addRef();
 
@@ -193,7 +193,6 @@ Font::Text* Font::createText(const char* text, const Rectangle& area, const Vect
         size = _size;
     GP_ASSERT(_size);
     float scale = (float)size / _size;
-    const int length = strlen(text);
     int yPos = area.y;
     const float areaHeight = area.height - size;
     std::vector<int> xPositions;
@@ -554,7 +553,6 @@ void Font::drawText(const char* text, const Rectangle& area, const Vector4& colo
         size = _size;
     GP_ASSERT(_size);
     float scale = (float)size / _size;
-    const int length = strlen(text);
     int yPos = area.y;
     const float areaHeight = area.height - size;
     std::vector<int> xPositions;
@@ -1327,7 +1325,6 @@ int Font::getIndexOrLocation(const char* text, const Rectangle& area, unsigned i
 
     // Essentially need to measure text until we reach inLocation.
     float scale = (float)size / _size;
-    const int length = strlen(text);
     int yPos = area.y;
     const float areaHeight = area.height - size;
     std::vector<int> xPositions;

+ 1 - 1
gameplay/src/Form.cpp

@@ -40,7 +40,7 @@ static std::vector<Form*> __forms;
 
 Form::Form() : _theme(NULL), _frameBuffer(NULL), _spriteBatch(NULL), _node(NULL), _nodeQuad(NULL), _nodeMaterial(NULL) , _u2(0), _v1(0)
 {
-	_consumeInputEvents = false;
+    _consumeInputEvents = false;
 }
 
 Form::~Form()

+ 8 - 1
gameplay/src/Game.h

@@ -174,6 +174,13 @@ public:
      * @return The game window height.
      */
     inline unsigned int getHeight() const;
+    
+    /**
+     * Gets the aspect ratio of the window. (width / height)
+     * 
+     * @return The aspect ratio of the window.
+     */
+    inline float getAspectRatio() const;
 
     /**
      * Gets the game current viewport.
@@ -183,7 +190,7 @@ public:
     inline const Rectangle& getViewport() const;
 
     /**
-     * Set the game current viewport.
+     * Sets the game current viewport.
      *
      * The x, y, width and height of the viewport must all be positive.
      *

+ 5 - 0
gameplay/src/Game.inl

@@ -29,6 +29,11 @@ inline unsigned int Game::getHeight() const
     return _height;
 }
 
+inline float Game::getAspectRatio() const
+{
+    return (float)_width / (float)_height;
+}
+
 inline const Rectangle& Game::getViewport() const
 {
     return _viewport;

+ 4 - 4
gameplay/src/Joystick.cpp

@@ -4,7 +4,7 @@
 namespace gameplay
 {
 
-Joystick::Joystick() : _relative(true), _innerSize(NULL), _outerSize(NULL)
+Joystick::Joystick() : _radius(1.0f), _relative(true), _innerSize(NULL), _outerSize(NULL)
 {
 }
 
@@ -47,6 +47,7 @@ void Joystick::initialize(Theme::Style* style, Properties* properties)
         return;
     }
     _radius = properties->getFloat("radius");
+    GP_ASSERT(_radius != 0.0f);
 
     if (properties->exists("relative"))
     {
@@ -95,7 +96,6 @@ void Joystick::initialize(Theme::Style* style, Properties* properties)
         if (inner)
         {
             const Rectangle& rect = inner->getRegion();
-            float radiusx2 = _radius * 2;;
             _screenRegion.width = rect.width;
             _screenRegion.height = rect.height;
         }
@@ -147,7 +147,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
 
                 // If the displacement is greater than the radius, then cap the displacement to the
                 // radius.
-                
+                
                 Vector2 value;
                 if ((fabs(_displacement.x) > _radius) || (fabs(_displacement.y) > _radius))
                 {
@@ -183,7 +183,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
                 float dy = -(y - ((_relative) ? _screenRegion.y - _bounds.y : 0.0f) - _screenRegion.height * 0.5f);
             
                 _displacement.set(dx, dy);
-            
+            
                 Vector2 value;
                 if ((fabs(_displacement.x) > _radius) || (fabs(_displacement.y) > _radius))
                 {

+ 1 - 4
gameplay/src/Material.cpp

@@ -21,10 +21,7 @@ Material::~Material()
     for (unsigned int i = 0, count = _techniques.size(); i < count; ++i)
     {
         Technique* technique = _techniques[i];
-        if (technique)
-        {
-            SAFE_RELEASE(technique);
-        }
+        SAFE_RELEASE(technique);
     }
 }
 

+ 7 - 0
gameplay/src/MaterialParameter.cpp

@@ -68,6 +68,13 @@ const char* MaterialParameter::getName() const
     return _name.c_str();
 }
 
+Texture::Sampler* MaterialParameter::getSampler() const
+{
+    if (_type == MaterialParameter::SAMPLER)
+        return const_cast<Texture::Sampler*>(_value.samplerValue);
+    return NULL;
+}
+
 void MaterialParameter::setValue(float value)
 {
     clearValue();

+ 7 - 0
gameplay/src/MaterialParameter.h

@@ -44,6 +44,13 @@ public:
      */
     const char* getName() const;
 
+    /**
+     * Returns the texture sampler or NULL if this MaterialParameter is not a sampler type.
+     * 
+     * @return The texture sampler or NULL if this MaterialParameter is not a sampler type.
+     */
+    Texture::Sampler* getSampler() const;
+
     /**
      * Sets the value of this parameter to a float value.
      */

+ 13 - 13
gameplay/src/MathUtil.h

@@ -8,32 +8,32 @@ namespace gameplay
  */
 class MathUtil
 {
-	friend class Matrix;
-	friend class Vector3;
+    friend class Matrix;
+    friend class Vector3;
 
 private:
 
-	inline static void addMatrix(const float* m, float scalar, float* dst);
+    inline static void addMatrix(const float* m, float scalar, float* dst);
 
-	inline static void addMatrix(const float* m1, const float* m2, float* dst);
+    inline static void addMatrix(const float* m1, const float* m2, float* dst);
 
-	inline static void subtractMatrix(const float* m1, const float* m2, float* dst);
+    inline static void subtractMatrix(const float* m1, const float* m2, float* dst);
 
-	inline static void multiplyMatrix(const float* m, float scalar, float* dst);
+    inline static void multiplyMatrix(const float* m, float scalar, float* dst);
 
-	inline static void multiplyMatrix(const float* m1, const float* m2, float* dst);
+    inline static void multiplyMatrix(const float* m1, const float* m2, float* dst);
 
-	inline static void negateMatrix(const float* m, float* dst);
+    inline static void negateMatrix(const float* m, float* dst);
 
-	inline static void transposeMatrix(const float* m, float* dst);
+    inline static void transposeMatrix(const float* m, float* dst);
 
-	inline static void transformVector4(const float* m, float x, float y, float z, float w, float* dst);
+    inline static void transformVector4(const float* m, float x, float y, float z, float w, float* dst);
 
-	inline static void transformVector4(const float* m, const float* v, float* dst);
+    inline static void transformVector4(const float* m, const float* v, float* dst);
 
-	inline static void crossVector3(const float* v1, const float* v2, float* dst);
+    inline static void crossVector3(const float* v1, const float* v2, float* dst);
 
-	MathUtil();
+    MathUtil();
 };
 
 }

+ 123 - 123
gameplay/src/MathUtil.inl

@@ -3,173 +3,173 @@ namespace gameplay
 
 inline void MathUtil::addMatrix(const float* m, float scalar, float* dst)
 {
-	dst[0]  = m[0]  + scalar;
-	dst[1]  = m[1]  + scalar;
-	dst[2]  = m[2]  + scalar;
-	dst[3]  = m[3]  + scalar;
-	dst[4]  = m[4]  + scalar;
-	dst[5]  = m[5]  + scalar;
-	dst[6]  = m[6]  + scalar;
-	dst[7]  = m[7]  + scalar;
-	dst[8]  = m[8]  + scalar;
-	dst[9]  = m[9]  + scalar;
-	dst[10] = m[10] + scalar;
-	dst[11] = m[11] + scalar;
-	dst[12] = m[12] + scalar;
-	dst[13] = m[13] + scalar;
-	dst[14] = m[14] + scalar;
-	dst[15] = m[15] + scalar;
+    dst[0]  = m[0]  + scalar;
+    dst[1]  = m[1]  + scalar;
+    dst[2]  = m[2]  + scalar;
+    dst[3]  = m[3]  + scalar;
+    dst[4]  = m[4]  + scalar;
+    dst[5]  = m[5]  + scalar;
+    dst[6]  = m[6]  + scalar;
+    dst[7]  = m[7]  + scalar;
+    dst[8]  = m[8]  + scalar;
+    dst[9]  = m[9]  + scalar;
+    dst[10] = m[10] + scalar;
+    dst[11] = m[11] + scalar;
+    dst[12] = m[12] + scalar;
+    dst[13] = m[13] + scalar;
+    dst[14] = m[14] + scalar;
+    dst[15] = m[15] + scalar;
 }
 
 inline void MathUtil::addMatrix(const float* m1, const float* m2, float* dst)
 {
-	dst[0]  = m1[0]  + m2[0];
-	dst[1]  = m1[1]  + m2[1];
-	dst[2]  = m1[2]  + m2[2];
-	dst[3]  = m1[3]  + m2[3];
-	dst[4]  = m1[4]  + m2[4];
-	dst[5]  = m1[5]  + m2[5];
-	dst[6]  = m1[6]  + m2[6];
-	dst[7]  = m1[7]  + m2[7];
-	dst[8]  = m1[8]  + m2[8];
-	dst[9]  = m1[9]  + m2[9];
-	dst[10] = m1[10] + m2[10];
-	dst[11] = m1[11] + m2[11];
-	dst[12] = m1[12] + m2[12];
-	dst[13] = m1[13] + m2[13];
-	dst[14] = m1[14] + m2[14];
-	dst[15] = m1[15] + m2[15];
+    dst[0]  = m1[0]  + m2[0];
+    dst[1]  = m1[1]  + m2[1];
+    dst[2]  = m1[2]  + m2[2];
+    dst[3]  = m1[3]  + m2[3];
+    dst[4]  = m1[4]  + m2[4];
+    dst[5]  = m1[5]  + m2[5];
+    dst[6]  = m1[6]  + m2[6];
+    dst[7]  = m1[7]  + m2[7];
+    dst[8]  = m1[8]  + m2[8];
+    dst[9]  = m1[9]  + m2[9];
+    dst[10] = m1[10] + m2[10];
+    dst[11] = m1[11] + m2[11];
+    dst[12] = m1[12] + m2[12];
+    dst[13] = m1[13] + m2[13];
+    dst[14] = m1[14] + m2[14];
+    dst[15] = m1[15] + m2[15];
 }
 
 inline void MathUtil::subtractMatrix(const float* m1, const float* m2, float* dst)
 {
-	dst[0]  = m1[0]  - m2[0];
-	dst[1]  = m1[1]  - m2[1];
-	dst[2]  = m1[2]  - m2[2];
-	dst[3]  = m1[3]  - m2[3];
-	dst[4]  = m1[4]  - m2[4];
-	dst[5]  = m1[5]  - m2[5];
-	dst[6]  = m1[6]  - m2[6];
-	dst[7]  = m1[7]  - m2[7];
-	dst[8]  = m1[8]  - m2[8];
-	dst[9]  = m1[9]  - m2[9];
-	dst[10] = m1[10] - m2[10];
-	dst[11] = m1[11] - m2[11];
-	dst[12] = m1[12] - m2[12];
-	dst[13] = m1[13] - m2[13];
-	dst[14] = m1[14] - m2[14];
-	dst[15] = m1[15] - m2[15];
+    dst[0]  = m1[0]  - m2[0];
+    dst[1]  = m1[1]  - m2[1];
+    dst[2]  = m1[2]  - m2[2];
+    dst[3]  = m1[3]  - m2[3];
+    dst[4]  = m1[4]  - m2[4];
+    dst[5]  = m1[5]  - m2[5];
+    dst[6]  = m1[6]  - m2[6];
+    dst[7]  = m1[7]  - m2[7];
+    dst[8]  = m1[8]  - m2[8];
+    dst[9]  = m1[9]  - m2[9];
+    dst[10] = m1[10] - m2[10];
+    dst[11] = m1[11] - m2[11];
+    dst[12] = m1[12] - m2[12];
+    dst[13] = m1[13] - m2[13];
+    dst[14] = m1[14] - m2[14];
+    dst[15] = m1[15] - m2[15];
 }
 
 inline void MathUtil::multiplyMatrix(const float* m, float scalar, float* dst)
 {
-	dst[0]  = m[0]  * scalar;
-	dst[1]  = m[1]  * scalar;
-	dst[2]  = m[2]  * scalar;
-	dst[3]  = m[3]  * scalar;
-	dst[4]  = m[4]  * scalar;
-	dst[5]  = m[5]  * scalar;
-	dst[6]  = m[6]  * scalar;
-	dst[7]  = m[7]  * scalar;
-	dst[8]  = m[8]  * scalar;
-	dst[9]  = m[9]  * scalar;
-	dst[10] = m[10] * scalar;
-	dst[11] = m[11] * scalar;
-	dst[12] = m[12] * scalar;
-	dst[13] = m[13] * scalar;
-	dst[14] = m[14] * scalar;
-	dst[15] = m[15] * scalar;
+    dst[0]  = m[0]  * scalar;
+    dst[1]  = m[1]  * scalar;
+    dst[2]  = m[2]  * scalar;
+    dst[3]  = m[3]  * scalar;
+    dst[4]  = m[4]  * scalar;
+    dst[5]  = m[5]  * scalar;
+    dst[6]  = m[6]  * scalar;
+    dst[7]  = m[7]  * scalar;
+    dst[8]  = m[8]  * scalar;
+    dst[9]  = m[9]  * scalar;
+    dst[10] = m[10] * scalar;
+    dst[11] = m[11] * scalar;
+    dst[12] = m[12] * scalar;
+    dst[13] = m[13] * scalar;
+    dst[14] = m[14] * scalar;
+    dst[15] = m[15] * scalar;
 }
 
 inline void MathUtil::multiplyMatrix(const float* m1, const float* m2, float* dst)
 {
-	// Support the case where m1 or m2 is the same array as dst.
-	float product[16];
-
-	product[0]  = m1[0] * m2[0]  + m1[4] * m2[1] + m1[8]   * m2[2]  + m1[12] * m2[3];
-	product[1]  = m1[1] * m2[0]  + m1[5] * m2[1] + m1[9]   * m2[2]  + m1[13] * m2[3];
-	product[2]  = m1[2] * m2[0]  + m1[6] * m2[1] + m1[10]  * m2[2]  + m1[14] * m2[3];
-	product[3]  = m1[3] * m2[0]  + m1[7] * m2[1] + m1[11]  * m2[2]  + m1[15] * m2[3];
-
-	product[4]  = m1[0] * m2[4]  + m1[4] * m2[5] + m1[8]   * m2[6]  + m1[12] * m2[7];
-	product[5]  = m1[1] * m2[4]  + m1[5] * m2[5] + m1[9]   * m2[6]  + m1[13] * m2[7];
-	product[6]  = m1[2] * m2[4]  + m1[6] * m2[5] + m1[10]  * m2[6]  + m1[14] * m2[7];
-	product[7]  = m1[3] * m2[4]  + m1[7] * m2[5] + m1[11]  * m2[6]  + m1[15] * m2[7];
-
-	product[8]  = m1[0] * m2[8]  + m1[4] * m2[9] + m1[8]   * m2[10] + m1[12] * m2[11];
-	product[9]  = m1[1] * m2[8]  + m1[5] * m2[9] + m1[9]   * m2[10] + m1[13] * m2[11];
-	product[10] = m1[2] * m2[8]  + m1[6] * m2[9] + m1[10]  * m2[10] + m1[14] * m2[11];
-	product[11] = m1[3] * m2[8]  + m1[7] * m2[9] + m1[11]  * m2[10] + m1[15] * m2[11];
-
-	product[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8]  * m2[14] + m1[12] * m2[15];
-	product[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9]  * m2[14] + m1[13] * m2[15];
-	product[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15];
-	product[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15];
-
-	memcpy(dst, product, MATRIX_SIZE);
+    // Support the case where m1 or m2 is the same array as dst.
+    float product[16];
+
+    product[0]  = m1[0] * m2[0]  + m1[4] * m2[1] + m1[8]   * m2[2]  + m1[12] * m2[3];
+    product[1]  = m1[1] * m2[0]  + m1[5] * m2[1] + m1[9]   * m2[2]  + m1[13] * m2[3];
+    product[2]  = m1[2] * m2[0]  + m1[6] * m2[1] + m1[10]  * m2[2]  + m1[14] * m2[3];
+    product[3]  = m1[3] * m2[0]  + m1[7] * m2[1] + m1[11]  * m2[2]  + m1[15] * m2[3];
+
+    product[4]  = m1[0] * m2[4]  + m1[4] * m2[5] + m1[8]   * m2[6]  + m1[12] * m2[7];
+    product[5]  = m1[1] * m2[4]  + m1[5] * m2[5] + m1[9]   * m2[6]  + m1[13] * m2[7];
+    product[6]  = m1[2] * m2[4]  + m1[6] * m2[5] + m1[10]  * m2[6]  + m1[14] * m2[7];
+    product[7]  = m1[3] * m2[4]  + m1[7] * m2[5] + m1[11]  * m2[6]  + m1[15] * m2[7];
+
+    product[8]  = m1[0] * m2[8]  + m1[4] * m2[9] + m1[8]   * m2[10] + m1[12] * m2[11];
+    product[9]  = m1[1] * m2[8]  + m1[5] * m2[9] + m1[9]   * m2[10] + m1[13] * m2[11];
+    product[10] = m1[2] * m2[8]  + m1[6] * m2[9] + m1[10]  * m2[10] + m1[14] * m2[11];
+    product[11] = m1[3] * m2[8]  + m1[7] * m2[9] + m1[11]  * m2[10] + m1[15] * m2[11];
+
+    product[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8]  * m2[14] + m1[12] * m2[15];
+    product[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9]  * m2[14] + m1[13] * m2[15];
+    product[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15];
+    product[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15];
+
+    memcpy(dst, product, MATRIX_SIZE);
 }
 
 inline void MathUtil::negateMatrix(const float* m, float* dst)
 {
-	dst[0]  = -m[0];
-	dst[1]  = -m[1];
-	dst[2]  = -m[2];
-	dst[3]  = -m[3];
-	dst[4]  = -m[4];
-	dst[5]  = -m[5];
-	dst[6]  = -m[6];
-	dst[7]  = -m[7];
-	dst[8]  = -m[8];
-	dst[9]  = -m[9];
-	dst[10] = -m[10];
-	dst[11] = -m[11];
-	dst[12] = -m[12];
-	dst[13] = -m[13];
-	dst[14] = -m[14];
-	dst[15] = -m[15];
+    dst[0]  = -m[0];
+    dst[1]  = -m[1];
+    dst[2]  = -m[2];
+    dst[3]  = -m[3];
+    dst[4]  = -m[4];
+    dst[5]  = -m[5];
+    dst[6]  = -m[6];
+    dst[7]  = -m[7];
+    dst[8]  = -m[8];
+    dst[9]  = -m[9];
+    dst[10] = -m[10];
+    dst[11] = -m[11];
+    dst[12] = -m[12];
+    dst[13] = -m[13];
+    dst[14] = -m[14];
+    dst[15] = -m[15];
 }
 
 inline void MathUtil::transposeMatrix(const float* m, float* dst)
 {
-	float t[16] = {
-		m[0], m[4], m[8], m[12],
-		m[1], m[5], m[9], m[13],
-		m[2], m[6], m[10], m[14],
-		m[3], m[7], m[11], m[15]
-	};
-	memcpy(dst, t, MATRIX_SIZE);
+    float t[16] = {
+        m[0], m[4], m[8], m[12],
+        m[1], m[5], m[9], m[13],
+        m[2], m[6], m[10], m[14],
+        m[3], m[7], m[11], m[15]
+    };
+    memcpy(dst, t, MATRIX_SIZE);
 }
 
 inline void MathUtil::transformVector4(const float* m, float x, float y, float z, float w, float* dst)
 {
-	dst[0] = x * m[0] + y * m[4] + z * m[8] + w * m[12];
-	dst[1] = x * m[1] + y * m[5] + z * m[9] + w * m[13];
-	dst[2] = x * m[2] + y * m[6] + z * m[10] + w * m[14];
+    dst[0] = x * m[0] + y * m[4] + z * m[8] + w * m[12];
+    dst[1] = x * m[1] + y * m[5] + z * m[9] + w * m[13];
+    dst[2] = x * m[2] + y * m[6] + z * m[10] + w * m[14];
 }
 
 inline void MathUtil::transformVector4(const float* m, const float* v, float* dst)
 {
     // Handle case where v == dst.
     float x = v[0] * m[0] + v[1] * m[4] + v[2] * m[8] + v[3] * m[12];
-	float y = v[0] * m[1] + v[1] * m[5] + v[2] * m[9] + v[3] * m[13];
+    float y = v[0] * m[1] + v[1] * m[5] + v[2] * m[9] + v[3] * m[13];
     float z = v[0] * m[2] + v[1] * m[6] + v[2] * m[10] + v[3] * m[14];
     float w = v[0] * m[3] + v[1] * m[7] + v[2] * m[11] + v[3] * m[15];
 
     dst[0] = x;
     dst[1] = y;
-	dst[2] = z;
-	dst[3] = w;
+    dst[2] = z;
+    dst[3] = w;
 }
 
 inline void MathUtil::crossVector3(const float* v1, const float* v2, float* dst)
 {
-	float x = (v1[1] * v2[2]) - (v1[2] * v2[1]);
-	float y = (v1[2] * v2[0]) - (v1[0] * v2[2]);
-	float z = (v1[0] * v2[1]) - (v1[1] * v2[0]);
+    float x = (v1[1] * v2[2]) - (v1[2] * v2[1]);
+    float y = (v1[2] * v2[0]) - (v1[0] * v2[2]);
+    float z = (v1[0] * v2[1]) - (v1[1] * v2[0]);
 
-	dst[0] = x;
-	dst[1] = y;
-	dst[2] = z;
+    dst[0] = x;
+    dst[1] = y;
+    dst[2] = z;
 }
 
 }

+ 185 - 185
gameplay/src/MathUtilNeon.inl

@@ -3,227 +3,227 @@ namespace gameplay
 
 inline void MathUtil::addMatrix(const float* m, float scalar, float* dst)
 {
-	asm volatile(
-		"vld1.32 {q0, q1}, [%1]! 	\n\t" // M[m0-m7]
-		"vld1.32 {q2, q3}, [%1] 	\n\t" // M[m8-m15]
-		"vld1.32 {d8[0]},  [%2] 	\n\t" // s
-		"vmov.f32 s17, s16          \n\t" // s
-		"vmov.f32 s18, s16          \n\t" // s
-		"vmov.f32 s19, s16          \n\t" // s
-
-		"vadd.f32 q8, q0, q4  		\n\t" // DST->M[m0-m3] = M[m0-m3] + s
-		"vadd.f32 q9, q1, q4 		\n\t" // DST->M[m4-m7] = M[m4-m7] + s
-		"vadd.f32 q10, q2, q4 		\n\t" // DST->M[m8-m11] = M[m8-m11] + s
-		"vadd.f32 q11, q3, q4 		\n\t" // DST->M[m12-m15] = M[m12-m15] + s
-
-		"vst1.32 {q8, q9}, [%0]!  	\n\t" // DST->M[m0-m7]
-		"vst1.32 {q10, q11}, [%0]   \n\t" // DST->M[m8-m15]
-		:
-		: "r"(dst), "r"(m), "r"(&scalar)
-		: "q0", "q1", "q2", "q3", "q4", "q8", "q9", "q10", "q11", "memory"
-	);
+    asm volatile(
+        "vld1.32 {q0, q1}, [%1]!    \n\t" // M[m0-m7]
+        "vld1.32 {q2, q3}, [%1]     \n\t" // M[m8-m15]
+        "vld1.32 {d8[0]},  [%2]     \n\t" // s
+        "vmov.f32 s17, s16          \n\t" // s
+        "vmov.f32 s18, s16          \n\t" // s
+        "vmov.f32 s19, s16          \n\t" // s
+
+        "vadd.f32 q8, q0, q4        \n\t" // DST->M[m0-m3] = M[m0-m3] + s
+        "vadd.f32 q9, q1, q4        \n\t" // DST->M[m4-m7] = M[m4-m7] + s
+        "vadd.f32 q10, q2, q4       \n\t" // DST->M[m8-m11] = M[m8-m11] + s
+        "vadd.f32 q11, q3, q4       \n\t" // DST->M[m12-m15] = M[m12-m15] + s
+
+        "vst1.32 {q8, q9}, [%0]!    \n\t" // DST->M[m0-m7]
+        "vst1.32 {q10, q11}, [%0]   \n\t" // DST->M[m8-m15]
+        :
+        : "r"(dst), "r"(m), "r"(&scalar)
+        : "q0", "q1", "q2", "q3", "q4", "q8", "q9", "q10", "q11", "memory"
+    );
 }
 
 inline void MathUtil::addMatrix(const float* m1, const float* m2, float* dst)
 {
-	asm volatile(
-		"vld1.32 	{q0, q1}, 	[%1]! 	\n\t" // M1[m0-m7]
-		"vld1.32 	{q2, q3}, 	[%1] 	\n\t" // M1[m8-m15]
-		"vld1.32 	{q8, q9}, 	[%2]! 	\n\t" // M2[m0-m7]
-		"vld1.32 	{q10, q11}, [%2]  	\n\t" // M2[m8-m15]
-
-		"vadd.f32   q12, q0, q8 		\n\t" // DST->M[m0-m3] = M1[m0-m3] + M2[m0-m3]
-		"vadd.f32   q13, q1, q9			\n\t" // DST->M[m4-m7] = M1[m4-m7] + M2[m4-m7]
-		"vadd.f32   q14, q2, q10		\n\t" // DST->M[m8-m11] = M1[m8-m11] + M2[m8-m11]
-		"vadd.f32   q15, q3, q11		\n\t" // DST->M[m12-m15] = M1[m12-m15] + M2[m12-m15]
-
-		"vst1.32    {q12, q13}, [%0]!   \n\t" // DST->M[m0-m7]
-		"vst1.32    {q14, q15}, [%0]    \n\t" // DST->M[m8-m15]
-		:
-		: "r"(dst), "r"(m1), "r"(m2)
-		: "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", "memory"
-	);
+    asm volatile(
+        "vld1.32     {q0, q1},     [%1]! \n\t" // M1[m0-m7]
+        "vld1.32     {q2, q3},     [%1]  \n\t" // M1[m8-m15]
+        "vld1.32     {q8, q9},     [%2]! \n\t" // M2[m0-m7]
+        "vld1.32     {q10, q11}, [%2]    \n\t" // M2[m8-m15]
+
+        "vadd.f32   q12, q0, q8          \n\t" // DST->M[m0-m3] = M1[m0-m3] + M2[m0-m3]
+        "vadd.f32   q13, q1, q9          \n\t" // DST->M[m4-m7] = M1[m4-m7] + M2[m4-m7]
+        "vadd.f32   q14, q2, q10         \n\t" // DST->M[m8-m11] = M1[m8-m11] + M2[m8-m11]
+        "vadd.f32   q15, q3, q11         \n\t" // DST->M[m12-m15] = M1[m12-m15] + M2[m12-m15]
+
+        "vst1.32    {q12, q13}, [%0]!    \n\t" // DST->M[m0-m7]
+        "vst1.32    {q14, q15}, [%0]     \n\t" // DST->M[m8-m15]
+        :
+        : "r"(dst), "r"(m1), "r"(m2)
+        : "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", "memory"
+    );
 }
 
 inline void MathUtil::subtractMatrix(const float* m1, const float* m2, float* dst)
 {
-	asm volatile(
-		"vld1.32 	{q0, q1}, 	[%1]! 	\n\t" // M1[m0-m7]
-		"vld1.32 	{q2, q3}, 	[%1] 	\n\t" // M1[m8-m15]
-		"vld1.32 	{q8, q9}, 	[%2]! 	\n\t" // M2[m0-m7]
-		"vld1.32 	{q10, q11}, [%2] 	\n\t" // M2[m8-m15]
-
-		"vsub.f32   q12, q0, q8 		\n\t" // DST->M[m0-m3] = M1[m0-m3] - M2[m0-m3]
-		"vsub.f32   q13, q1, q9			\n\t" // DST->M[m4-m7] = M1[m4-m7] - M2[m4-m7]
-		"vsub.f32   q14, q2, q10		\n\t" // DST->M[m8-m11] = M1[m8-m11] - M2[m8-m11]
-		"vsub.f32   q15, q3, q11		\n\t" // DST->M[m12-m15] = M1[m12-m15] - M2[m12-m15]
-
-		"vst1.32    {q12, q13}, [%0]!   \n\t" // DST->M[m0-m7]
-		"vst1.32    {q14, q15}, [%0]    \n\t" // DST->M[m8-m15]
-		:
-		: "r"(dst), "r"(m1), "r"(m2)
-		: "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", "memory"
-	);
+    asm volatile(
+        "vld1.32     {q0, q1},     [%1]!  \n\t" // M1[m0-m7]
+        "vld1.32     {q2, q3},     [%1]   \n\t" // M1[m8-m15]
+        "vld1.32     {q8, q9},     [%2]!  \n\t" // M2[m0-m7]
+        "vld1.32     {q10, q11}, [%2]     \n\t" // M2[m8-m15]
+
+        "vsub.f32   q12, q0, q8         \n\t" // DST->M[m0-m3] = M1[m0-m3] - M2[m0-m3]
+        "vsub.f32   q13, q1, q9         \n\t" // DST->M[m4-m7] = M1[m4-m7] - M2[m4-m7]
+        "vsub.f32   q14, q2, q10        \n\t" // DST->M[m8-m11] = M1[m8-m11] - M2[m8-m11]
+        "vsub.f32   q15, q3, q11        \n\t" // DST->M[m12-m15] = M1[m12-m15] - M2[m12-m15]
+
+        "vst1.32    {q12, q13}, [%0]!   \n\t" // DST->M[m0-m7]
+        "vst1.32    {q14, q15}, [%0]    \n\t" // DST->M[m8-m15]
+        :
+        : "r"(dst), "r"(m1), "r"(m2)
+        : "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", "memory"
+    );
 }
 
 inline void MathUtil::multiplyMatrix(const float* m, float scalar, float* dst)
 {
-	asm volatile(
-		"vld1.32 	{d0[0]},	 	[%2]     	\n\t" // M[m0-m7]
-		"vld1.32	{q4-q5},  		[%1]!    	\n\t" // M[m8-m15]
-		"vld1.32	{q6-q7},  		[%1]		\n\t" // s
-
-		"vmul.f32 	q8, q4, d0[0]    			\n\t" // DST->M[m0-m3] = M[m0-m3] * s
-		"vmul.f32 	q9, q5, d0[0]    			\n\t" // DST->M[m4-m7] = M[m4-m7] * s
-		"vmul.f32 	q10, q6, d0[0]    			\n\t" // DST->M[m8-m11] = M[m8-m11] * s
-		"vmul.f32 	q11, q7, d0[0]   		 	\n\t" // DST->M[m12-m15] = M[m12-m15] * s
-
-		"vst1.32 	{q8-q9},   		[%0]! 		\n\t" // DST->M[m0-m7]
-		"vst1.32 	{q10-q11}, 		[%0]		\n\t" // DST->M[m8-m15]
-		:
-		: "r"(dst), "r"(m), "r"(&scalar)
-		: "q0", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", "memory"
-	);
+    asm volatile(
+        "vld1.32     {d0[0]},         [%2]        \n\t" // M[m0-m7]
+        "vld1.32    {q4-q5},          [%1]!       \n\t" // M[m8-m15]
+        "vld1.32    {q6-q7},          [%1]        \n\t" // s
+
+        "vmul.f32     q8, q4, d0[0]               \n\t" // DST->M[m0-m3] = M[m0-m3] * s
+        "vmul.f32     q9, q5, d0[0]               \n\t" // DST->M[m4-m7] = M[m4-m7] * s
+        "vmul.f32     q10, q6, d0[0]              \n\t" // DST->M[m8-m11] = M[m8-m11] * s
+        "vmul.f32     q11, q7, d0[0]              \n\t" // DST->M[m12-m15] = M[m12-m15] * s
+
+        "vst1.32     {q8-q9},           [%0]!     \n\t" // DST->M[m0-m7]
+        "vst1.32     {q10-q11},         [%0]      \n\t" // DST->M[m8-m15]
+        :
+        : "r"(dst), "r"(m), "r"(&scalar)
+        : "q0", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", "memory"
+    );
 }
 
 inline void MathUtil::multiplyMatrix(const float* m1, const float* m2, float* dst)
 {
-	asm volatile(
-		"vld1.32	 {d16 - d19}, [%1]!	  \n\t"       // M1[m0-m7]
-		"vld1.32     {d20 - d23}, [%1]    \n\t"       // M1[m8-m15]
-		"vld1.32     {d0 - d3}, [%2]!     \n\t"       // M2[m0-m7]
-		"vld1.32     {d4 - d7}, [%2]      \n\t"       // M2[m8-m15]
-
-		"vmul.f32    q12, q8, d0[0]     \n\t"         // DST->M[m0-m3] = M1[m0-m3] * M2[m0]
-		"vmul.f32    q13, q8, d2[0]     \n\t"         // DST->M[m4-m7] = M1[m4-m7] * M2[m4]
-		"vmul.f32    q14, q8, d4[0]     \n\t"         // DST->M[m8-m11] = M1[m8-m11] * M2[m8]
-		"vmul.f32    q15, q8, d6[0]     \n\t"         // DST->M[m12-m15] = M1[m12-m15] * M2[m12]
-
-		"vmla.f32    q12, q9, d0[1]     \n\t"         // DST->M[m0-m3] += M1[m0-m3] * M2[m1]
-		"vmla.f32    q13, q9, d2[1]     \n\t"         // DST->M[m4-m7] += M1[m4-m7] * M2[m5]
-		"vmla.f32    q14, q9, d4[1]     \n\t"         // DST->M[m8-m11] += M1[m8-m11] * M2[m9]
-		"vmla.f32    q15, q9, d6[1]     \n\t"         // DST->M[m12-m15] += M1[m12-m15] * M2[m13]
-
-		"vmla.f32    q12, q10, d1[0]    \n\t"         // DST->M[m0-m3] += M1[m0-m3] * M2[m2]
-		"vmla.f32    q13, q10, d3[0]    \n\t"         // DST->M[m4-m7] += M1[m4-m7] * M2[m6]
-		"vmla.f32    q14, q10, d5[0]    \n\t"         // DST->M[m8-m11] += M1[m8-m11] * M2[m10]
-		"vmla.f32    q15, q10, d7[0]    \n\t"         // DST->M[m12-m15] += M1[m12-m15] * M2[m14]
-
-		"vmla.f32    q12, q11, d1[1]    \n\t"         // DST->M[m0-m3] += M1[m0-m3] * M2[m3]
-		"vmla.f32    q13, q11, d3[1]    \n\t"         // DST->M[m4-m7] += M1[m4-m7] * M2[m7]
-		"vmla.f32    q14, q11, d5[1]    \n\t"         // DST->M[m8-m11] += M1[m8-m11] * M2[m11]
-		"vmla.f32    q15, q11, d7[1]    \n\t"         // DST->M[m12-m15] += M1[m12-m15] * M2[m15]
-
-		"vst1.32    {d24 - d27}, [%0]!    \n\t"       // DST->M[m0-m7]
-		"vst1.32    {d28 - d31}, [%0]     \n\t"       // DST->M[m8-m15]
-
-		: // output
-		: "r"(dst), "r"(m1), "r"(m2) // input - note *value* of pointer doesn't change.
-		: "memory", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15"
-	);
+    asm volatile(
+        "vld1.32     {d16 - d19}, [%1]! \n\t"       // M1[m0-m7]
+        "vld1.32     {d20 - d23}, [%1]  \n\t"       // M1[m8-m15]
+        "vld1.32     {d0 - d3}, [%2]!   \n\t"       // M2[m0-m7]
+        "vld1.32     {d4 - d7}, [%2]    \n\t"       // M2[m8-m15]
+
+        "vmul.f32    q12, q8, d0[0]     \n\t"         // DST->M[m0-m3] = M1[m0-m3] * M2[m0]
+        "vmul.f32    q13, q8, d2[0]     \n\t"         // DST->M[m4-m7] = M1[m4-m7] * M2[m4]
+        "vmul.f32    q14, q8, d4[0]     \n\t"         // DST->M[m8-m11] = M1[m8-m11] * M2[m8]
+        "vmul.f32    q15, q8, d6[0]     \n\t"         // DST->M[m12-m15] = M1[m12-m15] * M2[m12]
+
+        "vmla.f32    q12, q9, d0[1]     \n\t"         // DST->M[m0-m3] += M1[m0-m3] * M2[m1]
+        "vmla.f32    q13, q9, d2[1]     \n\t"         // DST->M[m4-m7] += M1[m4-m7] * M2[m5]
+        "vmla.f32    q14, q9, d4[1]     \n\t"         // DST->M[m8-m11] += M1[m8-m11] * M2[m9]
+        "vmla.f32    q15, q9, d6[1]     \n\t"         // DST->M[m12-m15] += M1[m12-m15] * M2[m13]
+
+        "vmla.f32    q12, q10, d1[0]    \n\t"         // DST->M[m0-m3] += M1[m0-m3] * M2[m2]
+        "vmla.f32    q13, q10, d3[0]    \n\t"         // DST->M[m4-m7] += M1[m4-m7] * M2[m6]
+        "vmla.f32    q14, q10, d5[0]    \n\t"         // DST->M[m8-m11] += M1[m8-m11] * M2[m10]
+        "vmla.f32    q15, q10, d7[0]    \n\t"         // DST->M[m12-m15] += M1[m12-m15] * M2[m14]
+
+        "vmla.f32    q12, q11, d1[1]    \n\t"         // DST->M[m0-m3] += M1[m0-m3] * M2[m3]
+        "vmla.f32    q13, q11, d3[1]    \n\t"         // DST->M[m4-m7] += M1[m4-m7] * M2[m7]
+        "vmla.f32    q14, q11, d5[1]    \n\t"         // DST->M[m8-m11] += M1[m8-m11] * M2[m11]
+        "vmla.f32    q15, q11, d7[1]    \n\t"         // DST->M[m12-m15] += M1[m12-m15] * M2[m15]
+
+        "vst1.32    {d24 - d27}, [%0]!  \n\t"       // DST->M[m0-m7]
+        "vst1.32    {d28 - d31}, [%0]   \n\t"       // DST->M[m8-m15]
+
+        : // output
+        : "r"(dst), "r"(m1), "r"(m2) // input - note *value* of pointer doesn't change.
+        : "memory", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15"
+    );
 }
 
 inline void MathUtil::negateMatrix(const float* m, float* dst)
 {
-	asm volatile(
-		"vld1.32 	{q0-q1},  [%1]! 	\n\t" // load m0-m7
-		"vld1.32 	{q2-q3},  [%1]   	\n\t" // load m8-m15
-
-		"vneg.f32 	q4, q0 				\n\t" // negate m0-m3
-		"vneg.f32 	q5, q1 				\n\t" // negate m4-m7
-		"vneg.f32 	q6, q2 				\n\t" // negate m8-m15
-		"vneg.f32 	q7, q3 				\n\t" // negate m8-m15
-
-		"vst1.32 	{q4-q5},  [%0]!		\n\t" // store m0-m7
-		"vst1.32 	{q6-q7},  [%0]		\n\t" // store m8-m15
-		:
-		: "r"(dst), "r"(m)
-		: "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory"
-	);
+    asm volatile(
+        "vld1.32     {q0-q1},  [%1]!     \n\t" // load m0-m7
+        "vld1.32     {q2-q3},  [%1]      \n\t" // load m8-m15
+
+        "vneg.f32     q4, q0             \n\t" // negate m0-m3
+        "vneg.f32     q5, q1             \n\t" // negate m4-m7
+        "vneg.f32     q6, q2             \n\t" // negate m8-m15
+        "vneg.f32     q7, q3             \n\t" // negate m8-m15
+
+        "vst1.32     {q4-q5},  [%0]!     \n\t" // store m0-m7
+        "vst1.32     {q6-q7},  [%0]      \n\t" // store m8-m15
+        :
+        : "r"(dst), "r"(m)
+        : "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory"
+    );
 }
 
 inline void MathUtil::transposeMatrix(const float* m, float* dst)
 {
-	asm volatile(
-		"vld4.32 {d0[0], d2[0], d4[0], d6[0]}, [%1]! 	\n\t" // DST->M[m0, m4, m8, m12] = M[m0-m3]
-		"vld4.32 {d0[1], d2[1], d4[1], d6[1]}, [%1]!	\n\t" // DST->M[m1, m5, m9, m12] = M[m4-m7]
-		"vld4.32 {d1[0], d3[0], d5[0], d7[0]}, [%1]!	\n\t" // DST->M[m2, m6, m10, m12] = M[m8-m11]
-		"vld4.32 {d1[1], d3[1], d5[1], d7[1]}, [%1] 	\n\t" // DST->M[m3, m7, m11, m12] = M[m12-m15]
-
-		"vst1.32 {q0-q1}, [%0]! 						\n\t" // DST->M[m0-m7]
-		"vst1.32 {q2-q3}, [%0] 							\n\t" // DST->M[m8-m15]
-		:
-		: "r"(dst), "r"(m)
-		: "q0", "q1", "q2", "q3", "memory"
-	);
+    asm volatile(
+        "vld4.32 {d0[0], d2[0], d4[0], d6[0]}, [%1]!    \n\t" // DST->M[m0, m4, m8, m12] = M[m0-m3]
+        "vld4.32 {d0[1], d2[1], d4[1], d6[1]}, [%1]!    \n\t" // DST->M[m1, m5, m9, m12] = M[m4-m7]
+        "vld4.32 {d1[0], d3[0], d5[0], d7[0]}, [%1]!    \n\t" // DST->M[m2, m6, m10, m12] = M[m8-m11]
+        "vld4.32 {d1[1], d3[1], d5[1], d7[1]}, [%1]     \n\t" // DST->M[m3, m7, m11, m12] = M[m12-m15]
+
+        "vst1.32 {q0-q1}, [%0]!                         \n\t" // DST->M[m0-m7]
+        "vst1.32 {q2-q3}, [%0]                          \n\t" // DST->M[m8-m15]
+        :
+        : "r"(dst), "r"(m)
+        : "q0", "q1", "q2", "q3", "memory"
+    );
 }
 
 inline void MathUtil::transformVector4(const float* m, float x, float y, float z, float w, float* dst)
 {
-	asm volatile(
-		"vld1.32	{d0[0]},		[%1]	\n\t"	// V[x]
-		"vld1.32	{d0[1]},    	[%2]	\n\t"	// V[y]
-		"vld1.32	{d1[0]},		[%3]	\n\t"	// V[z]
-		"vld1.32	{d1[1]},		[%4]	\n\t"	// V[w]
-		"vld1.32	{d18 - d21},	[%5]!	\n\t"	// M[m0-m7]
-		"vld1.32	{d22 - d25},	[%5]	\n\t"	// M[m8-m15]
-
-		"vmul.f32 q13,  q9, d0[0]			\n\t"	// DST->V = M[m0-m3] * V[x]
-		"vmla.f32 q13, q10, d0[1]      		\n\t"	// DST->V += M[m4-m7] * V[y]
-		"vmla.f32 q13, q11, d1[0]      		\n\t"	// DST->V += M[m8-m11] * V[z]
-		"vmla.f32 q13, q12, d1[1]      		\n\t"	// DST->V += M[m12-m15] * V[w]
-
-		"vst1.32 {d26}, [%0]!        		\n\t"	// DST->V[x, y]
-		"vst1.32 {d27[0]}, [%0]        		\n\t"	// DST->V[z]
-		:
-		: "r"(dst), "r"(&x), "r"(&y), "r"(&z), "r"(&w), "r"(m)
-		: "q0", "q9", "q10","q11", "q12", "q13", "memory"
-	);
+    asm volatile(
+        "vld1.32    {d0[0]},        [%1]    \n\t"    // V[x]
+        "vld1.32    {d0[1]},        [%2]    \n\t"    // V[y]
+        "vld1.32    {d1[0]},        [%3]    \n\t"    // V[z]
+        "vld1.32    {d1[1]},        [%4]    \n\t"    // V[w]
+        "vld1.32    {d18 - d21},    [%5]!   \n\t"    // M[m0-m7]
+        "vld1.32    {d22 - d25},    [%5]    \n\t"    // M[m8-m15]
+
+        "vmul.f32 q13,  q9, d0[0]           \n\t"    // DST->V = M[m0-m3] * V[x]
+        "vmla.f32 q13, q10, d0[1]           \n\t"    // DST->V += M[m4-m7] * V[y]
+        "vmla.f32 q13, q11, d1[0]           \n\t"    // DST->V += M[m8-m11] * V[z]
+        "vmla.f32 q13, q12, d1[1]           \n\t"    // DST->V += M[m12-m15] * V[w]
+
+        "vst1.32 {d26}, [%0]!               \n\t"    // DST->V[x, y]
+        "vst1.32 {d27[0]}, [%0]             \n\t"    // DST->V[z]
+        :
+        : "r"(dst), "r"(&x), "r"(&y), "r"(&z), "r"(&w), "r"(m)
+        : "q0", "q9", "q10","q11", "q12", "q13", "memory"
+    );
 }
 
 inline void MathUtil::transformVector4(const float* m, const float* v, float* dst)
 {
-	asm volatile
-	(
-		"vld1.32	{d0, d1}, [%1]		\n\t"   // V[x, y, z, w]
-		"vld1.32    {d18 - d21}, [%2]!  \n\t"   // M[m0-m7]
-		"vld1.32    {d22 - d25}, [%2]  \n\t"    // M[m8-m15]
-
-		"vmul.f32   q13, q9, d0[0]      \n\t"   // DST->V = M[m0-m3] * V[x]
-		"vmla.f32   q13, q10, d0[1]     \n\t"   // DST->V = M[m4-m7] * V[y]
-		"vmla.f32   q13, q11, d1[0]     \n\t"   // DST->V = M[m8-m11] * V[z]
-		"vmla.f32   q13, q12, d1[1]     \n\t"   // DST->V = M[m12-m15] * V[w]
-
-		"vst1.32    {d26, d27}, [%0]    \n\t"   // DST->V
-		:
-		: "r"(dst), "r"(v), "r"(m)
-		: "q0", "q9", "q10","q11", "q12", "q13", "memory"
-	);
+    asm volatile
+    (
+        "vld1.32    {d0, d1}, [%1]     \n\t"   // V[x, y, z, w]
+        "vld1.32    {d18 - d21}, [%2]! \n\t"   // M[m0-m7]
+        "vld1.32    {d22 - d25}, [%2]  \n\t"    // M[m8-m15]
+
+        "vmul.f32   q13, q9, d0[0]     \n\t"   // DST->V = M[m0-m3] * V[x]
+        "vmla.f32   q13, q10, d0[1]    \n\t"   // DST->V = M[m4-m7] * V[y]
+        "vmla.f32   q13, q11, d1[0]    \n\t"   // DST->V = M[m8-m11] * V[z]
+        "vmla.f32   q13, q12, d1[1]    \n\t"   // DST->V = M[m12-m15] * V[w]
+
+        "vst1.32    {d26, d27}, [%0]   \n\t"   // DST->V
+        :
+        : "r"(dst), "r"(v), "r"(m)
+        : "q0", "q9", "q10","q11", "q12", "q13", "memory"
+    );
 }
 
 inline void MathUtil::crossVector3(const float* v1, const float* v2, float* dst)
 {
-	asm volatile(
-		"vld1.32 {d1[1]},  [%1] 		\n\t" //
-		"vld1.32 {d0},     [%2]         \n\t" //
-		"vmov.f32 s2, s1                \n\t" // q0 = (v1y, v1z, v1z, v1x)
-
-		"vld1.32 {d2[1]},  [%3]	    	\n\t" //
-		"vld1.32 {d3},     [%4]         \n\t" //
-		"vmov.f32 s4, s7          		\n\t" // q1 = (v2z, v2x, v2y, v2z)
-
-		"vmul.f32 d4, d0, d2  			\n\t" // x = v1y * v2z, y = v1z * v2x
-		"vmls.f32 d4, d1, d3  			\n\t" // x -= v1z * v2y, y-= v1x - v2z
-
-		"vmul.f32 d5, d3, d1[1]			\n\t" // z = v1x * v2y
-		"vmls.f32 d5, d0, d2[1]         \n\t" // z-= v1y * vx
-
-		"vst1.32 {d4}, 	  [%0]!    		\n\t" // V[x, y]
-		"vst1.32 {d5[0]}, [%0]     		\n\t" // V[z]
-		:
-		: "r"(dst), "r"(v1), "r"((v1+1)), "r"(v2), "r"((v2+1))
-		: "q0", "q1", "q2", "memory"
-	);
+    asm volatile(
+        "vld1.32 {d1[1]},  [%1]         \n\t" //
+        "vld1.32 {d0},     [%2]         \n\t" //
+        "vmov.f32 s2, s1                \n\t" // q0 = (v1y, v1z, v1z, v1x)
+
+        "vld1.32 {d2[1]},  [%3]         \n\t" //
+        "vld1.32 {d3},     [%4]         \n\t" //
+        "vmov.f32 s4, s7                  \n\t" // q1 = (v2z, v2x, v2y, v2z)
+
+        "vmul.f32 d4, d0, d2            \n\t" // x = v1y * v2z, y = v1z * v2x
+        "vmls.f32 d4, d1, d3            \n\t" // x -= v1z * v2y, y-= v1x - v2z
+
+        "vmul.f32 d5, d3, d1[1]         \n\t" // z = v1x * v2y
+        "vmls.f32 d5, d0, d2[1]         \n\t" // z-= v1y * vx
+
+        "vst1.32 {d4},       [%0]!      \n\t" // V[x, y]
+        "vst1.32 {d5[0]}, [%0]          \n\t" // V[z]
+        :
+        : "r"(dst), "r"(v1), "r"((v1+1)), "r"(v2), "r"((v2+1))
+        : "q0", "q1", "q2", "memory"
+    );
 }
 
 }

+ 2 - 2
gameplay/src/Matrix.cpp

@@ -654,9 +654,9 @@ void Matrix::multiply(const Matrix& m)
 
 void Matrix::multiply(const Matrix& m1, const Matrix& m2, Matrix* dst)
 {
-	GP_ASSERT(dst);
+    GP_ASSERT(dst);
 
-	MathUtil::multiplyMatrix(m1.m, m2.m, dst->m);
+    MathUtil::multiplyMatrix(m1.m, m2.m, dst->m);
 }
 
 void Matrix::negate()

+ 4 - 4
gameplay/src/PhysicsController.cpp

@@ -173,8 +173,8 @@ bool PhysicsController::rayTest(const Ray& ray, float distance, PhysicsControlle
         {
         }
 
-		virtual bool needsCollision(btBroadphaseProxy* proxy0) const
-		{
+        virtual bool needsCollision(btBroadphaseProxy* proxy0) const
+        {
             if (!btCollisionWorld::ClosestRayResultCallback::needsCollision(proxy0))
                 return false;
 
@@ -248,8 +248,8 @@ bool PhysicsController::sweepTest(PhysicsCollisionObject* object, const Vector3&
         {
         }
 
-		virtual bool needsCollision(btBroadphaseProxy* proxy0) const
-		{
+        virtual bool needsCollision(btBroadphaseProxy* proxy0) const
+        {
             if (!btCollisionWorld::ClosestConvexResultCallback::needsCollision(proxy0))
                 return false;
 

+ 2 - 0
gameplay/src/PhysicsRigidBody.h

@@ -280,6 +280,8 @@ public:
 
     /**
      * Applies the given force to the rigid body (optionally, from the given relative position).
+     * Note that the total force applied depends on the duration of the next frame.
+     * If you want to apply an "impulse" irrespective of the frame duration, consider using applyImpulse.
      * 
      * @param force The force to be applied.
      * @param relativePosition The relative position from which to apply the force.

+ 15 - 15
gameplay/src/PlatformLinux.cpp

@@ -426,10 +426,10 @@ Platform* Platform::create(Game* game, void* attachToWindow)
     GLXFBConfig* configs;
     int configCount = 0;
     configs = glXChooseFBConfig(__display, DefaultScreen(__display), configAttribs, &configCount);
-    if( configCount == 0 || configs == 0 )	
-    {	
+    if( configCount == 0 || configs == 0 )    
+    {    
         perror( "glXChooseFBConfig" );
-        return NULL;	
+        return NULL;    
     }
 
     // Create the windows
@@ -494,11 +494,11 @@ void cleanupX11()
         glXMakeCurrent(__display, None, NULL);
 
         if (__context)
-     	    glXDestroyContext(__display, __context);
+             glXDestroyContext(__display, __context);
         if (__window)
-     	    XDestroyWindow(__display, __window);
+             XDestroyWindow(__display, __window);
 
-     	XCloseDisplay(__display);
+         XCloseDisplay(__display);
     }
 }
 
@@ -508,14 +508,14 @@ double timespec2millis(struct timespec *a)
     return (1000.0 * a->tv_sec) + (0.000001 * a->tv_nsec);
 }
 
-void updateWindowSize()	
-{	
-    GP_ASSERT(__display);	
+void updateWindowSize()    
+{    
+    GP_ASSERT(__display);    
     GP_ASSERT(__window);
-    XWindowAttributes windowAttrs;	
-    XGetWindowAttributes(__display, __window, &windowAttrs);  	
-    __windowSize[0] = windowAttrs.width;	
-    __windowSize[1] = windowAttrs.height;	
+    XWindowAttributes windowAttrs;    
+    XGetWindowAttributes(__display, __window, &windowAttrs);      
+    __windowSize[0] = windowAttrs.width;    
+    __windowSize[1] = windowAttrs.height;    
 }
 
 int Platform::enterMessagePump()
@@ -540,9 +540,9 @@ int Platform::enterMessagePump()
     // Run the game.
     _game->run();
 
-    // Setup select for message handling (to allow non-blocking)	
+    // Setup select for message handling (to allow non-blocking)    
     int x11_fd = ConnectionNumber(__display);
-	
+    
     pollfd xpolls[1];
     xpolls[0].fd = x11_fd;
     xpolls[0].events = POLLIN|POLLPRI;

+ 1 - 1
gameplay/src/PlatformMacOSX.mm

@@ -688,7 +688,7 @@ Platform::~Platform()
 
 Platform* Platform::create(Game* game, void* attachToWindow)
 {
-	__attachToWindow = attachToWindow;
+    __attachToWindow = attachToWindow;
     Platform* platform = new Platform(game);
     
     return platform;

+ 70 - 71
gameplay/src/PlatformQNX.cpp

@@ -565,8 +565,8 @@ Platform* Platform::create(Game* game, void* attachToWindow)
     int screenSwapInterval = WINDOW_VSYNC ? 1 : 0;
     int screenTransparency = SCREEN_TRANSPARENCY_NONE;
 
-	char *width_str = getenv("WIDTH");
-	char *height_str = getenv("HEIGHT");
+    char *width_str = getenv("WIDTH");
+    char *height_str = getenv("HEIGHT");
 
     // Hard-coded to (0,0).
     int windowPosition[] =
@@ -633,74 +633,74 @@ Platform* Platform::create(Game* game, void* attachToWindow)
         goto error;
     }
 
-	if (width_str && height_str)
-	{
-		__screenWindowSize[0] = atoi(width_str);
-		__screenWindowSize[1] = atoi(height_str);
-	}
-	else
-	{
-		int angle = atoi(getenv("ORIENTATION"));
-
-		screen_display_t screen_display;
-		rc = screen_get_window_property_pv(__screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&screen_display);
-		if (rc)
-		{
-			perror("screen_get_window_property_pv(SCREEN_PROPERTY_DISPLAY)");
-			goto error;
-		}
-
-		screen_display_mode_t screen_mode;
-		rc = screen_get_display_property_pv(screen_display, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
-		if (rc)
-		{
-			perror("screen_get_display_property_pv(SCREEN_PROPERTY_MODE)");
-			goto error;
-		}
-
-		int size[2];
-		rc = screen_get_window_property_iv(__screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, size);
-		if (rc)
-		{
-			perror("screen_get_window_property_iv(SCREEN_PROPERTY_BUFFER_SIZE)");
-			goto error;
-		}
-
-		__screenWindowSize[0] = size[0];
-		__screenWindowSize[1] = size[1];
-
-		if ((angle == 0) || (angle == 180))
-		{
-			if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
-				((screen_mode.width < screen_mode.height) && (size[0] > size[1])))
-			{
-				__screenWindowSize[1] = size[0];
-				__screenWindowSize[0] = size[1];
-			}
-		}
-		else if ((angle == 90) || (angle == 270))
-		{
-			if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
-				((screen_mode.width < screen_mode.height) && (size[0] < size[1])))
-			{
-				__screenWindowSize[1] = size[0];
-				__screenWindowSize[0] = size[1];
-			}
-		}
-		else
-		{
-			perror("Navigator returned an unexpected orientation angle.");
-			goto error;
-		}
-
-
-	    rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_ROTATION, &angle);
-	    if (rc)
-	    {
-	        perror("screen_set_window_property_iv(SCREEN_PROPERTY_ROTATION)");
-	        goto error;
-	    }
-	}
+    if (width_str && height_str)
+    {
+        __screenWindowSize[0] = atoi(width_str);
+        __screenWindowSize[1] = atoi(height_str);
+    }
+    else
+    {
+        int angle = atoi(getenv("ORIENTATION"));
+
+        screen_display_t screen_display;
+        rc = screen_get_window_property_pv(__screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&screen_display);
+        if (rc)
+        {
+            perror("screen_get_window_property_pv(SCREEN_PROPERTY_DISPLAY)");
+            goto error;
+        }
+
+        screen_display_mode_t screen_mode;
+        rc = screen_get_display_property_pv(screen_display, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
+        if (rc)
+        {
+            perror("screen_get_display_property_pv(SCREEN_PROPERTY_MODE)");
+            goto error;
+        }
+
+        int size[2];
+        rc = screen_get_window_property_iv(__screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, size);
+        if (rc)
+        {
+            perror("screen_get_window_property_iv(SCREEN_PROPERTY_BUFFER_SIZE)");
+            goto error;
+        }
+
+        __screenWindowSize[0] = size[0];
+        __screenWindowSize[1] = size[1];
+
+        if ((angle == 0) || (angle == 180))
+        {
+            if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
+                ((screen_mode.width < screen_mode.height) && (size[0] > size[1])))
+            {
+                __screenWindowSize[1] = size[0];
+                __screenWindowSize[0] = size[1];
+            }
+        }
+        else if ((angle == 90) || (angle == 270))
+        {
+            if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
+                ((screen_mode.width < screen_mode.height) && (size[0] < size[1])))
+            {
+                __screenWindowSize[1] = size[0];
+                __screenWindowSize[0] = size[1];
+            }
+        }
+        else
+        {
+            perror("Navigator returned an unexpected orientation angle.");
+            goto error;
+        }
+
+
+        rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_ROTATION, &angle);
+        if (rc)
+        {
+            perror("screen_set_window_property_iv(SCREEN_PROPERTY_ROTATION)");
+            goto error;
+        }
+    }
 
     rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, __screenWindowSize);
     if (rc)
@@ -844,7 +844,6 @@ int Platform::enterMessagePump()
     int position[2];
     int domain;
     mtouch_event_t touchEvent;
-    int touchId = 0;
     bool suspended = false;
 
     // Get the initial time.

+ 3 - 4
gameplay/src/PlatformWin32.cpp

@@ -763,9 +763,9 @@ Platform* Platform::create(Game* game, void* attachToWindow)
             DEVMODE dm;
             memset(&dm, 0, sizeof(dm));
             dm.dmSize= sizeof(dm);
-            dm.dmPelsWidth	= __width;
-            dm.dmPelsHeight	= __height;
-            dm.dmBitsPerPel	= 32;
+            dm.dmPelsWidth    = __width;
+            dm.dmPelsHeight    = __height;
+            dm.dmBitsPerPel    = 32;
             dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
 
             // Try to set selected mode and get results. NOTE: CDS_FULLSCREEN gets rid of start bar.
@@ -849,7 +849,6 @@ error:
 int Platform::enterMessagePump()
 {
     GP_ASSERT(_game);
-    int rc = 0;
 
     // Get the initial time.
     LARGE_INTEGER tps;

+ 4 - 4
gameplay/src/PlatformiOS.mm

@@ -51,7 +51,7 @@ int getKey(unichar keyCode);
 
 @interface View : UIView <UIKeyInput>
 {
-    EAGLContext* context;	
+    EAGLContext* context;
     CADisplayLink* displayLink;
     GLuint defaultFramebuffer;
     GLuint colorRenderbuffer;
@@ -241,7 +241,7 @@ int getKey(unichar keyCode);
 {
     if (interval >= 1)
     {
-        swapInterval = interval;		
+        swapInterval = interval;        
         if (updating)
         {
             [self stopUpdating];
@@ -651,7 +651,7 @@ int getKey(unichar keyCode);
 }
 
 - (void)applicationWillEnterForeground:(UIApplication*)application 
-{	
+{    
     [viewController startUpdating];
 }
 
@@ -661,7 +661,7 @@ int getKey(unichar keyCode);
 }
 
 - (void)applicationWillTerminate:(UIApplication*)application 
-{	
+{    
     [viewController stopUpdating];
 }
 

+ 8 - 14
gameplay/src/Properties.cpp

@@ -17,15 +17,11 @@ Properties::Properties()
 }
 
 Properties::Properties(const Properties& copy)
+    : _namespace(copy._namespace), _id(copy._id), _parentID(copy._parentID), _properties(copy._properties)
 {
-    _namespace = copy._namespace;
-    _id = copy._id;
-    _parentID = copy._parentID;
-    _properties = copy._properties;
-    
     _namespaces = std::vector<Properties*>();
     std::vector<Properties*>::const_iterator it;
-    for (it = copy._namespaces.begin(); it < copy._namespaces.end(); it++)
+    for (it = copy._namespaces.begin(); it < copy._namespaces.end(); ++it)
     {
         GP_ASSERT(*it);
         _namespaces.push_back(new Properties(**it));
@@ -327,7 +323,7 @@ void Properties::readProperties(FILE* file)
 Properties::~Properties()
 {
     unsigned int count = _namespaces.size();
-    for (unsigned int i = 0; i < count; i++)
+    for (unsigned int i = 0; i < count; ++i)
     {
         SAFE_DELETE(_namespaces[i]);
     }
@@ -423,7 +419,7 @@ void Properties::resolveInheritance(const char* id)
                 derived->_properties = parent->_properties;
                 derived->_namespaces = std::vector<Properties*>();
                 std::vector<Properties*>::const_iterator itt;
-                for (itt = parent->_namespaces.begin(); itt < parent->_namespaces.end(); itt++)
+                for (itt = parent->_namespaces.begin(); itt < parent->_namespaces.end(); ++itt)
                 {
                     GP_ASSERT(*itt);
                     derived->_namespaces.push_back(new Properties(**itt));
@@ -466,7 +462,7 @@ void Properties::mergeWith(Properties* overrides)
         this->_properties[name] = value;
         name = overrides->getNextProperty(&value);
     }
-    SAFE_DELETE(value);
+    SAFE_DELETE_ARRAY(value);
     this->_propertiesItr = this->_properties.end();
 
     // Merge all common nested namespaces, add new ones.
@@ -512,7 +508,7 @@ const char* Properties::getNextProperty(char** value)
     else
     {
         // Move to the next property
-        _propertiesItr++;
+        ++_propertiesItr;
     }
 
     if (_propertiesItr != _properties.end())
@@ -540,7 +536,7 @@ Properties* Properties::getNextNamespace()
     }
     else
     {
-        _namespacesItr++;
+        ++_namespacesItr;
     }
 
     if (_namespacesItr != _namespaces.end())
@@ -565,7 +561,7 @@ Properties* Properties::getNamespace(const char* id, bool searchNames) const
     Properties* ret = NULL;
     std::vector<Properties*>::const_iterator it;
     
-    for (it = _namespaces.begin(); it < _namespaces.end(); it++)
+    for (it = _namespaces.begin(); it < _namespaces.end(); ++it)
     {
         ret = *it;
         if (strcmp(searchNames ? ret->_namespace.c_str() : ret->_id.c_str(), id) == 0)
@@ -998,11 +994,9 @@ Properties* getPropertiesFromNamespacePath(Properties* properties, const std::ve
 {
     // If the url references a specific namespace within the file,
     // return the specified namespace or notify the user if it cannot be found.
-    Properties* originalProperties = properties;
     if (namespacePath.size() > 0)
     {
         unsigned int size = namespacePath.size();
-        const char* tmp = namespacePath[0].c_str();
         properties->rewind();
         Properties* iter = properties->getNextNamespace();
         for (unsigned int i = 0; i < size;)

+ 1 - 1
gameplay/src/Quaternion.cpp

@@ -57,7 +57,7 @@ bool Quaternion::isIdentity() const
 
 bool Quaternion::isZero() const
 {
-    return x == 0.0f && y == 0.0f && z == 0.0f && z == 0.0f;
+    return x == 0.0f && y == 0.0f && z == 0.0f && w == 0.0f;
 }
 
 void Quaternion::createFromRotationMatrix(const Matrix& m, Quaternion* dst)

+ 12 - 12
gameplay/src/RadioButton.cpp

@@ -5,7 +5,7 @@ namespace gameplay
 {
 static std::vector<RadioButton*> __radioButtons;
 
-RadioButton::RadioButton() : _selected(false)
+RadioButton::RadioButton() : _selected(false), _image(NULL)
 {
 }
 
@@ -102,16 +102,16 @@ bool RadioButton::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int c
         {
             if (_contactIndex == (int) _contactIndex && _state == Control::ACTIVE)
             {
-				if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
-					y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
-				{
-					if (!_selected)
-					{
-						RadioButton::clearSelected(_groupId);
-						_selected = true;
-						notifyListeners(Listener::VALUE_CHANGED);
-					}
-				}
+                if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
+                    y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
+                {
+                    if (!_selected)
+                    {
+                        RadioButton::clearSelected(_groupId);
+                        _selected = true;
+                        notifyListeners(Listener::VALUE_CHANGED);
+                    }
+                }
             }
         }
         break;
@@ -123,7 +123,7 @@ bool RadioButton::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int c
 void RadioButton::clearSelected(const std::string& groupId)
 {
     std::vector<RadioButton*>::const_iterator it;
-    for (it = __radioButtons.begin(); it < __radioButtons.end(); it++)
+    for (it = __radioButtons.begin(); it < __radioButtons.end(); ++it)
     {
         RadioButton* radioButton = *it;
         GP_ASSERT(radioButton);

+ 1 - 1
gameplay/src/Rectangle.cpp

@@ -126,7 +126,7 @@ void Rectangle::inflate(float horizontalAmount, float verticalAmount)
     height += verticalAmount * 2;
 }
 
-const Rectangle& Rectangle::operator = (const Rectangle& r)
+Rectangle& Rectangle::operator = (const Rectangle& r)
 {
     x = r.x;
     y = r.y;

+ 1 - 1
gameplay/src/Rectangle.h

@@ -214,7 +214,7 @@ public:
     /**
      * operator =
      */
-    const Rectangle& operator = (const Rectangle& r);
+    Rectangle& operator = (const Rectangle& r);
 
     /**
      * operator ==

+ 1 - 1
gameplay/src/RenderState.cpp

@@ -193,7 +193,7 @@ void RenderState::setNodeBinding(Node* node)
         while (itr != _autoBindings.end())
         {
             applyAutoBinding(itr->first.c_str(), itr->second);
-            itr++;
+            ++itr;
         }
     }
 }

+ 1 - 1
gameplay/src/RenderTarget.cpp

@@ -47,7 +47,7 @@ RenderTarget* RenderTarget::getRenderTarget(const char* id)
 
     // Search the vector for a matching ID.
     std::vector<RenderTarget*>::const_iterator it;
-    for (it = __renderTargets.begin(); it < __renderTargets.end(); it++)
+    for (it = __renderTargets.begin(); it < __renderTargets.end(); ++it)
     {
         RenderTarget* dst = *it;
         GP_ASSERT(dst);

+ 3 - 9
gameplay/src/SceneLoader.cpp

@@ -88,7 +88,6 @@ Scene* SceneLoader::loadInternal(const char* url)
 
     // Find the physics properties object.
     Properties* physics = NULL;
-    Properties* ns = NULL;
     sceneProperties->rewind();
     while (true)
     {
@@ -106,7 +105,7 @@ Scene* SceneLoader::loadInternal(const char* url)
 
     // Clean up all loaded properties objects.
     std::map<std::string, Properties*>::iterator iter = _propertiesFromFile.begin();
-    for (; iter != _propertiesFromFile.end(); iter++)
+    for (; iter != _propertiesFromFile.end(); ++iter)
     {
         SAFE_DELETE(iter->second);
     }
@@ -201,10 +200,6 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
             break;
         }
         case SceneNodeProperty::MATERIAL:
-            {
-                const char* id = node->getId();
-                id = NULL;
-            }
             if (!node->getModel())
             {
                 GP_ERROR("Attempting to set a material on node '%s', which has no model.", sceneNode._nodeID);
@@ -288,7 +283,6 @@ void SceneLoader::applyNodeProperty(SceneNode& sceneNode, Node* node, const Prop
     {
         // Handle scale, rotate and translate.
         Properties* np = sceneProperties->getNamespace(sceneNode._nodeID);
-        const char* name = NULL;
 
         switch (snp._type)
         {
@@ -916,7 +910,7 @@ void SceneLoader::loadReferencedFiles()
 {
     // Load all referenced properties files.
     std::map<std::string, Properties*>::iterator iter = _properties.begin();
-    for (; iter != _properties.end(); iter++)
+    for (; iter != _properties.end(); ++iter)
     {
         if (iter->second == NULL)
         {
@@ -1096,7 +1090,7 @@ SceneLoader::SceneNode::SceneNode()
 {
 }
 
-SceneLoader::SceneNodeProperty::SceneNodeProperty(Type type, std::string url, int index)
+SceneLoader::SceneNodeProperty::SceneNodeProperty(Type type, const std::string& url, int index)
     : _type(type), _url(url), _index(index)
 {
 }

+ 1 - 1
gameplay/src/SceneLoader.h

@@ -56,7 +56,7 @@ private:
             URL = 128
         };
 
-        SceneNodeProperty(Type type, std::string url, int index);
+        SceneNodeProperty(Type type, const std::string& url, int index);
 
         Type _type;
         std::string _url;

+ 13 - 13
gameplay/src/ScriptController.cpp

@@ -23,7 +23,7 @@
         return LuaArray<type>((type*)NULL); \
     \
     /* Declare a LuaArray to store the values. */ \
-	LuaArray<type> arr(size); \
+    LuaArray<type> arr(size); \
     \
     /* Push the first key. */ \
     lua_pushnil(sc->_lua); \
@@ -59,13 +59,13 @@ void ScriptUtil::registerLibrary(const char* name, const luaL_Reg* functions)
     lua_setglobal(sc->_lua, name);
 }
 
-void ScriptUtil::registerConstantBool(std::string name, bool value, std::vector<std::string> scopePath)
+void ScriptUtil::registerConstantBool(const std::string& name, bool value, const std::vector<std::string>& scopePath)
 {
     ScriptController* sc = Game::getInstance()->getScriptController();
 
     // If the constant is within a scope, get the correct parent 
     // table on the stack before setting its value.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         for (unsigned int i = 1; i < scopePath.size(); i++)
@@ -92,13 +92,13 @@ void ScriptUtil::registerConstantBool(std::string name, bool value, std::vector<
     }
 }
 
-void ScriptUtil::registerConstantNumber(std::string name, double value, std::vector<std::string> scopePath)
+void ScriptUtil::registerConstantNumber(const std::string& name, double value, const std::vector<std::string>& scopePath)
 {
     ScriptController* sc = Game::getInstance()->getScriptController();
 
     // If the constant is within a scope, get the correct parent 
     // table on the stack before setting its value.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         for (unsigned int i = 1; i < scopePath.size(); i++)
@@ -125,13 +125,13 @@ void ScriptUtil::registerConstantNumber(std::string name, double value, std::vec
     }
 }
 
-void ScriptUtil::registerConstantString(std::string name, std::string value, std::vector<std::string> scopePath)
+void ScriptUtil::registerConstantString(const std::string& name, const std::string& value, const std::vector<std::string>& scopePath)
 {
     ScriptController* sc = Game::getInstance()->getScriptController();
 
     // If the constant is within a scope, get the correct parent 
     // table on the stack before setting its value.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         for (unsigned int i = 1; i < scopePath.size(); i++)
@@ -159,13 +159,13 @@ void ScriptUtil::registerConstantString(std::string name, std::string value, std
 }
 
 void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CFunction newFunction, 
-    lua_CFunction deleteFunction, const luaL_Reg* statics,  std::vector<std::string> scopePath)
+    lua_CFunction deleteFunction, const luaL_Reg* statics,  const std::vector<std::string>& scopePath)
 {
     ScriptController* sc = Game::getInstance()->getScriptController();
 
     // If the type is an inner type, get the correct parent 
     // table on the stack before creating the table for the class.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
         std::string tablename = name;
 
@@ -229,7 +229,7 @@ void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CF
     }
 
     // Set the table we just created within the correct parent table.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
         lua_settable(sc->_lua, -3);
 
@@ -250,7 +250,7 @@ void ScriptUtil::registerFunction(const char* luaFunction, lua_CFunction cppFunc
     lua_setglobal(Game::getInstance()->getScriptController()->_lua, luaFunction);
 }
 
-void ScriptUtil::setGlobalHierarchyPair(std::string base, std::string derived)
+void ScriptUtil::setGlobalHierarchyPair(const std::string& base, const std::string& derived)
 {
     Game::getInstance()->getScriptController()->_hierarchy[base].push_back(derived);
 }
@@ -784,7 +784,7 @@ void ScriptController::executeFunctionHelper(int resultCount, const char* func,
         GP_WARN("Failed to call function '%s' with error '%s'.", func, lua_tostring(_lua, -1));
 }
 
-void ScriptController::registerCallback(ScriptCallback callback, std::string function)
+void ScriptController::registerCallback(ScriptCallback callback, const std::string& function)
 {
     SAFE_DELETE(_callbacks[callback]);
     _callbacks[callback] = new std::string(function);
@@ -1058,4 +1058,4 @@ template<> std::string ScriptController::executeFunction<std::string>(const char
     SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(std::string, luaL_checkstring);
 }
 
-}
+}

+ 55 - 55
gameplay/src/ScriptController.h

@@ -39,46 +39,46 @@ class LuaArray
 {
 public:
 
-	/**
-	 * Creates a LuaArray to store a single pointer value.
-	 */
-	LuaArray(T* param);
-
-	/**
-	 * Allocates a LuaArray to store an array of values.
-	 *
-	 * Individual items in the array can be set using the 
-	 * set(unsigned int, const T&) method.
-	 * 
-	 * @param count Number of elements to store in the parameter.
-	 */
-	LuaArray(int count);
-
-	/**
-	 * Copy construcotr.
-	 */
-	LuaArray(const LuaArray<T>& copy);
-
-	/**
-	 * Destructor.
-	 */
-	~LuaArray();
-
-	/**
-	 * Assignment operator.
-	 */
-	LuaArray<T>& operator = (const LuaArray<T>& p);
-
-	/**
-	 * Copies the value of the object pointed to by itemPtr into the specified
+    /**
+     * Creates a LuaArray to store a single pointer value.
+     */
+    LuaArray(T* param);
+
+    /**
+     * Allocates a LuaArray to store an array of values.
+     *
+     * Individual items in the array can be set using the 
+     * set(unsigned int, const T&) method.
+     * 
+     * @param count Number of elements to store in the parameter.
+     */
+    LuaArray(int count);
+
+    /**
+     * Copy construcotr.
+     */
+    LuaArray(const LuaArray<T>& copy);
+
+    /**
+     * Destructor.
+     */
+    ~LuaArray();
+
+    /**
+     * Assignment operator.
+     */
+    LuaArray<T>& operator = (const LuaArray<T>& p);
+
+    /**
+     * Copies the value of the object pointed to by itemPtr into the specified
      * index of this LuaArray's array.
-	 */
-	void set(unsigned int index, const T* itemPtr);
+     */
+    void set(unsigned int index, const T* itemPtr);
 
-	/**
-	 * Conversion operator from LuaArray to T*.
-	 */
-	operator T* () const;
+    /**
+     * Conversion operator from LuaArray to T*.
+     */
+    operator T* () const;
 
     /**
      * Overloades [] operator to get/set item value at index.
@@ -87,14 +87,14 @@ public:
 
 private:
 
-	struct Data
-	{
+    struct Data
+    {
         Data() : value(NULL), refCount(0) { }
-		T* value;
-		int refCount;
-	};
+        T* value;
+        int refCount;
+    };
 
-	Data* _data;
+    Data* _data;
 };
 
 /**
@@ -114,7 +114,7 @@ void registerLibrary(const char* name, const luaL_Reg* functions);
  * @param scopePath The list of containing classes, going inward from the most outer class.
  * @script{ignore}
  */
-void registerConstantBool(std::string name, bool value, std::vector<std::string> scopePath);
+void registerConstantBool(const std::string& name, bool value, const std::vector<std::string>& scopePath);
 
 /**
  * Registers the given number constant as valid for the given scope path.
@@ -124,7 +124,7 @@ void registerConstantBool(std::string name, bool value, std::vector<std::string>
  * @param scopePath The list of containing classes, going inward from the most outer class.
  * @script{ignore}
  */
-void registerConstantNumber(std::string name, double value, std::vector<std::string> scopePath);
+void registerConstantNumber(const std::string& name, double value, const std::vector<std::string>& scopePath);
 
 /**
  * Registers the given string constant as valid for the given scope path.
@@ -134,7 +134,7 @@ void registerConstantNumber(std::string name, double value, std::vector<std::str
  * @param scopePath The list of containing classes, going inward from the most outer class.
  * @script{ignore}
  */
-void registerConstantString(std::string name, std::string value, std::vector<std::string> scopePath);
+void registerConstantString(const std::string& name, const std::string& value, const std::vector<std::string>& scopePath);
 
 /**
  * Registers the given class type with Lua.
@@ -148,7 +148,7 @@ void registerConstantString(std::string name, std::string value, std::vector<std
  * @script{ignore}
  */
 void registerClass(const char* name, const luaL_Reg* members, lua_CFunction newFunction, lua_CFunction deleteFunction, const luaL_Reg* statics,
-    std::vector<std::string> scopePath = std::vector<std::string>());
+    const std::vector<std::string>& scopePath);
 
 /**
  * Register a function with Lua.
@@ -166,7 +166,7 @@ void registerFunction(const char* luaFunction, lua_CFunction cppFunction);
  * @param derived The derived class of the inheritance pair.
  * @script{ignore}
  */
-void setGlobalHierarchyPair(std::string base, std::string derived);
+void setGlobalHierarchyPair(const std::string& base, const std::string& derived);
 
 /**
  * Adds the given function as a string-from-enumerated value conversion function.
@@ -781,7 +781,7 @@ private:
      * @param callback The script callback to register for.
      * @param function The name of the function within the Lua script to call.
      */
-    void registerCallback(ScriptCallback callback, std::string function);
+    void registerCallback(ScriptCallback callback, const std::string& function);
 
     /**
      * Converts the given string to a valid script callback enumeration value
@@ -794,13 +794,13 @@ private:
 
     // Friend functions (used by Lua script bindings).
     friend void ScriptUtil::registerLibrary(const char* name, const luaL_Reg* functions);
-    friend void ScriptUtil::registerConstantBool(std::string name, bool value, std::vector<std::string> scopePath);
-    friend void ScriptUtil::registerConstantNumber(std::string name, double value, std::vector<std::string> scopePath);
-    friend void ScriptUtil::registerConstantString(std::string name, std::string value, std::vector<std::string> scopePath);
+    friend void ScriptUtil::registerConstantBool(const std::string& name, bool value, const std::vector<std::string>& scopePath);
+    friend void ScriptUtil::registerConstantNumber(const std::string& name, double value, const std::vector<std::string>& scopePath);
+    friend void ScriptUtil::registerConstantString(const std::string& name, const std::string& value, const std::vector<std::string>& scopePath);
     friend void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CFunction newFunction,
-        lua_CFunction deleteFunction, const luaL_Reg* statics, std::vector<std::string> scopePath);
+        lua_CFunction deleteFunction, const luaL_Reg* statics, const std::vector<std::string>& scopePath);
     friend void ScriptUtil::registerFunction(const char* luaFunction, lua_CFunction cppFunction);
-    friend void ScriptUtil::setGlobalHierarchyPair(std::string base, std::string derived);
+    friend void ScriptUtil::setGlobalHierarchyPair(const std::string& base, const std::string& derived);
     friend void ScriptUtil::addStringFromEnumConversionFunction(luaStringEnumConversionFunction stringFromEnum);
     friend ScriptUtil::LuaArray<bool> ScriptUtil::getBoolPointer(int index);
     friend ScriptUtil::LuaArray<short> ScriptUtil::getShortPointer(int index);

+ 32 - 32
gameplay/src/ScriptController.inl

@@ -6,71 +6,71 @@ namespace gameplay
 template <typename T>
 ScriptUtil::LuaArray<T>::LuaArray(T* param)
 {
-	_data = new ScriptUtil::LuaArray<T>::Data();
-	_data->value = param;
+    _data = new ScriptUtil::LuaArray<T>::Data();
+    _data->value = param;
 
-	// Initial ref count of zero means no memory management
-	_data->refCount = 0;
+    // Initial ref count of zero means no memory management
+    _data->refCount = 0;
 }
 
 template <typename T>
 ScriptUtil::LuaArray<T>::LuaArray(int count)
 {
-	_data = new ScriptUtil::LuaArray<T>::Data();
+    _data = new ScriptUtil::LuaArray<T>::Data();
 
-	// Allocate a chunk of memory to store 'count' number of T.
-	// Use new instead of malloc since we track memory allocations
-	// int DebugMem configurations.
-	_data->value = (T*)new unsigned char[sizeof(T) * count];
+    // Allocate a chunk of memory to store 'count' number of T.
+    // Use new instead of malloc since we track memory allocations
+    // int DebugMem configurations.
+    _data->value = (T*)new unsigned char[sizeof(T) * count];
 
-	// Positive ref count means we automatically cleanup memory
-	_data->refCount = 1;
+    // Positive ref count means we automatically cleanup memory
+    _data->refCount = 1;
 }
 
 template <typename T>
 ScriptUtil::LuaArray<T>::LuaArray(const ScriptUtil::LuaArray<T>& copy)
 {
-	_data = copy._data;
-	++_data->refCount;
+    _data = copy._data;
+    ++_data->refCount;
 }
 
 template <typename T>
 ScriptUtil::LuaArray<T>::~LuaArray()
 {
-	if ((--_data->refCount) <= 0)
-	{
+    if ((--_data->refCount) <= 0)
+    {
         // Non managed arrays/pointers start with ref count zero, so only delete data if
         // the decremented ref count == 0 (otherwise it will be -1).
         if (_data->refCount == 0)
         {
             unsigned char* value = (unsigned char*)_data->value;
-		    SAFE_DELETE_ARRAY(value);
+            SAFE_DELETE_ARRAY(value);
         }
 
         SAFE_DELETE(_data);
-	}
+    }
 }
 
 template <typename T>
 ScriptUtil::LuaArray<T>& ScriptUtil::LuaArray<T>::operator = (const ScriptUtil::LuaArray<T>& p)
 {
     _data = p._data;
-	++_data->refCount;
+    ++_data->refCount;
 }
 
 template <typename T>
 void ScriptUtil::LuaArray<T>::set(unsigned int index, const T* itemPtr)
 {
-	// WARNING: The following code will only work properly for arrays of pointers
-	// to objects (i.e. T**) or for simple structs that are being passed
-	// in as read-only. Since the memory is directly copied, any member data that
-	// is modified with the object that is copied, will not modify the original object.
-	// What is even scarier is that if an array of objects that contain virtual functions
-	// is copied here, then the vtables are copied directly, meaning the new object
-	// contains a copy of a vtable that points to functions in the old object. Calling
-	// virtual fucntions on the new object would then call the functions on the old object.
-	// If the old object is deleted, the vtable on the new object would point to addressess
-	// for functions that no longer exist.
+    // WARNING: The following code will only work properly for arrays of pointers
+    // to objects (i.e. T**) or for simple structs that are being passed
+    // in as read-only. Since the memory is directly copied, any member data that
+    // is modified with the object that is copied, will not modify the original object.
+    // What is even scarier is that if an array of objects that contain virtual functions
+    // is copied here, then the vtables are copied directly, meaning the new object
+    // contains a copy of a vtable that points to functions in the old object. Calling
+    // virtual fucntions on the new object would then call the functions on the old object.
+    // If the old object is deleted, the vtable on the new object would point to addressess
+    // for functions that no longer exist.
     if (itemPtr)
         memcpy((void*)&_data->value[index], (void*)itemPtr, sizeof(T));
     else
@@ -80,7 +80,7 @@ void ScriptUtil::LuaArray<T>::set(unsigned int index, const T* itemPtr)
 template <typename T>
 ScriptUtil::LuaArray<T>::operator T* () const
 {
-	return _data->value;
+    return _data->value;
 }
 
 template <typename T>
@@ -111,7 +111,7 @@ ScriptUtil::LuaArray<T> ScriptUtil::getObjectPointer(int index, const char* type
         if (size <= 0)
             return LuaArray<T>((T*)NULL);
 
-		LuaArray<T> arr(size);
+        LuaArray<T> arr(size);
 
         // Push the first key.
         lua_pushnil(sc->_lua);
@@ -128,7 +128,7 @@ ScriptUtil::LuaArray<T> ScriptUtil::getObjectPointer(int index, const char* type
                     if (lua_rawequal(sc->_lua, -1, -2))
                     {
                         lua_pop(sc->_lua, 2);
-						arr.set(i, (T*)((ScriptUtil::LuaObject*)p)->instance);
+                        arr.set(i, (T*)((ScriptUtil::LuaObject*)p)->instance);
                         lua_pop(sc->_lua, 1);
                         continue;
                     }
@@ -142,7 +142,7 @@ ScriptUtil::LuaArray<T> ScriptUtil::getObjectPointer(int index, const char* type
                         if (lua_rawequal(sc->_lua, -1, -2))
                         {
                             lua_pop(sc->_lua, 2);
-							arr.set(i, (T*)((ScriptUtil::LuaObject*)p)->instance);
+                            arr.set(i, (T*)((ScriptUtil::LuaObject*)p)->instance);
                             lua_pop(sc->_lua, 1);
                             continue;
                         }

+ 1 - 4
gameplay/src/Slider.cpp

@@ -6,7 +6,7 @@ namespace gameplay
 // Fraction of slider to scroll when mouse scrollwheel is used.
 static const float SCROLL_FRACTION = 0.1f;
 
-Slider::Slider() : _minImage(NULL), _maxImage(NULL), _trackImage(NULL), _markerImage(NULL)
+Slider::Slider() : _min(0.0f), _max(0.0f), _step(0.0f), _value(0.0f), _minImage(NULL), _maxImage(NULL), _trackImage(NULL), _markerImage(NULL)
 {
 }
 
@@ -240,9 +240,6 @@ void Slider::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
     // The slider is drawn in the center of the control (perpendicular to orientation).
     // The track is stretched according to orientation.
     // Caps and marker are not stretched.
-    const Theme::Border& border = getBorder(_state);
-    const Theme::Padding& padding = getPadding();
-
     const Rectangle& minCapRegion = _minImage->getRegion();
     const Rectangle& maxCapRegion = _maxImage->getRegion();
     const Rectangle& markerRegion = _markerImage->getRegion();

+ 4 - 4
gameplay/src/SpriteBatch.h

@@ -124,7 +124,7 @@ public:
      * @param color The color to tint the sprite. Use white for no tint.
      * @param rotationPoint The point to rotate around, relative to dst's x and y values.
      *                      (e.g. Use Vector2(0.5f, 0.5f) to rotate around the quad's center.)
-     * @param rotationAngle The rotation angle.
+     * @param rotationAngle The rotation angle in radians.
      */
     void draw(const Vector3& dst, const Rectangle& src, const Vector2& scale, const Vector4& color,
               const Vector2& rotationPoint, float rotationAngle);
@@ -142,7 +142,7 @@ public:
      * @param color The color to tint the sprite. Use white for no tint.
      * @param rotationPoint The point to rotate around, relative to dst's x and y values.
      *                      (e.g. Use Vector2(0.5f, 0.5f) to rotate around the quad's center.)
-     * @param rotationAngle The rotation angle.
+     * @param rotationAngle The rotation angle in radians.
      * @param positionIsCenter Specified whether the given destination is to be the center of the sprite or not (if not, it is treated as the bottom-left).
      */
     void draw(const Vector3& dst, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color,
@@ -163,7 +163,7 @@ public:
      * @param color The color to tint the sprite. Use white for no tint.
      * @param rotationPoint The point to rotate around, relative to dst's x and y values.
      *                      (e.g. Use Vector2(0.5f, 0.5f) to rotate around the quad's center.)
-     * @param rotationAngle The rotation angle.
+     * @param rotationAngle The rotation angle in radians.
      * @param positionIsCenter Specified whether the given destination is to be the center of the sprite or not (if not, it is treated as the bottom-left).
      */
     void draw(float x, float y, float z, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color,
@@ -184,7 +184,7 @@ public:
      * @param color The color to tint the sprite. Use white for no tint.
      * @param rotationPoint The point to rotate around, relative to dst's x and y values.
      *                      (e.g. Use Vector2(0.5f, 0.5f) to rotate around the quad's center.)
-     * @param rotationAngle The rotation angle.
+     * @param rotationAngle The rotation angle in radians.
      */
     void draw(const Vector3& position, const Vector3& right, const Vector3& forward, float width, float height, 
               float u1, float v1, float u2, float v2, const Vector4& color, const Vector2& rotationPoint, float rotationAngle);

+ 11 - 11
gameplay/src/TextBox.cpp

@@ -4,7 +4,7 @@
 namespace gameplay
 {
 
-TextBox::TextBox() : _lastKeypress(0)
+TextBox::TextBox() : _textIndex(0), _lastKeypress(0), _fontSize(0), _caretImage(NULL)
 {
 }
 
@@ -250,11 +250,11 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                 {
                     case Keyboard::KEY_BACKSPACE:
                     {
-                        if (textIndex > 0)
+                        if (_textIndex > 0)
                         {
-                            --textIndex;
-                            _text.erase(textIndex, 1);
-                            font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, textIndex,
+                            --_textIndex;
+                            _text.erase(_textIndex, 1);
+                            font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, _textIndex,
                                 textAlignment, true, rightToLeft);
 
                             _dirty = true;
@@ -272,11 +272,11 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                     default:
                     {
                         // Insert character into string.
-                        _text.insert(textIndex, 1, (char)key);
+                        _text.insert(_textIndex, 1, (char)key);
                         consume = true;
 
                         // Get new location of caret.
-                        font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, textIndex + 1,
+                        font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, _textIndex + 1,
                             textAlignment, true, rightToLeft);
 
                         if (key == ' ')
@@ -286,8 +286,8 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                                 _caretLocation.y >= _textBounds.y + _textBounds.height)
                             {
                                 // If not, undo the character insertion.
-                                _text.erase(textIndex, 1);
-                                font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, textIndex,
+                                _text.erase(_textIndex, 1);
+                                font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, _textIndex,
                                     textAlignment, true, rightToLeft);
 
                                 // No need to check again.
@@ -302,8 +302,8 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                             textBounds.width >= _textBounds.width || textBounds.height >= _textBounds.height)
                         {
                             // If not, undo the character insertion.
-                            _text.erase(textIndex, 1);
-                            font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, textIndex,
+                            _text.erase(_textIndex, 1);
+                            font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, _textIndex,
                                 textAlignment, true, rightToLeft);
 
                             // TextBox is not dirty.

+ 1 - 1
gameplay/src/TextBox.h

@@ -152,7 +152,7 @@ protected:
     /**
      * The index into the TextBox's string that the caret is.
      */
-    unsigned int textIndex;
+    unsigned int _textIndex;
     
     /**
      * The last character that was entered into the TextBox.

+ 1 - 0
gameplay/src/Texture.cpp

@@ -402,6 +402,7 @@ GLubyte* Texture::readCompressedPVRTC(const char* path, FILE* file, GLsizei* wid
     read = fread(data, 1, dataSize, file);
     if (read != dataSize)
     {
+        SAFE_DELETE_ARRAY(data);
         GP_ERROR("Failed to read texture data from PVR file '%s'.", path);
         return NULL;
     }

+ 5 - 7
gameplay/src/Theme.cpp

@@ -457,7 +457,7 @@ Theme::Style* Theme::getEmptyStyle()
         overlay->addRef();
         overlay->addRef();
         overlay->addRef();
-        emptyStyle = new Theme::Style((Theme*)this, "EMPTY_STYLE", 1.0f / _texture->getWidth(), 1.0f / _texture->getHeight(),
+        emptyStyle = new Theme::Style(const_cast<Theme*>(this), "EMPTY_STYLE", 1.0f / _texture->getWidth(), 1.0f / _texture->getHeight(),
             Theme::Margin::empty(), Theme::Border::empty(), overlay, overlay, overlay, overlay);
 
         _styles.push_back(emptyStyle);
@@ -584,12 +584,10 @@ Theme::ImageList::ImageList(const Vector4& color) : _color(color)
 }
 
 Theme::ImageList::ImageList(const ImageList& copy)
+    : _id(copy._id), _color(copy._color)
 {
-    _id = copy._id;
-    _color = copy._color;
-
     std::vector<ThemeImage*>::const_iterator it;
-    for (it = copy._images.begin(); it != copy._images.end(); it++)
+    for (it = copy._images.begin(); it != copy._images.end(); ++it)
     {
         ThemeImage* image = *it;
         GP_ASSERT(image);
@@ -600,7 +598,7 @@ Theme::ImageList::ImageList(const ImageList& copy)
 Theme::ImageList::~ImageList()
 {
     std::vector<ThemeImage*>::const_iterator it;
-    for (it = _images.begin(); it != _images.end(); it++)
+    for (it = _images.begin(); it != _images.end(); ++it)
     {
         ThemeImage* image = *it;
         SAFE_RELEASE(image);
@@ -647,7 +645,7 @@ Theme::ThemeImage* Theme::ImageList::getImage(const char* imageId) const
     GP_ASSERT(imageId);
 
     std::vector<ThemeImage*>::const_iterator it;
-    for (it = _images.begin(); it != _images.end(); it++)
+    for (it = _images.begin(); it != _images.end(); ++it)
     {
         ThemeImage* image = *it;
         GP_ASSERT(image);

+ 2 - 2
gameplay/src/Transform.cpp

@@ -829,7 +829,7 @@ void Transform::removeListener(Transform::Listener* listener)
 
     if (_listeners)
     {
-        for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
+        for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); ++itr)
         {
             if ((*itr).listener == listener)
             {
@@ -844,7 +844,7 @@ void Transform::transformChanged()
 {
     if (_listeners)
     {
-        for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
+        for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); ++itr)
         {
             TransformListener& l = *itr;
             GP_ASSERT(l.listener);

+ 1 - 1
gameplay/src/Vector4.cpp

@@ -91,7 +91,7 @@ bool Vector4::isZero() const
 
 bool Vector4::isOne() const
 {
-    return x == 1.0f && y == 1.0f && z == 1.0f && z == 1.0f;
+    return x == 1.0f && y == 1.0f && z == 1.0f && w == 1.0f;
 }
 
 float Vector4::angle(const Vector4& v1, const Vector4& v2)

+ 1 - 1
gameplay/src/gameplay-main-ios.mm

@@ -15,7 +15,7 @@ int main(int argc, char** argv)
     Platform* platform = Platform::create(game);
     GP_ASSERT(platform);
     int result = platform->enterMessagePump();
-	delete platform;
+    delete platform;
     [p release];
     return result;
 }

+ 1 - 1
gameplay/src/gameplay-main-macosx.mm

@@ -15,7 +15,7 @@ int main(int argc, char** argv)
     Platform* platform = Platform::create(game);
     GP_ASSERT(platform);
     int result = platform->enterMessagePump();
-	delete platform;
+    delete platform;
     [p release];
     return result;
 }

+ 38 - 0
gameplay/src/lua/lua_Game.cpp

@@ -34,6 +34,7 @@ void luaRegister_Game()
         {"getAIController", lua_Game_getAIController},
         {"getAccelerometerValues", lua_Game_getAccelerometerValues},
         {"getAnimationController", lua_Game_getAnimationController},
+        {"getAspectRatio", lua_Game_getAspectRatio},
         {"getAudioController", lua_Game_getAudioController},
         {"getAudioListener", lua_Game_getAudioListener},
         {"getConfig", lua_Game_getConfig},
@@ -641,6 +642,43 @@ int lua_Game_getAnimationController(lua_State* state)
     return 0;
 }
 
+int lua_Game_getAspectRatio(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Game* instance = getInstance(state);
+                float result = instance->getAspectRatio();
+
+                // Push the return value onto the stack.
+                lua_pushnumber(state, result);
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Game_getAspectRatio - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Game_getAudioController(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Game.h

@@ -17,6 +17,7 @@ int lua_Game_gestureTapEvent(lua_State* state);
 int lua_Game_getAIController(lua_State* state);
 int lua_Game_getAccelerometerValues(lua_State* state);
 int lua_Game_getAnimationController(lua_State* state);
+int lua_Game_getAspectRatio(lua_State* state);
 int lua_Game_getAudioController(lua_State* state);
 int lua_Game_getAudioListener(lua_State* state);
 int lua_Game_getConfig(lua_State* state);

+ 47 - 0
gameplay/src/lua/lua_MaterialParameter.cpp

@@ -28,6 +28,7 @@ void luaRegister_MaterialParameter()
         {"getAnimationPropertyValue", lua_MaterialParameter_getAnimationPropertyValue},
         {"getName", lua_MaterialParameter_getName},
         {"getRefCount", lua_MaterialParameter_getRefCount},
+        {"getSampler", lua_MaterialParameter_getSampler},
         {"release", lua_MaterialParameter_release},
         {"setAnimationPropertyValue", lua_MaterialParameter_setAnimationPropertyValue},
         {"setValue", lua_MaterialParameter_setValue},
@@ -788,6 +789,52 @@ int lua_MaterialParameter_getRefCount(lua_State* state)
     return 0;
 }
 
+int lua_MaterialParameter_getSampler(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                MaterialParameter* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getSampler();
+                if (returnPtr)
+                {
+                    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "TextureSampler");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_MaterialParameter_getSampler - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_MaterialParameter_release(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_MaterialParameter.h

@@ -17,6 +17,7 @@ int lua_MaterialParameter_getAnimationPropertyComponentCount(lua_State* state);
 int lua_MaterialParameter_getAnimationPropertyValue(lua_State* state);
 int lua_MaterialParameter_getName(lua_State* state);
 int lua_MaterialParameter_getRefCount(lua_State* state);
+int lua_MaterialParameter_getSampler(lua_State* state);
 int lua_MaterialParameter_release(lua_State* state);
 int lua_MaterialParameter_setAnimationPropertyValue(lua_State* state);
 int lua_MaterialParameter_setValue(lua_State* state);