diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt
index 2c6425f..5cb6012 100644
--- a/build/tizen/CMakeLists.txt
+++ b/build/tizen/CMakeLists.txt
@@ -243,6 +243,21 @@ IF( ENABLE_PKG_CONFIGURE )
SET( ENABLE_SCENE3D "ON" )
ENDIF()
+ pkg_check_modules(DALI_PHYSICS_2D dali2-physics-2d)
+ IF( DALI_PHYSICS_2D_FOUND )
+ FOREACH(flag ${DALI_PHYSICS_2D_CFLAGS})
+ SET(REQUIRED_CFLAGS "${REQUIRED_CFLAGS} ${flag}")
+ ENDFOREACH(flag)
+
+ SET( REQUIRED_CFLAGS "${REQUIRED_CFLAGS} -DDALI_PHYSICS_2D_AVAILABLE" )
+
+ FOREACH(flag ${DALI_PHYSICS_2D_LDFLAGS})
+ SET(REQUIRED_PKGS_LDFLAGS "${REQUIRED_PKGS_LDFLAGS} ${flag}")
+ ENDFOREACH(flag)
+
+ SET( ENABLE_PHYSICS_2D "ON" )
+ ENDIF()
+
# if build as tizen platform, use capi-appfw-app-control
IF( TIZEN )
pkg_check_modules(CAPI_APPFW_APP_CONTROL capi-appfw-app-control)
@@ -292,6 +307,8 @@ IF( WIN32 OR APPLE ) # WIN32 includes x64 as well according to the cmake doc.
FIND_PACKAGE( dali2-scene3d )
+ FIND_PACKAGE( chipmunk )
+
# Set up the include dir
SET( INCLUDE_DIR $ENV{includedir} )
IF( NOT INCLUDE_DIR )
@@ -346,6 +363,15 @@ IF( WIN32 OR APPLE ) # WIN32 includes x64 as well according to the cmake doc.
)
SET( ENABLE_SCENE3D "ON" )
ENDIF()
+
+ IF (chipmunk_FOUND)
+ SET(REQUIRED_LIBS
+ ${REQUIRED_LIBS}
+ -lchipmunk
+ )
+ SET( ENABLE_PHYSICS_2D "ON" )
+ ENDIF()
+
ELSEIF( UNIX )
SET( REQUIRED_LIBS
${REQUIRED_PKGS_LDFLAGS}
@@ -374,6 +400,10 @@ IF( ENABLE_SCENE3D )
SET(DALI_DEMO_CFLAGS "${DALI_DEMO_CFLAGS} -DDALI_SCENE3D_AVAILABLE")
ENDIF()
+IF( ENABLE_PHYSICS_2D )
+ SET(DALI_DEMO_CFLAGS "${DALI_DEMO_CFLAGS} -DDALI_PHYSICS_2D_AVAILABLE")
+ENDIF()
+
IF( UNIX )
IF( NOT ${ENABLE_EXPORTALL} )
ADD_DEFINITIONS( "-DHIDE_DALI_INTERNALS" )
@@ -491,3 +521,4 @@ MESSAGE( " Folder DEMO_LANG : [" ${DEMO_LANG} "]" )
MESSAGE( " Current Build Platform : [" ${CURRENT_BUILD_PLATFORM} "]" )
MESSAGE( " Build example name : [" ${CURRENT_BUILD_EXAMPLE_NAME} "]" )
MESSAGE( " Scene3D Enabled : [" ${ENABLE_SCENE3D} "]" )
+MESSAGE( " Physics 2D Enabled : [" ${ENABLE_PHYSICS_2D} "]" )
diff --git a/build/tizen/examples/CMakeLists.txt b/build/tizen/examples/CMakeLists.txt
index 05ebbdf..6a458b3 100644
--- a/build/tizen/examples/CMakeLists.txt
+++ b/build/tizen/examples/CMakeLists.txt
@@ -20,6 +20,13 @@ IF (NOT "${ENABLE_SCENE3D}" )
ENDIF()
ENDIF()
+SET(PHYSICS_2D_DIR "chipmunk")
+IF (NOT "${ENABLE_PHYSICS_2D}" )
+ IF ( ${PHYSICS_2D_DIR} IN_LIST SUBDIRS )
+ LIST( REMOVE_ITEM SUBDIRS ${PHYSICS_2D_DIR} )
+ ENDIF()
+ENDIF()
+
FIND_PROGRAM( SHADER_GENERATOR "dali-shader-generator" )
IF( NOT SHADER_GENERATOR )
MESSAGE( FATAL_ERROR "dali-shader-generator not found!" )
diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml
index 4d2e012..4c12d91 100644
--- a/com.samsung.dali-demo.xml
+++ b/com.samsung.dali-demo.xml
@@ -67,6 +67,9 @@
+
+
+
diff --git a/examples-reel/dali-examples-reel.cpp b/examples-reel/dali-examples-reel.cpp
index b44ab48..a697899 100644
--- a/examples-reel/dali-examples-reel.cpp
+++ b/examples-reel/dali-examples-reel.cpp
@@ -47,6 +47,7 @@ int DALI_EXPORT_API main(int argc, char** argv)
demo.AddExample(Example("builder.example", DALI_DEMO_STR_TITLE_SCRIPT_BASED_UI));
demo.AddExample(Example("buttons.example", DALI_DEMO_STR_TITLE_BUTTONS));
demo.AddExample(Example("canvas-view.example", DALI_DEMO_STR_TITLE_CANVAS_VIEW));
+ demo.AddExample(Example("chipmunk-physics.example", DALI_DEMO_STR_TITLE_CHIPMUNK_PHYSICS));
demo.AddExample(Example("clipping.example", DALI_DEMO_STR_TITLE_CLIPPING));
demo.AddExample(Example("clipping-draw-order.example", DALI_DEMO_STR_TITLE_CLIPPING_DRAW_ORDER));
demo.AddExample(Example("color-transition.example", DALI_DEMO_STR_TITLE_COLOR_TRANSITION));
diff --git a/examples/chipmunk-physics/frame-callback.cpp b/examples/chipmunk-physics/frame-callback.cpp
new file mode 100644
index 0000000..c6ef8a3
--- /dev/null
+++ b/examples/chipmunk-physics/frame-callback.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "frame-callback.h"
+#include "physics-impl.h"
+#include
+#include
+#include
+
+using Dali::Vector3;
+using Dali::Quaternion;
+
+FrameCallback::FrameCallback(PhysicsImpl& physicsImpl)
+: mPhysicsImpl(physicsImpl)
+{
+}
+
+bool FrameCallback::Update(Dali::UpdateProxy& updateProxy, float elapsedSeconds)
+{
+ Dali::Mutex::ScopedLock lock(mPhysicsImpl.mMutex);
+ static float frameTime=0;
+ frameTime+=elapsedSeconds;
+ do
+ {
+ mPhysicsImpl.Integrate(mPhysicsTimeStep);
+ frameTime-=mPhysicsTimeStep;
+ } while (frameTime>0);
+
+ for(auto&& actor : mPhysicsImpl.mPhysicsActors)
+ {
+ // Get position, orientation from physics world.
+ Vector3 position = actor.second.GetActorPosition();
+ updateProxy.BakePosition(actor.first, position);
+ Quaternion rotation = actor.second.GetActorRotation();
+ updateProxy.BakeOrientation(actor.first, rotation);
+ }
+
+ return true;
+}
diff --git a/examples/chipmunk-physics/frame-callback.h b/examples/chipmunk-physics/frame-callback.h
new file mode 100644
index 0000000..c45f019
--- /dev/null
+++ b/examples/chipmunk-physics/frame-callback.h
@@ -0,0 +1,58 @@
+#ifndef PHYSICS_DEMO_FRAME_CALLBACK_H
+#define PHYSICS_DEMO_FRAME_CALLBACK_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include
+#include