Merge pull request from boyu0/iss2771_physical

[ci skip]Iss2771 physical
This commit is contained in:
minggo 2013-11-27 19:10:25 -08:00
commit d9139682ed
44 changed files with 653 additions and 1253 deletions

View File

@ -1 +1 @@
0d9ce76f7e63d75718c38b1137b2580e19d0db76
f9416b73efef54140650372b509bfe22727cb00f

View File

@ -1 +1 @@
b343c033f369dd9a1cd41baf60012cd447af6970
2c04a1aefcf0da7137ddc5e3ca807fe82d975f4d

View File

@ -39,13 +39,13 @@ CCEventAcceleration.cpp \
CCEventCustom.cpp \
CCEventDispatcher.cpp \
CCEventKeyboard.cpp \
CCEventMouse.cpp \
CCEventListenerMouse.cpp \
CCEventListener.cpp \
CCEventListenerAcceleration.cpp \
CCEventListenerCustom.cpp \
CCEventListenerKeyboard.cpp \
CCEventListenerMouse.cpp \
CCEventListenerTouch.cpp \
CCEventMouse.cpp \
CCEventTouch.cpp \
CCFont.cpp \
CCFontAtlas.cpp \
@ -149,11 +149,6 @@ platform/CCThread.cpp \
../physics/CCPhysicsJoint.cpp \
../physics/CCPhysicsShape.cpp \
../physics/CCPhysicsWorld.cpp \
../physics/box2d/CCPhysicsBodyInfo_box2d.cpp \
../physics/box2d/CCPhysicsContactInfo_box2d.cpp \
../physics/box2d/CCPhysicsJointInfo_box2d.cpp \
../physics/box2d/CCPhysicsShapeInfo_box2d.cpp \
../physics/box2d/CCPhysicsWorldInfo_box2d.cpp \
../physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp \
../physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp \
../physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp \

View File

@ -33,7 +33,6 @@ THE SOFTWARE.
#ifdef EMSCRIPTEN
#include "CCGLBufferedNode.h"
#endif // EMSCRIPTEN
#include "CCPhysicsSetting.h"
#include "CCEventKeyboard.h"

View File

@ -38,7 +38,6 @@
#include "CCScriptSupport.h"
#include "CCProtocols.h"
#include "CCEventDispatcher.h"
#include "CCPhysicsSetting.h"
#include <vector>

View File

@ -74,7 +74,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;CC_USE_PHYSICS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -121,7 +121,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
</PreBuildEvent>
<ClCompile>
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;CC_USE_PHYSICS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
@ -192,11 +192,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClCompile Include="..\math\kazmath\src\vec2.c" />
<ClCompile Include="..\math\kazmath\src\vec3.c" />
<ClCompile Include="..\math\kazmath\src\vec4.c" />
<ClCompile Include="..\physics\box2d\CCPhysicsBodyInfo_box2d.cpp" />
<ClCompile Include="..\physics\box2d\CCPhysicsContactInfo_box2d.cpp" />
<ClCompile Include="..\physics\box2d\CCPhysicsJointInfo_box2d.cpp" />
<ClCompile Include="..\physics\box2d\CCPhysicsShapeInfo_box2d.cpp" />
<ClCompile Include="..\physics\box2d\CCPhysicsWorldInfo_box2d.cpp" />
<ClCompile Include="..\physics\CCPhysicsBody.cpp" />
<ClCompile Include="..\physics\CCPhysicsContact.cpp" />
<ClCompile Include="..\physics\CCPhysicsJoint.cpp" />
@ -361,16 +356,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClInclude Include="..\math\kazmath\include\kazmath\vec2.h" />
<ClInclude Include="..\math\kazmath\include\kazmath\vec3.h" />
<ClInclude Include="..\math\kazmath\include\kazmath\vec4.h" />
<ClInclude Include="..\physics\box2d\CCPhysicsBodyInfo_box2d.h" />
<ClInclude Include="..\physics\box2d\CCPhysicsContactInfo_box2d.h" />
<ClInclude Include="..\physics\box2d\CCPhysicsHelper_box2d.h" />
<ClInclude Include="..\physics\box2d\CCPhysicsJointInfo_box2d.h" />
<ClInclude Include="..\physics\box2d\CCPhysicsShapeInfo_box2d.h" />
<ClInclude Include="..\physics\box2d\CCPhysicsWorldInfo_box2d.h" />
<ClInclude Include="..\physics\CCPhysicsBody.h" />
<ClInclude Include="..\physics\CCPhysicsContact.h" />
<ClInclude Include="..\physics\CCPhysicsJoint.h" />
<ClInclude Include="..\physics\CCPhysicsSetting.h" />
<ClInclude Include="..\physics\CCPhysicsShape.h" />
<ClInclude Include="..\physics\CCPhysicsWorld.h" />
<ClInclude Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.h" />

View File

@ -91,9 +91,6 @@
<Filter Include="physics\chipmunk">
<UniqueIdentifier>{aeadfa95-9c89-4212-98ae-89ad57db596a}</UniqueIdentifier>
</Filter>
<Filter Include="physics\Box2D">
<UniqueIdentifier>{b9880458-36e5-4f28-a34b-d01d9512a395}</UniqueIdentifier>
</Filter>
<Filter Include="kazmath\include">
<UniqueIdentifier>{05e27e68-7574-4a8b-af68-553dd3bafdfa}</UniqueIdentifier>
</Filter>
@ -548,21 +545,6 @@
<ClCompile Include="CCEventMouse.cpp">
<Filter>event_dispatcher</Filter>
</ClCompile>
<ClCompile Include="..\physics\box2d\CCPhysicsBodyInfo_box2d.cpp">
<Filter>physics\Box2D</Filter>
</ClCompile>
<ClCompile Include="..\physics\box2d\CCPhysicsContactInfo_box2d.cpp">
<Filter>physics\Box2D</Filter>
</ClCompile>
<ClCompile Include="..\physics\box2d\CCPhysicsJointInfo_box2d.cpp">
<Filter>physics\Box2D</Filter>
</ClCompile>
<ClCompile Include="..\physics\box2d\CCPhysicsShapeInfo_box2d.cpp">
<Filter>physics\Box2D</Filter>
</ClCompile>
<ClCompile Include="..\physics\box2d\CCPhysicsWorldInfo_box2d.cpp">
<Filter>physics\Box2D</Filter>
</ClCompile>
<ClCompile Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.cpp">
<Filter>physics\chipmunk</Filter>
</ClCompile>
@ -589,9 +571,6 @@
<ClInclude Include="..\physics\CCPhysicsJoint.h">
<Filter>physics</Filter>
</ClInclude>
<ClInclude Include="..\physics\CCPhysicsSetting.h">
<Filter>physics</Filter>
</ClInclude>
<ClInclude Include="..\physics\CCPhysicsShape.h">
<Filter>physics</Filter>
</ClInclude>
@ -1128,24 +1107,6 @@
<ClInclude Include="CCEventMouse.h">
<Filter>event_dispatcher</Filter>
</ClInclude>
<ClInclude Include="..\physics\box2d\CCPhysicsBodyInfo_box2d.h">
<Filter>physics\Box2D</Filter>
</ClInclude>
<ClInclude Include="..\physics\box2d\CCPhysicsContactInfo_box2d.h">
<Filter>physics\Box2D</Filter>
</ClInclude>
<ClInclude Include="..\physics\box2d\CCPhysicsHelper_box2d.h">
<Filter>physics\Box2D</Filter>
</ClInclude>
<ClInclude Include="..\physics\box2d\CCPhysicsJointInfo_box2d.h">
<Filter>physics\Box2D</Filter>
</ClInclude>
<ClInclude Include="..\physics\box2d\CCPhysicsShapeInfo_box2d.h">
<Filter>physics\Box2D</Filter>
</ClInclude>
<ClInclude Include="..\physics\box2d\CCPhysicsWorldInfo_box2d.h">
<Filter>physics\Box2D</Filter>
</ClInclude>
<ClInclude Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.h">
<Filter>physics\chipmunk</Filter>
</ClInclude>

View File

@ -27,31 +27,20 @@
#include <climits>
#include <algorithm>
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#include "chipmunk.h"
#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D)
#include "Box2D.h"
#endif
#include "CCPhysicsShape.h"
#include "CCPhysicsJoint.h"
#include "CCPhysicsWorld.h"
#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h"
#include "box2d/CCPhysicsBodyInfo_box2d.h"
#include "chipmunk/CCPhysicsJointInfo_chipmunk.h"
#include "box2d/CCPhysicsJointInfo_box2d.h"
#include "chipmunk/CCPhysicsWorldInfo_chipmunk.h"
#include "box2d/CCPhysicsWorldInfo_box2d.h"
#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h"
#include "box2d/CCPhysicsShapeInfo_box2d.h"
#include "chipmunk/CCPhysicsHelper_chipmunk.h"
#include "box2d/CCPhysicsHelper_box2d.h"
NS_CC_BEGIN
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
extern const float PHYSICS_INFINITY;
namespace
{
@ -526,18 +515,18 @@ void PhysicsBody::addMoment(float moment)
{
if (moment == PHYSICS_INFINITY)
{
// if moment is INFINITY, the moment of the body will become INFINITY
// if moment is PHYSICS_INFINITY, the moment of the body will become PHYSICS_INFINITY
_moment = PHYSICS_INFINITY;
_momentDefault = false;
}
else if (moment == -PHYSICS_INFINITY)
{
// if moment is -INFINITY, it won't change
// if moment is -PHYSICS_INFINITY, it won't change
return;
}
else
{
// if moment of the body is INFINITY is has no effect
// if moment of the body is PHYSICS_INFINITY is has no effect
if (_moment != PHYSICS_INFINITY)
{
if (_momentDefault)
@ -811,11 +800,6 @@ Point PhysicsBody::local2World(const Point& point)
return PhysicsHelper::cpv2point(cpBodyLocal2World(_info->getBody(), PhysicsHelper::point2cpv(point)));
}
#elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
#endif
NS_CC_END
#endif // CC_USE_PHYSICS

View File

@ -25,7 +25,6 @@
#ifndef __CCPHYSICS_BODY_H__
#define __CCPHYSICS_BODY_H__
#include "CCPhysicsSetting.h"
#ifdef CC_USE_PHYSICS
#include "CCObject.h"
@ -40,9 +39,10 @@ NS_CC_BEGIN
class Sprite;
class PhysicsWorld;
class PhysicsJoint;
class PhysicsBodyInfo;
typedef Point Vect;
const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT(0.1f, 0.5f, 0.5f);
@ -50,7 +50,7 @@ const PhysicsMaterial PHYSICSBODY_MATERIAL_DEFAULT(0.1f, 0.5f, 0.5f);
* A body affect by physics.
* it can attach one or more shapes.
* if you create body with createXXX, it will automatically compute mass and moment with density your specified(which is PHYSICSBODY_MATERIAL_DEFAULT by default, and the density value is 0.1f), and it based on the formular: mass = density * area.
* if you create body with createEdgeXXX, the mass and moment will be INFINITY by default. and it's a static body.
* if you create body with createEdgeXXX, the mass and moment will be PHYSICS_INFINITY by default. and it's a static body.
* you can change mass and moment with setMass() and setMoment(). and you can change the body to be dynamic or static by use function setDynamic().
*/
class PhysicsBody : public Object

View File

@ -23,19 +23,12 @@
****************************************************************************/
#include "CCPhysicsContact.h"
#ifdef CC_USE_PHYSICS
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#include "chipmunk.h"
#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D)
#include "Box2D.h"
#endif
#include "CCPhysicsBody.h"
#include "chipmunk/CCPhysicsContactInfo_chipmunk.h"
#include "box2d/CCPhysicsContactInfo_box2d.h"
#include "chipmunk/CCPhysicsHelper_chipmunk.h"
#include "box2d/CCPhysicsHelper_box2d.h"
#include "CCEventCustom.h"
@ -105,7 +98,7 @@ void PhysicsContact::generateContactData()
cpArbiter* arb = static_cast<cpArbiter*>(_contactInfo);
_contactData = new PhysicsContactData();
_contactData->count = cpArbiterGetCount(arb);
for (int i=0; i<_contactData->count; ++i)
for (int i=0; i<_contactData->count && i<PhysicsContactData::POINT_MAX; ++i)
{
_contactData->points[i] = PhysicsHelper::cpv2point(cpArbiterGetPoint(arb, i));
}

View File

@ -25,7 +25,6 @@
#ifndef __CCPHYSICS_CONTACT_H__
#define __CCPHYSICS_CONTACT_H__
#include "CCPhysicsSetting.h"
#ifdef CC_USE_PHYSICS
#include "CCObject.h"
@ -41,10 +40,12 @@ class PhysicsWorld;
class PhysicsContactInfo;
typedef Point Vect;
typedef struct PhysicsContactData
{
Point points[PHYSICS_CONTACT_POINT_MAX];
static const long POINT_MAX = 4;
Point points[POINT_MAX];
int count;
Point normal;

View File

@ -24,24 +24,15 @@
#include "CCPhysicsJoint.h"
#ifdef CC_USE_PHYSICS
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#include "chipmunk.h"
#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D)
#include "Box2D.h"
#endif
#include "CCPhysicsBody.h"
#include "CCPhysicsWorld.h"
#include "chipmunk/CCPhysicsJointInfo_chipmunk.h"
#include "box2d/CCPhysicsJointInfo_box2d.h"
#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h"
#include "box2d/CCPhysicsBodyInfo_box2d.h"
#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h"
#include "box2d/CCPhysicsShapeInfo_box2d.h"
#include "chipmunk/CCPhysicsHelper_chipmunk.h"
#include "box2d/CCPhysicsHelper_box2d.h"
#include "CCNode.h"
NS_CC_BEGIN
@ -71,19 +62,15 @@ bool PhysicsJoint::init(cocos2d::PhysicsBody *a, cocos2d::PhysicsBody *b)
{
do
{
CCASSERT(a != nullptr && b != nullptr, "the body passed in is nil");
CCASSERT(a != b, "the two bodies are equal");
CC_BREAK_IF(!(_info = new PhysicsJointInfo(this)));
if (a != nullptr)
{
_bodyA = a;
_bodyA->_joints.push_back(this);
}
if (b != nullptr)
{
_bodyB = b;
_bodyB->_joints.push_back(this);
}
_bodyA = a;
_bodyA->_joints.push_back(this);
_bodyB = b;
_bodyB->_joints.push_back(this);
return true;
} while (false);
@ -150,7 +137,6 @@ PhysicsJointDistance::~PhysicsJointDistance()
}
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
PhysicsBodyInfo* PhysicsJoint::getBodyInfo(PhysicsBody* body) const
{
return body->_info;
@ -375,9 +361,5 @@ bool PhysicsJointDistance::init(PhysicsBody* a, PhysicsBody* b, const Point& anc
return false;
}
#elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
#endif
NS_CC_END
#endif // CC_USE_PHYSICS

View File

@ -25,7 +25,6 @@
#ifndef __CCPHYSICS_JOINT_H__
#define __CCPHYSICS_JOINT_H__
#include "CCPhysicsSetting.h"
#ifdef CC_USE_PHYSICS
#include "CCObject.h"

View File

@ -1,59 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCPHYSICS_SETTING_H__
#define __CCPHYSICS_SETTING_H__
#define CC_PHYSICS_UNKNOWN 0
#define CC_PHYSICS_BOX2D 1
#define CC_PHYSICS_CHIPMUNK 2
#define CC_USE_CHIPMUNK
#ifdef CC_USE_BOX2D
#define CC_PHYSICS_ENGINE CC_PHYSICS_BOX2D
#elif defined(CC_USE_CHIPMUNK)
#define CC_PHYSICS_ENGINE CC_PHYSICS_CHIPMUNK
#else
#define CC_PHYSICS_ENGINE CC_PHYSICS_UNKNOWN
#endif
#if (CC_PHYSICS_ENGINE != CC_PHYSICS_UNKNOWN)
#define CC_USE_PHYSICS
#endif
namespace cocos2d
{
extern const float PHYSICS_INFINITY;
class Point;
typedef Point Vect;
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
static const int PHYSICS_CONTACT_POINT_MAX = 4;
#else
#endif
}
#endif // __CCPHYSICS_SETTING_H__

View File

@ -27,22 +27,17 @@
#include <climits>
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#include "chipmunk.h"
#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D)
#include "Box2D.h"
#endif
#include "CCPhysicsBody.h"
#include "CCPhysicsWorld.h"
#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h"
#include "box2d/CCPhysicsBodyInfo_box2d.h"
#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h"
#include "box2d/CCPhysicsShapeInfo_box2d.h"
#include "chipmunk/CCPhysicsHelper_chipmunk.h"
NS_CC_BEGIN
extern const float PHYSICS_INFINITY;
PhysicsShape::PhysicsShape()
: _body(nullptr)
@ -195,7 +190,6 @@ PhysicsShapeEdgeSegment::~PhysicsShapeEdgeSegment()
}
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
void PhysicsShape::setDensity(float density)
{
if (density < 0)
@ -810,10 +804,6 @@ bool PhysicsShape::containsPoint(const Point& point) const
return false;
}
#elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
#endif
NS_CC_END
#endif // CC_USE_PHYSICS

View File

@ -25,7 +25,6 @@
#ifndef __CCPHYSICS_SHAPE_H__
#define __CCPHYSICS_SHAPE_H__
#include "CCPhysicsSetting.h"
#ifdef CC_USE_PHYSICS
#include "CCObject.h"

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,6 @@
#ifndef __CCPHYSICS_WORLD_H__
#define __CCPHYSICS_WORLD_H__
#include "CCPhysicsSetting.h"
#ifdef CC_USE_PHYSICS
#include <list>
@ -43,6 +42,8 @@ class PhysicsShape;
class PhysicsContact;
class Array;
typedef Point Vect;
class Sprite;
class Scene;
class DrawNode;
@ -201,6 +202,7 @@ protected:
friend class PhysicsWorld;
};
extern const float PHYSICS_INFINITY;
NS_CC_END

View File

@ -1,9 +1,4 @@
set(COCOS_PHYSICS_SRC
${CMAKE_SOURCE_DIR}/cocos/physics/box2d/CCPhysicsContactInfo_box2d.cpp
${CMAKE_SOURCE_DIR}/cocos/physics/box2d/CCPhysicsJointInfo_box2d.cpp
${CMAKE_SOURCE_DIR}/cocos/physics/box2d/CCPhysicsShapeInfo_box2d.cpp
${CMAKE_SOURCE_DIR}/cocos/physics/box2d/CCPhysicsBodyInfo_box2d.cpp
${CMAKE_SOURCE_DIR}/cocos/physics/box2d/CCPhysicsWorldInfo_box2d.cpp
${CMAKE_SOURCE_DIR}/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp
${CMAKE_SOURCE_DIR}/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp
${CMAKE_SOURCE_DIR}/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp

View File

@ -1,39 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCPhysicsBodyInfo_box2d.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
NS_CC_BEGIN
PhysicsBodyInfo::PhysicsBodyInfo()
{
}
PhysicsBodyInfo::~PhysicsBodyInfo()
{
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D

View File

@ -1,45 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCPHYSICS_BODY_INFO_BOX2D_H__
#define __CCPHYSICS_BODY_INFO_BOX2D_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
#include "CCPlatformMacros.h"
NS_CC_BEGIN
class PhysicsBodyInfo
{
public:
PhysicsBodyInfo();
~PhysicsBodyInfo();
};
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D
#endif // __CCPHYSICS_BODY_INFO_BOX2D_H__

View File

@ -1,39 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCPhysicsContactInfo_box2d.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
NS_CC_BEGIN
PhysicsContactInfo::PhysicsContactInfo()
{
}
PhysicsContactInfo::~PhysicsContactInfo()
{
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D

View File

@ -1,44 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCPHYSICS_CONTACT_INFO_BOX2D_H__
#define __CCPHYSICS_CONTACT_INFO_BOX2D_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
#include "CCPlatformMacros.h"
NS_CC_BEGIN
class PhysicsContactInfo
{
public:
PhysicsContactInfo();
~PhysicsContactInfo();
};
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D
#endif // __CCPHYSICS_CONTACT_INFO_BOX2D_H__

View File

@ -1,42 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCPHYSICS_HELPER_BOX2D_H__
#define __CCPHYSICS_HELPER_BOX2D_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
#include "CCPlatformMacros.h"
#include "CCGeometry.h"
NS_CC_BEGIN
class PhysicsHelper
{
};
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D
#endif // __CCPHYSICS_HELPER_BOX2D_H__

View File

@ -1,39 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCPhysicsJointInfo_box2d.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
NS_CC_BEGIN
PhysicsJointInfo::PhysicsJointInfo()
{
}
PhysicsJointInfo::~PhysicsJointInfo()
{
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D

View File

@ -1,44 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCPHYSICS_JOINT_INFO_BOX2D_H__
#define __CCPHYSICS_JOINT_INFO_BOX2D_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
#include "CCPlatformMacros.h"
NS_CC_BEGIN
class PhysicsJointInfo
{
public:
PhysicsJointInfo();
~PhysicsJointInfo();
};
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D
#endif // __CCPHYSICS_JOINT_INFO_BOX2D_H__

View File

@ -1,39 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCPhysicsShapeInfo_box2d.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
NS_CC_BEGIN
PhysicsShapeInfo::PhysicsShapeInfo()
{
}
PhysicsShapeInfo::~PhysicsShapeInfo()
{
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D

View File

@ -1,44 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCPHYSICS_SHAPE_INFO_BOX2D_H__
#define __CCPHYSICS_SHAPE_INFO_BOX2D_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
#include "CCPlatformMacros.h"
NS_CC_BEGIN
class PhysicsShapeInfo
{
public:
PhysicsShapeInfo();
~PhysicsShapeInfo();
};
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D
#endif // __CCPHYSICS_SHAPE_INFO_BOX2D_H__

View File

@ -1,39 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCPhysicsWorldInfo_box2d.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
NS_CC_BEGIN
PhysicsWorldInfo::PhysicsWorldInfo()
{
}
PhysicsWorldInfo::~PhysicsWorldInfo()
{
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D

View File

@ -1,44 +0,0 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCPHYSICS_WORLD_INFO_BOX2D_H__
#define __CCPHYSICS_WORLD_INFO_BOX2D_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D)
#include "CCPlatformMacros.h"
NS_CC_BEGIN
class PhysicsWorldInfo
{
public:
PhysicsWorldInfo();
~PhysicsWorldInfo();
};
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D
#endif // __CCPHYSICS_WORLD_INFO_BOX2D_H__

View File

@ -22,8 +22,8 @@
THE SOFTWARE.
****************************************************************************/
#ifdef CC_USE_PHYSICS
#include "CCPhysicsBodyInfo_chipmunk.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
NS_CC_BEGIN
PhysicsBodyInfo::PhysicsBodyInfo()
@ -37,4 +37,4 @@ PhysicsBodyInfo::~PhysicsBodyInfo()
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS

View File

@ -25,8 +25,7 @@
#ifndef __CCPHYSICS_BODY_INFO_CHIPMUNK_H__
#define __CCPHYSICS_BODY_INFO_CHIPMUNK_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#ifdef CC_USE_PHYSICS
#include "chipmunk.h"
#include "CCPlatformMacros.h"
@ -52,5 +51,5 @@ private:
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS
#endif // __CCPHYSICS_BODY_INFO_CHIPMUNK_H__

View File

@ -22,8 +22,8 @@
THE SOFTWARE.
****************************************************************************/
#ifdef CC_USE_PHYSICS
#include "CCPhysicsContactInfo_chipmunk.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
NS_CC_BEGIN
PhysicsContactInfo::PhysicsContactInfo(PhysicsContact* contact)
@ -36,4 +36,4 @@ PhysicsContactInfo::~PhysicsContactInfo()
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS

View File

@ -25,8 +25,7 @@
#ifndef __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__
#define __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#ifdef CC_USE_PHYSICS
#include "chipmunk.h"
#include "CCPlatformMacros.h"
@ -50,5 +49,5 @@ private:
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS
#endif // __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__

View File

@ -25,8 +25,7 @@
#ifndef __CCPHYSICS_HELPER_CHIPMUNK_H__
#define __CCPHYSICS_HELPER_CHIPMUNK_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#ifdef CC_USE_PHYSICS
#include "chipmunk.h"
#include "CCPlatformMacros.h"
@ -69,5 +68,5 @@ public:
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS
#endif // __CCPHYSICS_HELPER_CHIPMUNK_H__

View File

@ -22,9 +22,8 @@
THE SOFTWARE.
****************************************************************************/
#ifdef CC_USE_PHYSICS
#include "CCPhysicsJointInfo_chipmunk.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#include <algorithm>
#include <unordered_map>
@ -82,4 +81,4 @@ void PhysicsJointInfo::removeAll()
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS

View File

@ -25,8 +25,7 @@
#ifndef __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__
#define __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#ifdef CC_USE_PHYSICS
#include "chipmunk.h"
#include "CCPlatformMacros.h"
@ -60,5 +59,5 @@ protected:
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS
#endif // __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__

View File

@ -22,9 +22,8 @@
THE SOFTWARE.
****************************************************************************/
#ifdef CC_USE_PHYSICS
#include "CCPhysicsShapeInfo_chipmunk.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#include <algorithm>
#include <unordered_map>
@ -116,4 +115,4 @@ void PhysicsShapeInfo::removeAll()
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS

View File

@ -25,8 +25,7 @@
#ifndef __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__
#define __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#if CC_USE_PHYSICS
#include <vector>
#include <unordered_map>
@ -69,5 +68,5 @@ protected:
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS
#endif // __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__

View File

@ -22,25 +22,14 @@
THE SOFTWARE.
****************************************************************************/
#ifdef CC_USE_PHYSICS
#include "CCPhysicsWorldInfo_chipmunk.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#include "CCPhysicsHelper_chipmunk.h"
#include "CCPhysicsBodyInfo_chipmunk.h"
#include "CCPhysicsShapeInfo_chipmunk.h"
#include "CCPhysicsJointInfo_chipmunk.h"
NS_CC_BEGIN
#define PHYSICS_WORLD_INFO_FUNCTION_IMPLEMENTS(name, type) \
void PhysicsWorldInfo::add##name(cp##type* data) \
{ \
if (!cpSpaceContains##type(_space, data)) cpSpaceAdd##type(_space, data); \
} \
\
void PhysicsWorldInfo::remove##name(cp##type* data) \
{ \
if (cpSpaceContains##type(_space, data)) cpSpaceRemove##type(_space, data); \
} \
PHYSICS_WORLD_INFO_FUNCTION_IMPLEMENTS(Shape, Shape)
PHYSICS_WORLD_INFO_FUNCTION_IMPLEMENTS(Body, Body)
PHYSICS_WORLD_INFO_FUNCTION_IMPLEMENTS(Joint, Constraint)
PhysicsWorldInfo::PhysicsWorldInfo()
{
_space = cpSpaceNew();
@ -51,5 +40,61 @@ PhysicsWorldInfo::~PhysicsWorldInfo()
cpSpaceFree(_space);
}
void PhysicsWorldInfo::setGravity(const Vect& gravity)
{
cpSpaceSetGravity(_space, PhysicsHelper::point2cpv(gravity));
}
void PhysicsWorldInfo::addBody(PhysicsBodyInfo& body)
{
if (!cpSpaceContainsBody(_space, body.getBody()))
{
cpSpaceAddBody(_space, body.getBody());
}
}
void PhysicsWorldInfo::removeBody(PhysicsBodyInfo& body)
{
if (cpSpaceContainsBody(_space, body.getBody()))
{
cpSpaceRemoveBody(_space, body.getBody());
}
}
void PhysicsWorldInfo::addShape(PhysicsShapeInfo& shape)
{
for (auto cps : shape.getShapes())
{
cpSpaceAddShape(_space, cps);
}
}
void PhysicsWorldInfo::removeShape(PhysicsShapeInfo& shape)
{
for (auto cps : shape.getShapes())
{
if (cpSpaceContainsShape(_space, cps))
{
cpSpaceRemoveShape(_space, cps);
}
}
}
void PhysicsWorldInfo::addJoint(PhysicsJointInfo& joint)
{
for (auto subjoint : joint.getJoints())
{
cpSpaceAddConstraint(_space, subjoint);
}
}
void PhysicsWorldInfo::removeJoint(PhysicsJointInfo& joint)
{
for (auto subjoint : joint.getJoints())
{
cpSpaceRemoveConstraint(_space, subjoint);
}
}
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS

View File

@ -25,24 +25,31 @@
#ifndef __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__
#define __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__
#include "../CCPhysicsSetting.h"
#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK)
#ifdef CC_USE_PHYSICS
#include <vector>
#include "chipmunk.h"
#include "CCPlatformMacros.h"
#include <vector>
#include "CCGeometry.h"
NS_CC_BEGIN
typedef Point Vect;
class PhysicsBodyInfo;
class PhysicsJointInfo;
class PhysicsShapeInfo;
class PhysicsWorldInfo
{
public:
cpSpace* getSpace() const { return _space; }
void addShape(cpShape* shape);
void removeShape(cpShape* shape);
void addBody(cpBody* body);
void removeBody(cpBody* body);
void addJoint(cpConstraint* joint);
void removeJoint(cpConstraint* joint);
void addShape(PhysicsShapeInfo& shape);
void removeShape(PhysicsShapeInfo& shape);
void addBody(PhysicsBodyInfo& body);
void removeBody(PhysicsBodyInfo& body);
void addJoint(PhysicsJointInfo& joint);
void removeJoint(PhysicsJointInfo& joint);
void setGravity(const Vect& gravity);
inline bool isLocked() { return static_cast<bool>(_space->locked_private); }
inline void step(float delta) { cpSpaceStep(_space, delta); }
private:
PhysicsWorldInfo();
@ -56,5 +63,5 @@ private:
NS_CC_END
#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK
#endif // CC_USE_PHYSICS
#endif // __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__

View File

@ -6,6 +6,7 @@ USING_NS_CC;
namespace
{
static std::function<Layer*()> createFunctions[] = {
#ifdef CC_USE_PHYSICS
CL(PhysicsDemoLogoSmash),
CL(PhysicsDemoPyramidStack),
CL(PhysicsDemoClickAdd),
@ -15,6 +16,9 @@ namespace
CL(PhysicsDemoPump),
CL(PhysicsDemoOneWayPlatform),
CL(PhysicsDemoSlice),
#else
CL(PhysicsDemoDisabled),
#endif
};
static int sceneIdx=-1;
@ -50,23 +54,44 @@ namespace
static const int DRAG_BODYS_TAG = 0x80;
}
PhysicsTestScene::PhysicsTestScene()
#ifdef CC_USE_PHYSICS
: TestScene(false, true)
#else
: TestScene()
#endif
, _debugDraw(false)
{}
void PhysicsTestScene::runThisTest()
{
#ifdef CC_USE_PHYSICS
sceneIdx = -1;
addChild(next());
Director::getInstance()->replaceScene(this);
#else
#endif
}
void PhysicsTestScene::toggleDebug()
{
#ifdef CC_USE_PHYSICS
_debugDraw = !_debugDraw;
getPhysicsWorld()->setDebugDrawMask(_debugDraw ? PhysicsWorld::DEBUGDRAW_ALL : PhysicsWorld::DEBUGDRAW_NONE);
#endif
}
#ifndef CC_USE_PHYSICS
void PhysicsDemoDisabled::onEnter()
{
auto label = LabelTTF::create("Should define CC_USE_PHYSICS\n to run this test case",
"Arial",
18);
auto size = Director::getInstance()->getWinSize();
label->setPosition(Point(size.width/2, size.height/2));
addChild(label);
}
#else
PhysicsDemo::PhysicsDemo()
: _scene(nullptr)
, _spriteTexture(nullptr)
@ -121,8 +146,6 @@ void PhysicsDemo::onEnter()
_spriteTexture = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100)->getTexture();
#ifdef CC_USE_PHYSICS
// menu for debug layer
MenuItemFont::setFontSize(18);
auto item = MenuItemFont::create("Toggle debug", CC_CALLBACK_1(PhysicsDemo::toggleDebugCallback, this));
@ -130,13 +153,10 @@ void PhysicsDemo::onEnter()
auto menu = Menu::create(item, NULL);
this->addChild(menu);
menu->setPosition(Point(VisibleRect::right().x-50, VisibleRect::top().y-10));
#else
#endif
}
Sprite* PhysicsDemo::addGrossiniAtPosition(Point p, float scale/* = 1.0*/)
{
#ifdef CC_USE_PHYSICS
CCLOG("Add sprite %0.2f x %02.f",p.x,p.y);
int posx, posy;
@ -154,18 +174,15 @@ Sprite* PhysicsDemo::addGrossiniAtPosition(Point p, float scale/* = 1.0*/)
sp->setPosition(p);
return sp;
#endif
}
void PhysicsDemo::toggleDebugCallback(Object* sender)
{
#ifdef CC_USE_PHYSICS
if (_scene != nullptr)
{
_scene->toggleDebug();
}
#endif
}
PhysicsDemoClickAdd::~PhysicsDemoClickAdd()
@ -177,8 +194,6 @@ void PhysicsDemoClickAdd::onEnter()
{
PhysicsDemo::onEnter();
#ifdef CC_USE_PHYSICS
auto touchListener = EventListenerTouchAllAtOnce::create();
touchListener->onTouchesEnded = CC_CALLBACK_2(PhysicsDemoClickAdd::onTouchesEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
@ -193,16 +208,6 @@ void PhysicsDemoClickAdd::onEnter()
this->addChild(node);
addGrossiniAtPosition(VisibleRect::center());
#else
auto label = LabelTTF::create("Should define CC_USE_BOX2D or CC_USE_CHIPMUNK\n to run this test case",
"Arial",
18);
auto size = Director::getInstance()->getWinSize();
label->setPosition(Point(size.width/2, size.height/2));
addChild(label);
#endif
}
std::string PhysicsDemoClickAdd::subtitle()
@ -224,7 +229,6 @@ void PhysicsDemoClickAdd::onTouchesEnded(const std::vector<Touch*>& touches, Eve
void PhysicsDemoClickAdd::onAcceleration(Acceleration* acc, Event* event)
{
#ifdef CC_USE_PHYSICS
static float prevX=0, prevY=0;
#define kFilterFactor 0.05f
@ -242,7 +246,6 @@ void PhysicsDemoClickAdd::onAcceleration(Acceleration* acc, Event* event)
{
_scene->getPhysicsWorld()->setGravity(v);
}
#endif
}
namespace
@ -1112,3 +1115,5 @@ std::string PhysicsDemoSlice::subtitle()
{
return "click and drag to slice up the block";
}
#endif // ifndef CC_USE_PHYSICS

View File

@ -11,10 +11,7 @@
class PhysicsTestScene : public TestScene
{
public:
PhysicsTestScene()
:TestScene(false, true)
, _debugDraw(false)
{}
PhysicsTestScene();
public:
virtual void runThisTest();
@ -25,6 +22,14 @@ private:
bool _debugDraw;
};
#ifndef CC_USE_PHYSICS
class PhysicsDemoDisabled : public BaseTest
{
public:
virtual void onEnter() override;
};
#else
class PhysicsDemo : public BaseTest
{
public:
@ -178,3 +183,4 @@ private:
};
#endif
#endif

View File

@ -70,7 +70,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\network;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_USE_PHYSICS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
@ -103,7 +103,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\network;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_USE_PHYSICS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>