Преглед изворни кода

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

setaylor пре 13 година
родитељ
комит
07c280cbca

BIN
gameplay-api/gameplay.png


+ 20 - 0
gameplay-api/header.html

@@ -0,0 +1,20 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
+<meta http-equiv="X-UA-Compatible" content="IE=9"/>
+<title>gameplay: Main Page</title>
+
+<link href="tabs.css" rel="stylesheet" type="text/css"/>
+<link href="doxygen.css" rel="stylesheet" type="text/css" />
+
+<link href="search/search.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="jquery.js"></script>
+<script type="text/javascript" src="search/search.js"></script>
+<script type="text/javascript">
+  $(document).ready(function() { searchBox.OnSelectItem(0); });
+</script>
+
+</head>
+<body>
+<div id="top"><!-- do not remove this div! -->

+ 8 - 7
gameplay.doxyfile

@@ -45,7 +45,7 @@ PROJECT_BRIEF          =
 # exceed 55 pixels and the maximum width should not exceed 200 pixels. 
 # Doxygen will copy the logo to the output directory.
 
-PROJECT_LOGO           = ./gameplay-api/gameplay.png
+PROJECT_LOGO           = 
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
 # base path where the generated documentation will be put. 
@@ -562,7 +562,7 @@ MAX_INITIALIZER_LINES  = 30
 # at the bottom of the documentation of classes and structs. If set to YES the 
 # list will mention the files that were used to generate the documentation.
 
-SHOW_USED_FILES        = YES
+SHOW_USED_FILES        = NO
 
 # If the sources in your project are distributed over multiple directories 
 # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
@@ -574,7 +574,7 @@ SHOW_DIRECTORIES       = NO
 # This will remove the Files entry from the Quick Index and from the 
 # Folder Tree View (if specified). The default is YES.
 
-SHOW_FILES             = YES
+SHOW_FILES             = NO
 
 # Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
 # Namespaces page.  This will remove the Namespaces entry from the Quick Index 
@@ -689,7 +689,8 @@ INPUT_ENCODING         = UTF-8
 # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py 
 # *.f90 *.f *.for *.vhd *.vhdl
 
-FILE_PATTERNS          = *.h
+FILE_PATTERNS          = *.h \
+                         *.dox
 
 # The RECURSIVE tag can be used to turn specify whether or not subdirectories 
 # should be searched for input files as well. Possible values are YES and NO. 
@@ -839,7 +840,7 @@ USE_HTAGS              = NO
 # will generate a verbatim copy of the header file for each class for 
 # which an include is specified. Set to NO to disable this.
 
-VERBATIM_HEADERS       = YES
+VERBATIM_HEADERS       = NO
 
 #---------------------------------------------------------------------------
 # configuration options related to the alphabetical class index
@@ -896,7 +897,7 @@ HTML_FILE_EXTENSION    = .html
 # have to redo this when upgrading to a newer version of doxygen or when 
 # changing the value of configuration settings such as GENERATE_TREEVIEW!
 
-HTML_HEADER            = 
+HTML_HEADER            = gameplay-api/header.html
 
 # The HTML_FOOTER tag can be used to specify a personal HTML footer for 
 # each generated HTML page. If it is left blank doxygen will generate a 
@@ -1136,7 +1137,7 @@ DISABLE_INDEX          = NO
 # Since the tree basically has the same information as the tab index you 
 # could consider to set DISABLE_INDEX to NO when enabling this option.
 
-GENERATE_TREEVIEW      = YES
+GENERATE_TREEVIEW      = NO
 
 # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values 
 # (range [0,1..20]) that doxygen will group on one line in the generated HTML 

+ 6 - 2
gameplay/.cproject

@@ -29,6 +29,10 @@
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/oggvorbis/include&quot;"/>
 									<listOptionValue builtIn="false" value="${QNX_TARGET}/../target-override/usr/include"/>
 								</option>
+								<option id="com.qnx.qcc.option.compiler.qccoptions.1968057343" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList"/>
+								<option id="com.qnx.qcc.option.compiler.ccoptions.1078137668" superClass="com.qnx.qcc.option.compiler.ccoptions" valueType="stringList">
+									<listOptionValue builtIn="false" value="-mfpu=neon"/>
+								</option>
 								<inputType id="com.qnx.qcc.inputType.compiler.997142816" superClass="com.qnx.qcc.inputType.compiler"/>
 							</tool>
 							<tool id="com.qnx.qcc.tool.assembler.1988140188" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
@@ -197,7 +201,7 @@
 							</tool>
 							<tool id="com.qnx.qcc.tool.linker.1976564730" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
 								<option id="com.qnx.qcc.option.linker.debug.483005272" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
-								<option id="com.qnx.qcc.option.linker.coverage.1325683096" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
+								<option id="com.qnx.qcc.option.linker.coverage.1325683096" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.linker.langcpp.1336725462" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.linker.security.261244208" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.linker.libraryPaths.1333876349" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
@@ -357,7 +361,7 @@
 							</tool>
 							<tool id="com.qnx.qcc.tool.linker.499344619" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
 								<option id="com.qnx.qcc.option.linker.debug.1036858603" name="Debug (-g)" superClass="com.qnx.qcc.option.linker.debug" value="true" valueType="boolean"/>
-								<option id="com.qnx.qcc.option.linker.coverage.120064975" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs -p)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
+								<option id="com.qnx.qcc.option.linker.coverage.120064975" name="Build for Code Coverage (-ftest-coverage -fprofile-arcs)" superClass="com.qnx.qcc.option.linker.coverage" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.linker.langcpp.732448976" name="C++ (-lang-c++)" superClass="com.qnx.qcc.option.linker.langcpp" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.linker.security.2060919956" name="Enhanced Security (-Wl,-z,relro -Wl,-z,now)" superClass="com.qnx.qcc.option.linker.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.linker.libraryPaths.2023922042" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">

+ 14 - 2
gameplay/src/Base.h

@@ -180,8 +180,20 @@ extern void printError(const char* format, ...);
 #define WINDOW_VSYNC        1
 
 // Graphics (OpenGL)
-#if defined (__QNX__) || defined(__ANDROID__)
-    #include <EGL/egl.h>
+#ifdef __QNX__
+#include <EGL/egl.h>
+    #include <GLES2/gl2.h>
+    #include <GLES2/gl2ext.h>
+    extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray;
+    extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays;
+    extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays;
+    extern PFNGLISVERTEXARRAYOESPROC glIsVertexArray;
+    #define glClearDepth glClearDepthf
+    #define OPENGL_ES
+    #define USE_PVRTC
+	#define USE_NEON
+#elif __ANDROID__
+	#include <EGL/egl.h>
     #include <GLES2/gl2.h>
     #include <GLES2/gl2ext.h>
     extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray;

+ 157 - 3
gameplay/src/Matrix.cpp

@@ -675,6 +675,27 @@ void Matrix::multiply(const Matrix& m, float scalar, Matrix* dst)
 {
     GP_ASSERT(dst);
 
+#ifdef USE_NEON
+
+    asm volatile(
+    	"vld1.32 	{d0[0]},	 	[%0]     	\n\t"
+    	"vld1.32	{q4-q5},  		[%1]!    	\n\t"
+		"vld1.32	{q6-q7},  		[%1]!		\n\t"
+
+    	"vmul.f32 	q8, q4, d0[0]    			\n\t"
+    	"vmul.f32 	q9, q5, d0[0]    			\n\t"
+		"vmul.f32 	q10, q6, d0[0]    			\n\t"
+		"vmul.f32 	q11, q7, d0[0]   		 	\n\t"
+
+    	"vst1.32 	{q8-q9},   		[%2]! 		\n\t"
+		"vst1.32 	{q10-q11}, 		[%2]!		\n\t"
+		:
+		: "r"(&scalar), "r"(m.m), "r"(dst->m)
+		: "q0", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", "memory"
+	);
+
+#else
+
     dst->m[0]  = m.m[0]  * scalar;
     dst->m[1]  = m.m[1]  * scalar;
     dst->m[2]  = m.m[2]  * scalar;
@@ -691,6 +712,8 @@ void Matrix::multiply(const Matrix& m, float scalar, Matrix* dst)
     dst->m[13] = m.m[13] * scalar;
     dst->m[14] = m.m[14] * scalar;
     dst->m[15] = m.m[15] * scalar;
+
+#endif
 }
 
 void Matrix::multiply(const Matrix& m)
@@ -700,7 +723,46 @@ void Matrix::multiply(const Matrix& m)
 
 void Matrix::multiply(const Matrix& m1, const Matrix& m2, Matrix* dst)
 {
-    GP_ASSERT(dst);
+	GP_ASSERT(dst);
+
+#ifdef USE_NEON // if set, neon unit is present.
+
+    asm volatile
+    (
+        "vld1.32	 {d16 - d19}, [%1]!	\n\t"         // load first eight elements of matrix 0
+		"vld1.32     {d20 - d23}, [%1]!   \n\t"         // load second eight elements of matrix 0
+		"vld1.32     {d0 - d3}, [%2]!     \n\t"         // load first eight elements of matrix 1
+		"vld1.32     {d4 - d7}, [%2]!     \n\t"         // load second eight elements of matrix 1
+
+		"vmul.f32    q12, q8, d0[0]     \n\t"         // rslt col0  = (mat0 col0) * (mat1 col0 elt0)
+		"vmul.f32    q13, q8, d2[0]     \n\t"         // rslt col1  = (mat0 col0) * (mat1 col1 elt0)
+		"vmul.f32    q14, q8, d4[0]     \n\t"         // rslt col2  = (mat0 col0) * (mat1 col2 elt0)
+		"vmul.f32    q15, q8, d6[0]     \n\t"         // rslt col3  = (mat0 col0) * (mat1 col3 elt0)
+
+		"vmla.f32    q12, q9, d0[1]     \n\t"         // rslt col0 += (mat0 col1) * (mat1 col0 elt1)
+		"vmla.f32    q13, q9, d2[1]     \n\t"         // rslt col1 += (mat0 col1) * (mat1 col1 elt1)
+		"vmla.f32    q14, q9, d4[1]     \n\t"         // rslt col2 += (mat0 col1) * (mat1 col2 elt1)
+		"vmla.f32    q15, q9, d6[1]     \n\t"         // rslt col3 += (mat0 col1) * (mat1 col3 elt1)
+
+		"vmla.f32    q12, q10, d1[0]    \n\t"         // rslt col0 += (mat0 col2) * (mat1 col0 elt2)
+		"vmla.f32    q13, q10, d3[0]    \n\t"         // rslt col1 += (mat0 col2) * (mat1 col1 elt2)
+		"vmla.f32    q14, q10, d5[0]    \n\t"         // rslt col2 += (mat0 col2) * (mat1 col2 elt2)
+		"vmla.f32    q15, q10, d7[0]    \n\t"         // rslt col3 += (mat0 col2) * (mat1 col2 elt2)
+
+		"vmla.f32    q12, q11, d1[1]    \n\t"         // rslt col0 += (mat0 col3) * (mat1 col0 elt3)
+		"vmla.f32    q13, q11, d3[1]    \n\t"         // rslt col1 += (mat0 col3) * (mat1 col1 elt3)
+		"vmla.f32    q14, q11, d5[1]    \n\t"         // rslt col2 += (mat0 col3) * (mat1 col2 elt3)
+		"vmla.f32    q15, q11, d7[1]    \n\t"         // rslt col3 += (mat0 col3) * (mat1 col3 elt3)
+
+		"vst1.32    {d24 - d27}, [%0]!    \n\t"         // store first eight elements of result
+		"vst1.32    {d28 - d31}, [%0]!    \n\t"         // store second eight elements of result
+        
+        : // output
+        : "r"(dst->m), "r"(m1.m), "r"(m2.m) // input - note *value* of pointer doesn't change.
+        : "memory", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15"
+	);
+
+#else
 
     // Support the case where m1 or m2 is the same array as dst.
     float product[16];
@@ -726,6 +788,8 @@ void Matrix::multiply(const Matrix& m1, const Matrix& m2, Matrix* dst)
     product[15] = m1.m[3] * m2.m[12] + m1.m[7] * m2.m[13] + m1.m[11] * m2.m[14] + m1.m[15] * m2.m[15];
 
     memcpy(dst->m, product, MATRIX_SIZE);
+
+#endif
 }
 
 void Matrix::negate()
@@ -737,6 +801,26 @@ void Matrix::negate(Matrix* dst) const
 {
     GP_ASSERT(dst);
 
+#ifdef USE_NEON
+
+    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->m), "r"(m)
+    	: "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "memory"
+    );
+
+#else
+
     dst->m[0]  = -m[0];
     dst->m[1]  = -m[1];
     dst->m[2]  = -m[2];
@@ -753,6 +837,8 @@ void Matrix::negate(Matrix* dst) const
     dst->m[13] = -m[13];
     dst->m[14] = -m[14];
     dst->m[15] = -m[15];
+
+#endif
 }
 
 void Matrix::rotate(const Quaternion& q)
@@ -940,11 +1026,38 @@ void Matrix::transformVector(const Vector3& vector, Vector3* dst) const
 void Matrix::transformVector(float x, float y, float z, float w, Vector3* dst) const
 {
     GP_ASSERT(dst);
-    
+
+#ifdef USE_NEON
+
+    asm volatile(
+    	"vld1.32	{d0[0]},		[%0]	\n\t"	// load x
+		"vld1.32	{d0[1]},    	[%1]	\n\t"	// load y
+		"vld1.32	{d1[0]},		[%2]	\n\t"	// load z
+		"vld1.32	{d1[1]},		[%3]	\n\t"	// load w
+		"vld1.32	{d18 - d21},	[%4]!	\n\t"	// load first 8 elements of matrix m0-m7
+		"vld1.32	{d22 - d25},	[%4]!	\n\t"	// load second 8 elements of matrix m8-m15
+
+    	"vmul.f32 q13,  q9, d0[0]			\n\t"	// Q5 =  (m0-m3)*x
+    	"vmla.f32 q13, q10, d0[1]      		\n\t"	// Q5 +=  (m4-m7)*y
+    	"vmla.f32 q13, q11, d1[0]      		\n\t"	// Q5 +=  (m8-m11)*z
+		"vmla.f32 q13, q12, d1[1]      		\n\t"	// Q5 +=  (m12-m15)*w
+
+    	"vst1.32 {d26[0]}, [%5]!        	\n\t"	// store dst->x
+		"vst1.32 {d26[1]}, [%5]!        	\n\t"	// store dst->y
+		"vst1.32 {d27[0]}, [%5]!        	\n\t"	// store dst->z
+		:
+    	: "r"(&x), "r"(&y), "r"(&z), "r"(&w), "r"(m), "r"(dst)
+        : "q0", "q9", "q10","q11", "q12", "q13", "memory"
+    );
+
+#else
+
     dst->set(
         x * m[0] + y * m[4] + z * m[8] + w * m[12],
         x * m[1] + y * m[5] + z * m[9] + w * m[13],
         x * m[2] + y * m[6] + z * m[10] + w * m[14]);
+
+#endif
 }
 
 void Matrix::transformVector(Vector4* vector) const
@@ -957,11 +1070,33 @@ void Matrix::transformVector(const Vector4& vector, Vector4* dst) const
 {
     GP_ASSERT(dst);
 
+#ifdef USE_NEON
+
+    asm volatile
+    (
+    		"vld1.32	{d0, d1}, [%1]		\n\t"   //Q0 = v (x, y, z, w)
+    		"vld1.32    {d18 - d21}, [%0]!  \n\t"   //Q1 = M (m0-m7)
+    		"vld1.32    {d22 - d25}, [%0]!  \n\t"   //Q2 = M (m8-m15)
+
+    		"vmul.f32   q13, q9, d0[0]      \n\t"   //Q5 =  Q0*Q0[0]
+    		"vmla.f32   q13, q10, d0[1]     \n\t"   //Q5 += Q1*Q0[1]
+    		"vmla.f32   q13, q11, d1[0]     \n\t"   //Q5 += Q2*Q0[2]
+    		"vmla.f32   q13, q12, d1[1]     \n\t"   //Q5 += Q3*Q0[3]
+    		"vst1.32    {d26, d27}, [%2]    \n\t"   //Q4 = m+12
+    		:
+    		: "r"(m), "r"(&vector), "r"(dst)
+    		: "q0", "q9", "q10","q11", "q12", "q13", "memory"
+    );
+
+#else
+
     dst->set(
         vector.x * m[0] + vector.y * m[4] + vector.z * m[8] + vector.w * m[12],
         vector.x * m[1] + vector.y * m[5] + vector.z * m[9] + vector.w * m[13],
-        vector.x * m[2] + vector.y * m[6] + vector.z * m[10] + vector.w * m[14],
+        vector.x * m[2] + vector.y * m[6] + vector.z * m[10] + vector.w * m[14],
         vector.x * m[3] + vector.y * m[7] + vector.z * m[11] + vector.w * m[15]);
+
+#endif
 }
 
 void Matrix::translate(float x, float y, float z)
@@ -994,7 +1129,24 @@ void Matrix::transpose()
 void Matrix::transpose(Matrix* dst) const
 {
     GP_ASSERT(dst);
+
+#ifdef USE_NEON
     
+    asm volatile(
+    	"vld4.32 {d0[0], d2[0], d4[0], d6[0]}, [%0]! \n\t"
+		"vld4.32 {d0[1], d2[1], d4[1], d6[1]}, [%0]! \n\t"
+		"vld4.32 {d1[0], d3[0], d5[0], d7[0]}, [%0]! \n\t"
+		"vld4.32 {d1[1], d3[1], d5[1], d7[1]}, [%0]! \n\t"
+
+		"vst1.32 {q0-q1}, [%1]! \n\t"
+		"vst1.32 {q2-q3}, [%1]! \n\t"
+    	:
+    	: "r"(this->m), "r"(dst->m)
+    	: "q0", "q1", "q2", "q3", "memory"
+    );
+
+#else
+
     float t[16] = {
         m[0], m[4], m[8], m[12],
         m[1], m[5], m[9], m[13],
@@ -1002,6 +1154,8 @@ void Matrix::transpose(Matrix* dst) const
         m[3], m[7], m[11], m[15]
     };
     memcpy(dst->m, t, MATRIX_SIZE);
+
+#endif
 }
 
 }

+ 3 - 0
gameplay/src/Node.cpp

@@ -1013,6 +1013,9 @@ PhysicsCollisionObject* Node::setCollisionObject(PhysicsCollisionObject::Type ty
             _collisionObject = new PhysicsCharacter(this, shape, rigidBodyParameters ? rigidBodyParameters->mass : 1.0f);
         }
         break;
+
+    case PhysicsCollisionObject::NONE:
+        break;  // Already deleted, Just don't add a new collision object back.
     }
 
     return _collisionObject;

+ 2 - 1
gameplay/src/Node.h

@@ -517,7 +517,8 @@ public:
      *        must point to a valid rigid body parameters object containing information
      *        about the rigid body; otherwise, this parmater may be NULL.
      */
-    PhysicsCollisionObject* setCollisionObject(PhysicsCollisionObject::Type type, const PhysicsCollisionShape::Definition& shape, PhysicsRigidBody::Parameters* rigidBodyParameters = NULL);
+    PhysicsCollisionObject* setCollisionObject(PhysicsCollisionObject::Type type, const PhysicsCollisionShape::Definition& shape = PhysicsCollisionShape::box(), 
+                                               PhysicsRigidBody::Parameters* rigidBodyParameters = NULL);
 
     /**
      * Sets the physics collision object for this node using the data from the Properties object defined at the specified URL, 

+ 27 - 4
gameplay/src/PhysicsCollisionObject.cpp

@@ -14,9 +14,7 @@ struct CollidesWithCallback : public btCollisionWorld::ContactResultCallback
     /**
      * Called with each contact. Needed to implement collidesWith(PhysicsCollisionObject*).
      */
-    btScalar addSingleResult(btManifoldPoint& cp, 
-        const btCollisionObject* a, int partIdA, int indexA, 
-        const btCollisionObject* b, int partIdB, int indexB)
+    btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObject* a, int partIdA, int indexA, const btCollisionObject* b, int partIdB, int indexB)
     {
         result = true;
         return 0.0f;
@@ -29,7 +27,7 @@ struct CollidesWithCallback : public btCollisionWorld::ContactResultCallback
 };
 
 PhysicsCollisionObject::PhysicsCollisionObject(Node* node)
-    : _node(node), _motionState(NULL), _collisionShape(NULL)
+    : _node(node), _motionState(NULL), _collisionShape(NULL), _enabled(true)
 {
 }
 
@@ -81,6 +79,31 @@ bool PhysicsCollisionObject::isDynamic() const
     return !getCollisionObject()->isStaticOrKinematicObject();
 }
 
+bool PhysicsCollisionObject::isEnabled() const
+{
+    return _enabled;
+}
+
+void PhysicsCollisionObject::setEnabled(bool enable)
+{
+    if (enable)
+    {  
+        if (!_enabled)
+        {
+            Game::getInstance()->getPhysicsController()->addCollisionObject(this);
+            _enabled = true;
+        }
+    }
+    else
+    {
+        if (_enabled)
+        {
+            Game::getInstance()->getPhysicsController()->removeCollisionObject(this);
+            _enabled = false;
+        }
+    }
+}
+
 void PhysicsCollisionObject::addCollisionListener(CollisionListener* listener, PhysicsCollisionObject* object)
 {
     GP_ASSERT(Game::getInstance()->getPhysicsController());

+ 23 - 4
gameplay/src/PhysicsCollisionObject.h

@@ -155,7 +155,7 @@ public:
      * A kinematic collision object is an object that is not simulated by
      * the physics system and instead has its transform driven manually.
      *
-     * @return Whether the collision object is kinematic.
+     * @return true if the collision object is kinematic.
      */
     bool isKinematic() const;
 
@@ -165,10 +165,24 @@ public:
      * A dynamic collision object is simulated entirely by the physics system,
      * such as with dynamic rigid bodies. 
      *
-     * @return Whether the collision object is dynamic.
+     * @return true if the collision object is dynamic.
      */
     bool isDynamic() const;
 
+    /**
+     * Check if th collision object is enabled.
+     *
+     * @return true if the collision object is enabled.
+     */
+    bool isEnabled() const;
+
+    /**
+     * Sets the collision object be enabled or disabled.
+     *
+     * @param enable true enables the collision object, false diables it.
+     */
+    void setEnabled(bool enable);
+
     /**
      * Adds a collision listener for this collision object.
      * 
@@ -190,10 +204,11 @@ public:
      * 
      * @param object The collision object to test for collision with.
      * 
-     * @return True if this object collides with the specified one; false otherwise.
+     * @return true if this object collides with the specified one; false otherwise.
      */
     bool collidesWith(PhysicsCollisionObject* object) const;
 
+
 protected:
 
     /**
@@ -215,7 +230,6 @@ protected:
      */
     PhysicsMotionState* getMotionState() const;
 
-    // Common member variables
     /**
      * Pointer to Node contained by this collision object.
      */ 
@@ -231,6 +245,11 @@ protected:
      */
     PhysicsCollisionShape* _collisionShape;
 
+    /**
+     * If the collision object is enabled or not.
+     */
+    bool _enabled;
+
 };
 
 }