Quellcode durchsuchen

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

seanpaultaylor vor 12 Jahren
Ursprung
Commit
465c0d64cb

+ 6 - 6
gameplay/src/Bundle.cpp

@@ -189,7 +189,7 @@ Bundle* Bundle::create(const char* path)
     Stream* stream = FileSystem::open(path);
     if (!stream)
     {
-        GP_ERROR("Failed to open file '%s'.", path);
+        GP_WARN("Failed to open file '%s'.", path);
         return NULL;
     }
 
@@ -198,7 +198,7 @@ Bundle* Bundle::create(const char* path)
     if (stream->read(sig, 1, 9) != 9 || memcmp(sig, "\xABGPB\xBB\r\n\x1A\n", 9) != 0)
     {
         SAFE_DELETE(stream);
-        GP_ERROR("Invalid GPB header for bundle '%s'.", path);
+        GP_WARN("Invalid GPB header for bundle '%s'.", path);
         return NULL;
     }
 
@@ -207,14 +207,14 @@ Bundle* Bundle::create(const char* path)
     if (stream->read(version, 1, 2) != 2)
     {
         SAFE_DELETE(stream);
-        GP_ERROR("Failed to read GPB version for bundle '%s'.", path);
+        GP_WARN("Failed to read GPB version for bundle '%s'.", path);
         return NULL;
     }
     // Check for the minimal 
     if (version[0] != BUNDLE_VERSION_MAJOR_REQUIRED || version[1] < BUNDLE_VERSION_MINOR_REQUIRED)
     {
         SAFE_DELETE(stream);
-        GP_ERROR("Unsupported version (%d.%d) for bundle '%s' (expected %d.%d).", (int)version[0], (int)version[1], path, BUNDLE_VERSION_MAJOR_REQUIRED, BUNDLE_VERSION_MINOR_REQUIRED);
+        GP_WARN("Unsupported version (%d.%d) for bundle '%s' (expected %d.%d).", (int)version[0], (int)version[1], path, BUNDLE_VERSION_MAJOR_REQUIRED, BUNDLE_VERSION_MINOR_REQUIRED);
         return NULL;
     }
 
@@ -223,7 +223,7 @@ Bundle* Bundle::create(const char* path)
     if (stream->read(&refCount, 4, 1) != 1)
     {
         SAFE_DELETE(stream);
-        GP_ERROR("Failed to read ref table for bundle '%s'.", path);
+        GP_WARN("Failed to read ref table for bundle '%s'.", path);
         return NULL;
     }
 
@@ -236,7 +236,7 @@ Bundle* Bundle::create(const char* path)
             stream->read(&refs[i].offset, 4, 1) != 1)
         {
             SAFE_DELETE(stream);
-            GP_ERROR("Failed to read ref number %d for bundle '%s'.", i, path);
+            GP_WARN("Failed to read ref number %d for bundle '%s'.", i, path);
             SAFE_DELETE_ARRAY(refs);
             return NULL;
         }

+ 2 - 0
gameplay/src/Bundle.h

@@ -29,6 +29,8 @@ public:
      * release() method must be called. Note that calling release() does
      * NOT free any actual game objects created/returned from the Bundle
      * instance and those objects must be released separately.
+     * 
+     * @return The new Bundle or NULL if there was an error.
      * @script{create}
      */
     static Bundle* create(const char* path);

+ 4 - 4
gameplay/src/Font.cpp

@@ -55,7 +55,7 @@ Font* Font::create(const char* path, const char* id)
     Bundle* bundle = Bundle::create(path);
     if (bundle == NULL)
     {
-        GP_ERROR("Failed to load font bundle '%s'.", path);
+        GP_WARN("Failed to load font bundle '%s'.", path);
         return NULL;
     }
 
@@ -66,7 +66,7 @@ Font* Font::create(const char* path, const char* id)
         const char* id;
         if ((id = bundle->getObjectId(0)) == NULL)
         {
-            GP_ERROR("Failed to load font without explicit id; the first object in the font bundle has a null id.");
+            GP_WARN("Failed to load font without explicit id; the first object in the font bundle has a null id.");
             return NULL;
         }
 
@@ -105,7 +105,7 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
         __fontEffect = Effect::createFromFile(FONT_VSH, FONT_FSH, defines);
         if (__fontEffect == NULL)
         {
-            GP_ERROR("Failed to create effect for font.");
+            GP_WARN("Failed to create effect for font.");
             SAFE_RELEASE(texture);
             return NULL;
         }
@@ -123,7 +123,7 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
 
     if (batch == NULL)
     {
-        GP_ERROR("Failed to create batch for font.");
+        GP_WARN("Failed to create batch for font.");
         return NULL;
     }
 

+ 2 - 2
gameplay/src/Font.h

@@ -114,7 +114,7 @@ public:
      * @param path The path to a bundle file containing a font resource.
      * @param id An optional ID of the font resource within the bundle (NULL for the first/only resource).
      * 
-     * @return The specified font.
+     * @return The specified Font or NULL if there was an error.
      * @script{create}
      */
     static Font* create(const char* path, const char* id = NULL);
@@ -351,7 +351,7 @@ private:
      * @param texture A texture map containing rendered glyphs.
      * @param format The format of the font (bitmap or distance fields)
      * 
-     * @return The new Font.
+     * @return The new Font or NULL if there was an error.
      */
     static Font* create(const char* family, Style style, unsigned int size, Glyph* glyphs, int glyphCount, Texture* texture, Font::Format format);
 

+ 3 - 1
gameplay/src/Form.cpp

@@ -136,6 +136,8 @@ Form* Form::create(const char* url)
 
     __forms.push_back(form);
 
+    SAFE_DELETE(properties);
+
     return form;
 }
 
@@ -601,7 +603,7 @@ Control* Form::handlePointerPressRelease(int* x, int* y, bool pressed)
             // originally pressed, fire a click event
             if (active->_absoluteClipBounds.contains(newX, newY))
             {
-				if (!active->_parent || !active->_parent->isScrolling())
+                if (!active->_parent || !active->_parent->isScrolling())
                 {
                     active->notifyListeners(Control::Listener::CLICK);
                 }

+ 6 - 16
gameplay/src/PhysicsVehicleWheel.cpp

@@ -7,29 +7,20 @@ namespace gameplay
 {
 
 PhysicsVehicleWheel::PhysicsVehicleWheel(Node* node, const PhysicsCollisionShape::Definition& shape, const PhysicsRigidBody::Parameters& parameters)
-    : PhysicsCollisionObject(node), _rigidBody(NULL), _host(NULL), _indexInHost(0)
+    : PhysicsCollisionObject(node), _host(NULL), _indexInHost(0)
 {
-    // Note that the constructor for PhysicsRigidBody calls addCollisionObject and so
-    // that is where the rigid body gets added to the dynamics world.
-    _rigidBody = new PhysicsRigidBody(node, shape, parameters);
-
     findAncestorAndBind();
 }
 
-PhysicsVehicleWheel::PhysicsVehicleWheel(Node* node, PhysicsRigidBody* rigidBody)
-    : PhysicsCollisionObject(node), _rigidBody(NULL), _host(NULL), _indexInHost(0)
+PhysicsVehicleWheel::PhysicsVehicleWheel(Node* node)
+    : PhysicsCollisionObject(node), _host(NULL), _indexInHost(0)
 {
-    _rigidBody = rigidBody;
-
     findAncestorAndBind();
 }
 
 PhysicsVehicleWheel* PhysicsVehicleWheel::create(Node* node, Properties* properties)
 {
-    // Note that the constructor for PhysicsRigidBody calls addCollisionObject and so
-    // that is where the rigid body gets added to the dynamics world.
-    PhysicsRigidBody* rigidBody = PhysicsRigidBody::create(node, properties, "VEHICLE_WHEEL");
-    PhysicsVehicleWheel* wheel = new PhysicsVehicleWheel(node, rigidBody);
+    PhysicsVehicleWheel* wheel = new PhysicsVehicleWheel(node);
 
     // Load the defined wheel parameters.
     properties->rewind();
@@ -100,14 +91,13 @@ PhysicsVehicleWheel* PhysicsVehicleWheel::create(Node* node, Properties* propert
 
 PhysicsVehicleWheel::~PhysicsVehicleWheel()
 {
-    SAFE_DELETE(_rigidBody);
 }
 
 btCollisionObject* PhysicsVehicleWheel::getCollisionObject() const
 {
-    GP_ASSERT(_rigidBody);
+    GP_ASSERT(_host);
 
-    return _rigidBody->getCollisionObject();
+    return _host->getCollisionObject();
 }
 
 PhysicsCollisionObject::Type PhysicsVehicleWheel::getType() const

+ 3 - 6
gameplay/src/PhysicsVehicleWheel.h

@@ -285,16 +285,14 @@ private:
     PhysicsVehicleWheel(Node* node, const PhysicsCollisionShape::Definition& shape, const PhysicsRigidBody::Parameters& parameters);
 
     /**
-     * Creates a vehicle wheel based on the given rigid body and some 'safe' defaults.
+     * Creates a vehicle wheel based on some 'safe' defaults.
      * Also, traverse up the scene graph until we find the first common ancestor with another node
      * of collision type VEHICLE and add ourself as a wheel onto that vehicle. This assumes that the
      * VEHICLE comes before the VEHICLE_WHEEL in the ".scene" (properties) file.
      * 
-     * @param node The node to create a rigid body for; note that the node must have
-     *      a model attached to it prior to creating a rigid body for it.
-     * @param rigidBody The rigid body.
+     * @param node The node to create a vehicle wheel for.
      */
-    PhysicsVehicleWheel(Node* node, PhysicsRigidBody* rigidBody);
+    PhysicsVehicleWheel(Node* node);
 
     /**
      * Private copy constructor to prevent copying.
@@ -380,7 +378,6 @@ private:
      */
     void getWheelPos(Vector3* result) const;
 
-    PhysicsRigidBody* _rigidBody;
     PhysicsVehicle* _host;
     unsigned int _indexInHost;
     Vector3 _initialOffset;

+ 2 - 1
gameplay/src/Properties.cpp

@@ -84,7 +84,7 @@ Properties* Properties::create(const char* url)
     std::auto_ptr<Stream> stream(FileSystem::open(fileString.c_str()));
     if (stream.get() == NULL)
     {
-        GP_ERROR("Failed to open file '%s'.", fileString.c_str());
+        GP_WARN("Failed to open file '%s'.", fileString.c_str());
         return NULL;
     }
 
@@ -97,6 +97,7 @@ Properties* Properties::create(const char* url)
     if (!p)
     {
         GP_WARN("Failed to load properties from url '%s'.", url);
+        SAFE_DELETE(properties);
         return NULL;
     }
 

+ 5 - 5
gameplay/src/SceneLoader.cpp

@@ -65,7 +65,7 @@ Scene* SceneLoader::loadInternal(const char* url)
         _scene = loadMainSceneData(sceneProperties);
         if (!_scene)
         {
-            GP_ERROR("Failed to load main scene from bundle.");
+            GP_WARN("Failed to load main scene from bundle.");
             SAFE_DELETE(properties);
             return NULL;
         }
@@ -919,7 +919,7 @@ Scene* SceneLoader::loadMainSceneData(const Properties* sceneProperties)
     Bundle* bundle = Bundle::create(_gpbPath.c_str());
     if (!bundle)
     {
-        GP_ERROR("Failed to load scene GPB file '%s'.", _gpbPath.c_str());
+        GP_WARN("Failed to load scene GPB file '%s'.", _gpbPath.c_str());
         return NULL;
     }
 
@@ -927,7 +927,7 @@ Scene* SceneLoader::loadMainSceneData(const Properties* sceneProperties)
     Scene* scene = bundle->loadScene(NULL);
     if (!scene)
     {
-        GP_ERROR("Failed to load scene from '%s'.", _gpbPath.c_str());
+        GP_WARN("Failed to load scene from '%s'.", _gpbPath.c_str());
         SAFE_RELEASE(bundle);
         return NULL;
     }
@@ -1068,7 +1068,7 @@ void SceneLoader::loadReferencedFiles()
                 properties = Properties::create(fileString.c_str());
                 if (properties == NULL)
                 {
-                    GP_ERROR("Failed to load referenced properties file '%s'.", fileString.c_str());
+                    GP_WARN("Failed to load referenced properties file '%s'.", fileString.c_str());
                     continue;
                 }
 
@@ -1079,7 +1079,7 @@ void SceneLoader::loadReferencedFiles()
             Properties* p = getPropertiesFromNamespacePath(properties, namespacePath);
             if (!p)
             {
-                GP_ERROR("Failed to load referenced properties from url '%s'.", iter->first.c_str());
+                GP_WARN("Failed to load referenced properties from url '%s'.", iter->first.c_str());
                 continue;
             }
             iter->second = p;

+ 1 - 0
samples/browser/src/InputSample.cpp

@@ -71,6 +71,7 @@ void InputSample::initialize()
     _formNodeParent->setTranslation(_formNodeRestPosition);
     _formNode->setTranslation(-0.2f, -0.2f, 0);
     _formNode->setForm(form);
+    form->release();
 }
 
 void InputSample::finalize()

+ 1 - 0
samples/browser/src/LightSample.cpp

@@ -47,6 +47,7 @@ void LightSample::initialize()
 
 	// Load the scene
 	_scene = Scene::load("res/common/lightBrickWall.gpb");
+    _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
 
 	// Get the wall model node
 	_modelNode = _scene->findNode("wall"); 

+ 1 - 0
samples/browser/src/PostProcessSample.cpp

@@ -83,6 +83,7 @@ void PostProcessSample::initialize()
 
     // Load game scene from file
     _scene = Scene::load("res/common/duck.gpb");
+    _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
 
     // Initialize box model
     _modelNode = _scene->findNode("duck");

+ 1 - 1
samples/character/android/build.xml

@@ -68,7 +68,7 @@
         <copy file="../res/design/book.png" tofile="assets/res/png/book.png"/>
         <copy file="../res/design/bookshelf.png" tofile="assets/res/png/bookshelf.png"/>
         <copy file="../res/common/boy.animation" tofile="assets/res/common/boy.animation"/>
-        <copy file="../res/design/character.png" tofile="assets/res/png/character.png"/>
+        <copy file="../res/design/boy.png" tofile="assets/res/png/boy.png"/>
         <copy file="../res/design/decals.png" tofile="assets/res/png/decals.png"/>
         <copy file="../res/design/door.png" tofile="assets/res/png/door.png"/>
         <copy file="../res/design/doorframe.png" tofile="assets/res/png/doorframe.png"/>

+ 1 - 1
samples/character/bar-descriptor.xml

@@ -51,7 +51,7 @@
     <asset path="res/design/basketballnet.png">res/png/basketballnet.png</asset>
     <asset path="res/design/book.png">res/png/book.png</asset>
     <asset path="res/design/bookshelf.png">res/png/bookshelf.png</asset>
-    <asset path="res/design/character.png">res/png/character.png</asset>
+    <asset path="res/design/boy.png">res/png/boy.png</asset>
     <asset path="res/design/decals.png">res/png/decals.png</asset>
     <asset path="res/design/door.png">res/png/door.png</asset>
     <asset path="res/design/doorframe.png">res/png/doorframe.png</asset>

+ 1 - 1
samples/character/game.atc.config

@@ -5,7 +5,7 @@ basketball = res/atc/basketball.dds
 basketballnet = res/atc/basketballnet.dds
 book = res/atc/book.dds
 bookshelf = res/atc/bookshelf.dds
-character = res/atc/character.dds
+character = res/atc/boy.dds
 decals = res/atc/decals.dds
 door = res/atc/door.dds
 doorframe = res/atc/doorframe.dds

+ 1 - 1
samples/character/game.dxt.config

@@ -14,7 +14,7 @@ aliases
     basketballnet = res/dxt/basketballnet.dds
     book = res/dxt/book.dds
     bookshelf = res/dxt/bookshelf.dds
-    character = res/dxt/character.dds
+    character = res/dxt/boy.dds
     decals = res/dxt/decals.dds
     door = res/dxt/door.dds
     doorframe = res/dxt/doorframe.dds

+ 1 - 1
samples/character/game.png.config

@@ -5,7 +5,7 @@ aliases
     basketballnet = res/png/basketballnet.png
     book = res/png/book.png
     bookshelf = res/png/bookshelf.png
-    character = res/png/character.png
+    character = res/png/boy.png
     decals = res/png/decals.png
     door = res/png/door.png
     doorframe = res/png/doorframe.png

+ 1 - 1
samples/character/game.pvrtc.config

@@ -5,7 +5,7 @@ aliases
     basketballnet = res/pvrtc/basketballnet.pvr
     book = res/pvrtc/book.pvr
     bookshelf = res/pvrtc/bookshelf.pvr
-    character = res/pvrtc/character.pvr
+    character = res/pvrtc/boy.pvr
     decals = res/pvrtc/decals.pvr
     door = res/pvrtc/door.pvr
     doorframe = res/pvrtc/doorframe.pvr

+ 0 - 0
samples/character/res/atc/character.dds → samples/character/res/atc/boy.dds


+ 0 - 0
samples/character/res/dxt/character.dds → samples/character/res/dxt/boy.dds


+ 0 - 0
samples/character/res/pvrtc/character.pvr → samples/character/res/pvrtc/boy.pvr


+ 7 - 1
samples/lua/bar-descriptor.xml

@@ -45,7 +45,13 @@
     <asset path="game.config">game.config</asset>
    	<asset path="../../gameplay/res/logo_powered_white.png">res/logo_powered_white.png</asset>
     <asset path="../../gameplay/res/shaders">res/shaders</asset>
-    <asset path="res">res</asset>
+    <asset path="res/ai.lua">res/ai.lua</asset>
+    <asset path="res/game.lua">res/game.lua</asset>
+    <asset path="res/arial.gpb">res/arial.gpb</asset>
+    <asset path="res/lua.gpb">res/lua.gpb</asset>
+    <asset path="res/lua.material">res/lua.material</asset>
+    <asset path="res/lua.scene">res/lua.scene</asset>
+    <asset path="res/lua-logo.png">res/lua-logo.png</asset>
 
     <configuration name="Device-Debug">
        <platformArchitecture>armle-v7</platformArchitecture>

+ 5 - 6
samples/mesh/android/build.xml

@@ -62,12 +62,11 @@
        -->
     <target name="-post-compile">
         <copy file="../game.config" tofile="assets/game.config"/>
-        <copy file="../res/arial40.gpb" tofile="assets/res/arial40.gpb"/>
-        <copy file="../res/sample.scene" tofile="assets/res/sample.scene"/>
-        <copy file="../res/duck.gpb" tofile="assets/res/duck.gpb"/>
-        <copy file="../res/duck.material" tofile="assets/res/duck.material"/>
-        <copy file="../res/duck-diffuse.png" tofile="assets/res/duck-diffuse.png"/>
-        <copy file="../res/grid.material" tofile="assets/res/grid.material"/>
+        <copy file="../res/arial.gpb" tofile="assets/res/arial.gpb"/>
+        <copy file="../res/mesh.scene" tofile="assets/res/mesh.scene"/>
+        <copy file="../res/mesh.gpb" tofile="assets/res/mesh.gpb"/>
+        <copy file="../res/mesh.material" tofile="assets/res/mesh.material"/>
+        <copy file="../res/duck.png" tofile="assets/res/duck.png"/>
         <copy file="../../../gameplay/res/logo_powered_white.png" tofile="assets/res/logo_powered_white.png"/>
         <copy todir="assets/res/shaders">
             <fileset dir="../../../gameplay/res/shaders"/>

+ 4 - 5
samples/mesh/bar-descriptor.xml

@@ -43,11 +43,10 @@
     
     <asset path="icon.png">icon.png</asset>
     <asset path="res/arial.gpb">res/arial.gpb</asset>
-    <asset path="res/duck-diffuse.png">res/duck-diffuse.png</asset>
-    <asset path="res/sample.scene">res/sample.scene</asset>
-    <asset path="res/duck.gpb">res/duck.gpb</asset>
-    <asset path="res/duck.material">res/duck.material</asset>
-    <asset path="res/grid.material">res/grid.material</asset>
+    <asset path="res/duck.png">res/duck.png</asset>
+    <asset path="res/mesh.scene">res/mesh.scene</asset>
+    <asset path="res/mesh.gpb">res/mesh.gpb</asset>
+    <asset path="res/mesh.material">res/mesh.material</asset>
     <asset path="../../gameplay/res/logo_powered_white.png">res/logo_powered_white.png</asset>
     <asset path="../../gameplay/res/shaders">res/shaders</asset>
     <asset path="game.config">game.config</asset>