Skip to content

Commit 395cff7

Browse files
committed
[WIP] Implement Physics2D with box2d-v3
1 parent 9eb9cff commit 395cff7

24 files changed

+7235
-208
lines changed

core/2d/Node.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Node::Node()
125125
, _onExitCallback(nullptr)
126126
, _onEnterTransitionDidFinishCallback(nullptr)
127127
, _onExitTransitionDidStartCallback(nullptr)
128-
#if defined(AX_ENABLE_PHYSICS) && 0
128+
#if defined(AX_ENABLE_PHYSICS)
129129
, _physicsBody(nullptr)
130130
#endif
131131
{

core/2d/Node.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
THE SOFTWARE.
2929
****************************************************************************/
3030

31-
#ifndef __CCNODE_H__
32-
#define __CCNODE_H__
31+
#ifndef __AXNODE_H__
32+
#define __AXNODE_H__
3333

3434
#include <cstdint>
3535
#include "base/Macros.h"
@@ -41,7 +41,7 @@
4141
#include "2d/ComponentContainer.h"
4242
#include "2d/Component.h"
4343

44-
#if defined(AX_ENABLE_PHYSICS) && 0
44+
#if defined(AX_ENABLE_PHYSICS)
4545
# include "physics/PhysicsBody.h"
4646
#endif
4747

@@ -2026,7 +2026,7 @@ class AX_DLL Node : public Object
20262026
backend::ProgramState* _programState = nullptr;
20272027

20282028
// Physics:remaining backwardly compatible
2029-
#if defined(AX_ENABLE_PHYSICS) && 0
2029+
#if defined(AX_ENABLE_PHYSICS)
20302030
PhysicsBody* _physicsBody;
20312031

20322032
public:

core/2d/Scene.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ THE SOFTWARE.
3535
#include "base/UTF8.h"
3636
#include "renderer/Renderer.h"
3737

38-
#if defined(AX_ENABLE_PHYSICS) && 0
38+
#if defined(AX_ENABLE_PHYSICS)
3939
# include "physics/PhysicsWorld.h"
4040
#endif
4141

@@ -351,7 +351,7 @@ bool Scene::initWithPhysics()
351351

352352
bool Scene::initPhysicsWorld()
353353
{
354-
# if defined(AX_ENABLE_PHYSICS) && 0
354+
# if defined(AX_ENABLE_PHYSICS)
355355
_physicsWorld = PhysicsWorld::construct(this);
356356
# endif
357357

@@ -377,7 +377,7 @@ bool Scene::initPhysicsWorld()
377377
#if defined(AX_ENABLE_PHYSICS) || defined(AX_ENABLE_3D_PHYSICS) || defined(AX_ENABLE_NAVMESH)
378378
void Scene::stepPhysicsAndNavigation(float deltaTime)
379379
{
380-
# if defined(AX_ENABLE_PHYSICS) && 0
380+
# if defined(AX_ENABLE_PHYSICS)
381381
if (_physicsWorld && _physicsWorld->isAutoStep())
382382
_physicsWorld->update(deltaTime);
383383
# endif

core/axmol.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ THE SOFTWARE.
165165
#include "renderer/Shaders.h"
166166

167167
// physics
168-
// #include "physics/PhysicsBody.h"
169-
// #include "physics/PhysicsContact.h"
170-
// #include "physics/PhysicsJoint.h"
171-
// #include "physics/PhysicsCollider.h"
172-
// #include "physics/PhysicsWorld.h"
168+
#include "physics/PhysicsBody.h"
169+
#include "physics/PhysicsContact.h"
170+
#include "physics/PhysicsJoint.h"
171+
#include "physics/PhysicsCollider.h"
172+
#include "physics/PhysicsWorld.h"
173173

174174
// platform
175175
#include "platform/Common.h"

core/physics/CMakeLists.txt

+16-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
# place holder for builtin physics based on box2d v3
1+
set(_AX_PHYSICS_HEADER
2+
physics/PhysicsContact.h
3+
physics/PhysicsWorld.h
4+
physics/PhysicsBody.h
5+
physics/PhysicsCollider.h
6+
physics/PhysicsHelper.h
7+
physics/PhysicsJoint.h
8+
)
9+
10+
set(_AX_PHYSICS_SRC
11+
physics/PhysicsBody.cpp
12+
physics/PhysicsContact.cpp
13+
physics/PhysicsJoint.cpp
14+
physics/PhysicsCollider.cpp
15+
physics/PhysicsWorld.cpp
16+
)

0 commit comments

Comments
 (0)