Sfoglia il codice sorgente

Merge pull request #80 from blackberry-gaming/next-sgrenier

Next sgrenier
Sean Paul Taylor 14 anni fa
parent
commit
68b0a8cfc6

+ 6 - 2
gameplay-encoder/gameplay-encoder.vcxproj

@@ -158,7 +158,9 @@
       <IgnoreSpecificDefaultLibraries>MSVCRT</IgnoreSpecificDefaultLibraries>
     </Link>
     <PostBuildEvent>
-      <Command>copy /Y "$(ProjectDir)..\external-deps\collada-dom\lib\win32\*.dll" "$(TargetDir)"</Command>
+      <Command>copy /Y "$(ProjectDir)..\external-deps\collada-dom\lib\win32\*.dll" "$(TargetDir)"
+copy /Y "$(ProjectDir)..\external-deps\zlib\lib\win32\*.dll" "$(TargetDir)"
+</Command>
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -183,7 +185,9 @@
       </IgnoreSpecificDefaultLibraries>
     </Link>
     <PostBuildEvent>
-      <Command>copy /Y "$(ProjectDir)..\external-deps\collada-dom\lib\win32\*.dll" "$(TargetDir)"</Command>
+      <Command>copy /Y "$(ProjectDir)..\external-deps\collada-dom\lib\win32\*.dll" "$(TargetDir)"
+copy /Y "$(ProjectDir)..\external-deps\zlib\lib\win32\*.dll" "$(TargetDir)"
+</Command>
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

+ 8 - 9
gameplay/src/BoundingSphere.cpp

@@ -283,15 +283,14 @@ void BoundingSphere::set(const BoundingBox& box)
 void BoundingSphere::transform(const Matrix& matrix)
 {
     // Translate the center point.
-    Vector3 translate;
-    matrix.transformPoint(center, &translate);
-    center = translate;
-
-    // Calculate the sphere's new radius from the radii in each direction (take the largest).
-    matrix.decompose(&translate, NULL, NULL);
-    float r = radius * translate.x;
-    r = max(radius, radius * translate.y);
-    r = max(radius, radius * translate.z);
+    matrix.transformPoint(center, &center);
+
+    // Scale the sphere's radius by the scale fo the matrix
+    Vector3 scale;
+    matrix.decompose(&scale, NULL, NULL);
+    float r = radius * scale.x;
+    r = max(r, radius * scale.y);
+    r = max(r, radius * scale.z);
     radius = r;
 }
 

+ 1 - 1
gameplay/src/Game.h

@@ -256,7 +256,7 @@ protected:
      * This is useful for rendering splash screens.
      */
     template <class T>
-    void renderOnce(T* instance, void (T::*method)(long), long cookie);
+    void renderOnce(T* instance, void (T::*method)(void*), void* cookie);
 
 private:
 

+ 1 - 1
gameplay/src/Game.inl

@@ -40,7 +40,7 @@ inline PhysicsController* Game::getPhysicsController() const
 }
 
 template <class T>
-void  Game::renderOnce(T* instance, void (T::*method)(long), long cookie)
+void  Game::renderOnce(T* instance, void (T::*method)(void*), void* cookie)
 {
     (instance->*method)(cookie);
     Platform::swapBuffers();

+ 5 - 0
gameplay/src/Package.cpp

@@ -996,6 +996,11 @@ Animation* Package::readAnimationChannel(Scene* scene, Animation* animation, con
     return animation;
 }
 
+Mesh* Package::loadMesh(const char* id)
+{
+    return loadMesh(id, false, NULL);
+}
+
 Mesh* Package::loadMesh(const char* id, bool loadWithMeshRBSupport, const char* nodeId)
 {
     // save the file position

+ 17 - 10
gameplay/src/Scene.h

@@ -167,16 +167,18 @@ public:
      *
      * Calling this method invokes the specified method pointer for each node
      * in the scene hierarchy, passing the Node and the specified cookie value.
-     * The visitMethod parameter must be a pointer to a method that has a void
-     * return type and accepts two parameters: a Node pointer and a long value
-     * (cookie).
+     * 
+     * The visitMethod parameter must be a pointer to a method that has a bool
+     * return type and accepts two parameters: a Node pointer and a void* (cookie).
+     * The scene travesal continues while visitMethod return true. Returning false
+     * will cause the traversal to stop.
      *
      * @param instance The pointer to an instance of the object that contains visitMethod.
      * @param visitMethod The pointer to the class method to call for each node in the scene.
      * @param cookie An optional user-defined parameter that will be passed to each invocation of visitMethod.
      */
     template <class T>
-    void visit(T* instance, void (T::*visitMethod)(Node*,long), long cookie = 0);
+    void visit(T* instance, bool (T::*visitMethod)(Node*,void*), void* cookie = 0);
 
 private:
 
@@ -199,7 +201,7 @@ private:
      * Visits the given node and all of its children recursively.
      */
     template <class T>
-    void visitNode(Node* node, T* instance, void (T::*visitMethod)(Node*,long), long cookie);
+    bool visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*,void*), void* cookie);
 
     std::string _id;
     Camera* _activeCamera;
@@ -212,25 +214,30 @@ private:
 };
 
 template <class T>
-void Scene::visit(T* instance, void (T::*visitMethod)(Node*,long), long cookie)
+void Scene::visit(T* instance, bool (T::*visitMethod)(Node*,void*), void* cookie)
 {
     for (Node* node = getFirstNode(); node != NULL; node = node->getNextSibling())
     {
-        visitNode(node, instance, visitMethod, cookie);
+        if (!visitNode(node, instance, visitMethod, cookie))
+            return;
     }
 }
 
 template <class T>
-void Scene::visitNode(Node* node, T* instance, void (T::*visitMethod)(Node*,long), long cookie)
+bool Scene::visitNode(Node* node, T* instance, bool (T::*visitMethod)(Node*,void*), void* cookie)
 {
     // Invoke the visit method for this node.
-    (instance->*visitMethod)(node, cookie);
+    if (!(instance->*visitMethod)(node, cookie))
+        return false;
 
     // Recurse for all children.
     for (Node* child = node->getFirstChild(); child != NULL; child = child->getNextSibling())
     {
-        visitNode(child, instance, visitMethod, cookie);
+        if (!visitNode(child, instance, visitMethod, cookie))
+            return false;
     }
+
+    return true;
 }
 
 }