Browse Source

Merge branch 'master' of https://github.com/blackberry/GamePlay

setaylor 13 years ago
parent
commit
71ea7b9d45

+ 15 - 1
gameplay-api/header.html

@@ -7,6 +7,7 @@
 
 <link href="tabs.css" rel="stylesheet" type="text/css"/>
 <link href="doxygen.css" rel="stylesheet" type="text/css" />
+<link href="custom.css" rel="stylesheet" type="text/css" />
 
 <link href="search/search.css" rel="stylesheet" type="text/css"/>
 <script type="text/javascript" src="jquery.js"></script>
@@ -17,4 +18,17 @@
 
 </head>
 <body>
-<div id="top"><!-- do not remove this div! -->
+<div id="top"><!-- do not remove this div! -->
+<table class="header" border="0">
+<tbody>
+<tr>
+<td id="logo"><a href="http://gameplay3d.org/"><img src="images/logo.png" alt="gameplay" border="0" height="64px"/></a></td>
+<td width="100%"/>
+<td><a href="http://gameplay3d.org/"><span class="button">overview</span></a></td><td width="12px"/>
+<td><a href="https://github.com/blackberry/GamePlay/wiki"><span class="button">wiki</span></a></td><td width="12px"/>
+<td><a href="http://blackberry.github.com/GamePlay/api/index.html"><span class="button">api&nbsp;reference</span></a></td><td width="12px"/>
+<td><a href="http://www.gameplay3d.org/forums"><span class="button">forums</span></a></td>
+<td><a href="https://github.com/blackberry/GamePlay"><span class="button">download</span></a></td>
+</tr>
+</tbody>
+</table>

+ 6 - 0
gameplay/src/Animation.cpp

@@ -453,6 +453,12 @@ Animation* Animation::clone(Channel* channel, AnimationTarget* target)
     GP_ASSERT(animation->getRefCount() == 1);
 
     // Clone the clips
+    
+    if (_defaultClip)
+    {
+        animation->_defaultClip = _defaultClip->clone(animation);
+    }
+    
     if (_clips)
     {
         for (std::vector<AnimationClip*>::iterator it = _clips->begin(); it != _clips->end(); ++it)

+ 0 - 1
gameplay/src/AnimationClip.cpp

@@ -598,7 +598,6 @@ AnimationClip* AnimationClip::clone(Animation* animation) const
 {
     // Don't clone the elapsed time, listeners or crossfade information.
     AnimationClip* newClip = new AnimationClip(getId(), animation, getStartTime(), getEndTime());
-    newClip->setRepeatCount(getRepeatCount());
     newClip->setSpeed(getSpeed());
     newClip->setRepeatCount(getRepeatCount());
     newClip->setBlendWeight(getBlendWeight());

+ 18 - 1
gameplay/src/AnimationTarget.cpp

@@ -4,6 +4,8 @@
 #include "Game.h"
 #include "Node.h"
 
+#define ANIMATION_TARGET_INDEFINITE_STR "INDEFINITE"
+
 namespace gameplay
 {
 
@@ -261,6 +263,21 @@ Animation* AnimationTarget::createAnimation(const char* id, Properties* animatio
         animation = createAnimation(id, propertyId, keyCount, keyTimes, keyValues, (Curve::InterpolationType) curve);
     }
 
+    const char* repeat = animationProperties->getString("repeatCount");
+    if (repeat)
+    {
+        if (strcmp(repeat, ANIMATION_TARGET_INDEFINITE_STR) == 0)
+        {
+            animation->getClip()->setRepeatCount(AnimationClip::REPEAT_INDEFINITE);
+        }
+        else
+        {
+            float value;
+            sscanf(repeat, "%f", &value);
+            animation->getClip()->setRepeatCount(value);
+        }
+    }
+    
     SAFE_DELETE_ARRAY(keyOut);
     SAFE_DELETE_ARRAY(keyIn);
     SAFE_DELETE_ARRAY(keyValues);
@@ -277,7 +294,7 @@ Animation* AnimationTarget::createAnimation(const char* id, Properties* animatio
         }
         animation->createClips(animationProperties, (unsigned int) frameCount);
     }
-
+    
     return animation;
 }
 

+ 3 - 0
gameplay/src/MaterialParameter.cpp

@@ -663,6 +663,9 @@ void MaterialParameter::cloneInto(MaterialParameter* materialParameter) const
         GP_ERROR("Unsupported material parameter type(%d).", _type);
         break;
     }
+    
+    NodeCloneContext context;
+    this->AnimationTarget::cloneInto(materialParameter, context);
 }
 
 }

+ 51 - 90
gameplay/src/PlatformiOS.mm

@@ -38,28 +38,26 @@ extern const int WINDOW_SCALE = [[UIScreen mainScreen] scale];
 static AppDelegate *__appDelegate = NULL;
 static View* __view = NULL;
 
-class TouchPointListElement
+class TouchPoint
 {
 public:
-    TouchPointListElement* _next;
-    TouchPointListElement* _prev;
-    unsigned int _id; // as assigned from hash
-    unsigned int _index; // to save time during touchesBegan
-    int _x;
-    int _y;
+    unsigned int hashId;
+    int x;
+    int y;
+    bool down;
     
-    TouchPointListElement()
+    TouchPoint()
     {
-        _next = NULL;
-        _prev = NULL;
-        _id = 0;
-        _index = 0;
-        _x = 0;
-        _y = 0;
+        hashId = 0;
+        x = 0;
+        y = 0;
+        down = false;
     }
 };
-static TouchPointListElement* __touchPointListHead = NULL;
-static TouchPointListElement* __touchPointListTail = NULL;
+
+// more than we'd ever need, to be safe
+#define TOUCH_POINTS_MAX (10)
+static TouchPoint __touchPoints[TOUCH_POINTS_MAX];
 
 static double __timeStart;
 static double __timeAbsolute;
@@ -540,28 +538,26 @@ int getUnicode(int key);
             touchID = [touch hash];
         }
 
-        // Map hash to index
-        TouchPointListElement* elem = new TouchPointListElement();
-        if (__touchPointListTail)
+        // Nested loop efficiency shouldn't be a concern since both loop sizes are small (<= 10)
+        int i = 0;
+        while (i < TOUCH_POINTS_MAX && __touchPoints[i].down)
         {
-            // Insert at end of list
-            __touchPointListTail->_next = elem;
-            elem->_index = __touchPointListTail->_index + 1;
+            i++;
+        }
+
+        if (i < TOUCH_POINTS_MAX)
+        {
+            __touchPoints[i].hashId = touchID;
+            __touchPoints[i].x = touchPoint.x * WINDOW_SCALE;
+            __touchPoints[i].y = touchPoint.y * WINDOW_SCALE;
+            __touchPoints[i].down = true;
+
+            Platform::touchEventInternal(Touch::TOUCH_PRESS, __touchPoints[i].x, __touchPoints[i].y, i);
         }
         else
         {
-            // Insert into empty list
-            __touchPointListHead = elem;
-            elem->_index = 0;
+            print("touchesBegan: unable to find free element in __touchPoints");
         }
-
-        elem->_prev = __touchPointListTail;
-        __touchPointListTail = elem;
-        elem->_id = touchID;
-        elem->_x = touchPoint.x * WINDOW_SCALE;
-        elem->_y = touchPoint.y * WINDOW_SCALE;
-
-        Platform::touchEventInternal(Touch::TOUCH_PRESS, elem->_x, elem->_y, elem->_index);
     }
 }
 
@@ -574,65 +570,30 @@ int getUnicode(int key);
         if(self.multipleTouchEnabled == YES) 
             touchID = [touch hash];
 
-        // Map hash to index
-        TouchPointListElement* elem = NULL;
-        for (TouchPointListElement* p = __touchPointListHead; p; p = p->_next)
+        // Nested loop efficiency shouldn't be a concern since both loop sizes are small (<= 10)
+        bool found = false;
+        for (int i = 0; !found && i < TOUCH_POINTS_MAX; i++)
         {
-            if (p->_id == touchID)
+            if (__touchPoints[i].down && __touchPoints[i].hashId == touchID)
             {
-                // Remove from list
-                elem = p;
-                p = elem->_next;
-
-                if (elem->_prev)
-                {
-                    elem->_prev->_next = p;
-                }
-                else
-                {
-                    __touchPointListHead = p;
-                }
-                
-                if (p)
-                {
-                    p->_prev = elem->_prev;
-                }
-                else
-                {
-                    __touchPointListTail = elem->_prev;
-                    break;
-                }
-            }
-
-            if (elem)
-            {
-                // Release at the old index and press at the new index
-                Platform::touchEventInternal(Touch::TOUCH_RELEASE, p->_x, p->_y, p->_index);
-                p->_index--;
-                Platform::touchEventInternal(Touch::TOUCH_PRESS, p->_x, p->_y, p->_index);
+                __touchPoints[i].down = false;
+                Platform::touchEventInternal(Touch::TOUCH_RELEASE, touchPoint.x * WINDOW_SCALE, touchPoint.y * WINDOW_SCALE, i);
+                found = true;
             }
         }
         
-        if (elem)
-        {
-            Platform::touchEventInternal(Touch::TOUCH_RELEASE, touchPoint.x * WINDOW_SCALE, touchPoint.y * WINDOW_SCALE, elem->_index);
-            delete elem;
-        }
-        else
+        if (!found)
         {
-            // It seems possible to receive an ID not in the list.
-            // The best we can do is clear the whole list.
-            TouchPointListElement* p = __touchPointListTail;
-            while (p)
+            // It seems possible to receive an ID not in the array.
+            // The best we can do is clear the whole array.
+            for (int i = 0; i < TOUCH_POINTS_MAX; i++)
             {
-                TouchPointListElement* e = p;
-                p = e->_prev;
-                // Neglect p->_next since the whole list is being deleted.
-                Platform::touchEventInternal(Touch::TOUCH_RELEASE, e->_x, e->_y, e->_index);
-                delete e;
+                if (__touchPoints[i].down)
+                {
+                    __touchPoints[i].down = false;
+                    Platform::touchEventInternal(Touch::TOUCH_RELEASE, __touchPoints[i].x, __touchPoints[i].y, i);
+                }
             }
-            __touchPointListTail = NULL;
-            __touchPointListHead = NULL;
         }
     }
 }
@@ -652,14 +613,14 @@ int getUnicode(int key);
         if(self.multipleTouchEnabled == YES) 
             touchID = [touch hash];
 
-        // Map hash to index
-        for (TouchPointListElement* p = __touchPointListHead; p; p = p->_next)
+        // Nested loop efficiency shouldn't be a concern since both loop sizes are small (<= 10)
+        for (int i = 0; i < TOUCH_POINTS_MAX; i++)
         {
-            if (p->_id == touchID)
+            if (__touchPoints[i].down && __touchPoints[i].hashId == touchID)
             {
-                p->_x = touchPoint.x * WINDOW_SCALE;
-                p->_y = touchPoint.y * WINDOW_SCALE;
-                Platform::touchEventInternal(Touch::TOUCH_MOVE, p->_x, p->_y, p->_index);
+                __touchPoints[i].x = touchPoint.x * WINDOW_SCALE;
+                __touchPoints[i].y = touchPoint.y * WINDOW_SCALE;
+                Platform::touchEventInternal(Touch::TOUCH_MOVE, __touchPoints[i].x, __touchPoints[i].y, i);
                 break;
             }
         }