diff --git a/thirdparty/bullet3-3.22/HPKBUILD b/thirdparty/bullet3-3.22/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..bb17bee0025ea5985b15a2160b306b3a77952c66 --- /dev/null +++ b/thirdparty/bullet3-3.22/HPKBUILD @@ -0,0 +1,73 @@ +# Copyright (c) 2023 Huawei Device 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. + +# Contributor: wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn>, wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +pkgname=bullet3-3.22 +pkgver=3.22 +pkgrel=0 +pkgdesc="It is a real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc." +url="https://github.com/bulletphysics/bullet3/tree/3.22" +archs=("armeabi-v7a" "arm64-v8a") +license=("Zlib License") +depends=() +makedepends=() +source="https://github.com/bulletphysics/bullet3/archive/refs/tags/3.22.zip" + +downloadpackage=true +autounpack=true +buildtools=cmake +patchflag=true + +builddir=bullet3-3.22 +packagename=bullet3-3.22.zip + +# 为编译设置环境,如设置环境变量,创建编译目录等 +prepare() { + if $patchflag + then + cd $builddir + patch -p1 < `pwd`/../bullet3-3.22_oh_pkg.patch + # patch只需要打一次,关闭打patch + patchflag=false + cd $OLDPWD + fi + mkdir -p $builddir/$ARCH-build +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" -DCMAKE_C_FLAGS="-Wno-unused-command-line-argument" \ + -DCMAKE_CXX_FLAGS="-Wno-unused-command-line-argument" -B$ARCH-build -S./ > $buildlog 2>&1 + $MAKE VERBOSE=1 -C $ARCH-build >> $buildlog 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir + $MAKE -C $ARCH-build install >> $buildlog 2>&1 + cd $OLDPWD +} + + +check() { + echo "The test must be on an OpenHarmony device!" +} + + +cleanbuild() { + rm -rf ${PWD}/$builddir +} \ No newline at end of file diff --git a/thirdparty/bullet3-3.22/HPKCHECK b/thirdparty/bullet3-3.22/HPKCHECK new file mode 100644 index 0000000000000000000000000000000000000000..9ceab10433ff83b2cc58bf2d9f00a047131e402c --- /dev/null +++ b/thirdparty/bullet3-3.22/HPKCHECK @@ -0,0 +1,30 @@ +# Copyright (c) 2023 Huawei Device 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. + +# Contributor: wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangyihao<2471389@stu.neu.edu.cn>, wangying +# Maintainer: wangyihao<2471389@stu.neu.edu.cn>, wangjialun<2271411@stu.neu.edu.cn>, zhangqian<2371418@stu.neu.edu.cn>, wangying + +source HPKBUILD > /dev/null 2>&1 # 导入HPKBUILD文件 +logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${OHOS_SDK_VER}_test.log + + +# 在OH环境执行测试的接口 +openharmonycheck() { + res=0 + cd ${builddir}/${ARCH}-build # 进入到测试目录 + ctest > ${logfile} 2>&1 # 执行测试命令并将测试结果导出到${logfile} + res=$? + cd $OLDPWD + + return $res +} \ No newline at end of file diff --git a/thirdparty/bullet3-3.22/OAT.xml b/thirdparty/bullet3-3.22/OAT.xml new file mode 100644 index 0000000000000000000000000000000000000000..eeb1f946d683c0b81976cd06522096062a6901b9 --- /dev/null +++ b/thirdparty/bullet3-3.22/OAT.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/bullet3-3.22/README.OpenSource b/thirdparty/bullet3-3.22/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..71d24c96fbe76c368679a036a412eb1963d612cd --- /dev/null +++ b/thirdparty/bullet3-3.22/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "bullet3-3.22", + "License": "Zlib License", + "License File": "https://github.com/bulletphysics/bullet3/blob/master/LICENSE.txt", + "Version Number": "3.22", + "Owner": "2942375747@qq.com", + "Upstream URL": "https://github.com/bulletphysics/bullet3", + "Description": "It is a real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc." + } +] \ No newline at end of file diff --git a/thirdparty/bullet3-3.22/README_zh.md b/thirdparty/bullet3-3.22/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..7393f0b7647cdd38d576c460c363a6b303c43c24 --- /dev/null +++ b/thirdparty/bullet3-3.22/README_zh.md @@ -0,0 +1,9 @@ +# bullet3-3.22三方库说明 +## 功能简介 +bullet3-3.22可以实现实时碰撞检测和多物理场仿真,适用于VR、游戏、视觉效果、机器人、机器学习等。 +## 三方库版本: +- 3.22 +## 使用约束: +- [IDE和SDK版本](../../docs/constraint.md) +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/bullet3-3.22/SHA512SUM b/thirdparty/bullet3-3.22/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..03239cc1f91539361dddc24d6ff515f486be5323 --- /dev/null +++ b/thirdparty/bullet3-3.22/SHA512SUM @@ -0,0 +1 @@ +0015bc885da97815979d8bec7febafa898d0306ac73b2e48aa3bd733fc11858ee968d61949a3f88d0578f9c20f2fbc22e27338bf3f8a38486774da858083d348 bullet3-3.22.zip \ No newline at end of file diff --git a/thirdparty/bullet3-3.22/bullet3-3.22_oh_pkg.patch b/thirdparty/bullet3-3.22/bullet3-3.22_oh_pkg.patch new file mode 100644 index 0000000000000000000000000000000000000000..bc58cf12bc26d2150eb90ecd468d736762ea9afe --- /dev/null +++ b/thirdparty/bullet3-3.22/bullet3-3.22_oh_pkg.patch @@ -0,0 +1,66 @@ +--- bullet3-3.22_old/examples/ThirdPartyLibs/Eigen/src/Core/util/Macros.h 2022-03-26 10:29:36.000000000 +0800 ++++ bullet3-3.22/Macros.h 2024-09-04 11:25:14.315308781 +0800 +@@ -1145,7 +1145,9 @@ + #if EIGEN_COMP_GNUC_STRICT && EIGEN_GNUC_AT_MOST(5, 0) + #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+r,w" (X)); + #else ++ #if !defined(__OHOS__) + #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,w" (X)); ++ #endif + #endif + #elif EIGEN_ARCH_i386_OR_x86_64 + // General, SSE. +--- bullet3-3.22_old/examples/SharedMemory/PhysicsClientUDP.cpp 2022-03-26 10:29:36.000000000 +0800 ++++ bullet3-3.22/PhysicsClientUDP.cpp 2024-09-04 11:32:00.342763723 +0800 +@@ -164,7 +164,7 @@ + if (gVerboseNetworkMessagesClient) + { + printf( +- "A packet of length %lu containing '%s' was " ++ "A packet of length %zu containing '%s' was " + "received from %s on channel %u.\n", + m_event.packet->dataLength, + (char*)m_event.packet->data, +@@ -220,7 +220,7 @@ + if (gVerboseNetworkMessagesClient) + { + printf( +- "A packet of length %lu containing '%s' was " ++ "A packet of length %zu containing '%s' was " + "received from %s on channel %u.\n", + m_event.packet->dataLength, + (char*)m_event.packet->data, +--- bullet3-3.22_old/examples/ThirdPartyLibs/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h 2022-03-26 10:29:36.000000000 +0800 ++++ bullet3-3.22/GenericPacketMathFunctions.h 2024-09-04 11:45:59.441659426 +0800 +@@ -638,7 +638,7 @@ + + // Rounding trick: + Packet y_round = padd(y, cst_rounding_magic); +- EIGEN_OPTIMIZATION_BARRIER(y_round) ++ //EIGEN_OPTIMIZATION_BARRIER(y_round); + PacketI y_int = preinterpret(y_round); // last 23 digits represent integer (if abs(x)<2^24) + y = psub(y_round, cst_rounding_magic); // nearest integer to x*4/pi + +@@ -660,9 +660,9 @@ + // and 2 ULP up to: + const float huge_th = ComputeSine ? 25966.f : 18838.f; + x = pmadd(y, pset1(-1.5703125), x); // = 0xbfc90000 +- EIGEN_OPTIMIZATION_BARRIER(x) ++ //EIGEN_OPTIMIZATION_BARRIER(x); + x = pmadd(y, pset1(-0.000483989715576171875), x); // = 0xb9fdc000 +- EIGEN_OPTIMIZATION_BARRIER(x) ++ //EIGEN_OPTIMIZATION_BARRIER(x); + x = pmadd(y, pset1(1.62865035235881805419921875e-07), x); // = 0x342ee000 + x = pmadd(y, pset1(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee + +--- bullet3-3.22_old/examples/OpenGLWindow/X11OpenGLWindow.cpp 2022-03-26 10:29:36.000000000 +0800 ++++ bullet3-3.22/X11OpenGLWindow.cpp 2024-09-04 11:57:34.600751392 +0800 +@@ -566,7 +566,7 @@ + //Access pthreads as a workaround for a bug in Linux/Ubuntu + //See https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-319/+bug/1248642 + +-#if !defined(__NetBSD__) && !defined(__ANDROID__) ++#if !defined(__NetBSD__) && !defined(__ANDROID__) && !defined(__OHOS__) + int i = pthread_getconcurrency(); + printf("pthread_getconcurrency()=%d\n", i); + #endif diff --git a/thirdparty/bullet3-3.22/docs/hap_integrate.md b/thirdparty/bullet3-3.22/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..781f4da5b4858fc5a6cd9535524719e6cceeac87 --- /dev/null +++ b/thirdparty/bullet3-3.22/docs/hap_integrate.md @@ -0,0 +1,81 @@ +# bullet3集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- [开发环境准备](../../../docs/hap_integrate_environment.md) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ```shell + tpc_c_cplusplus/thirdparty/bullet3-3.22 #三方库bullet3-3.22的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── HPKCHECK #测试脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md #三方库简介 + ``` + +- 在lycium目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../lycium/README.md#1编译环境准备) + + ```shell + cd lycium + ./build.sh bullet3-3.22 + ``` + +- 三方库头文件及生成的库 + + 在lycium目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ```shell + bullet3-3.22/arm64-v8a bullet3-3.22/armeabi-v7a + ``` + +- [测试三方库](#测试三方库) + +- 编译出可执行的文件进行测试,[准备三方库测试环境](../../../lycium/README.md#3ci环境准备) +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的头文件拷贝到该目录下,将编译生成的三方库以及依赖库全部(动态库名字带版本号和不带版本号的都需要)拷贝到工程的libs目录下,如下图所示: +   + +  ![thirdparty_install_dir](pic/bullet3_install_dir.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + + ```shell + #将三方库加入工程中 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/bullet3/${OHOS_ARCH}/lib/libBullet3Collision.a) + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/bullet3/${OHOS_ARCH}/lib/libBullet3Common.a) + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/bullet3/${OHOS_ARCH}/lib/libBullet3Dynamics.a) + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/bullet3/${OHOS_ARCH}/lib/libBullet3Geometry.a) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/bullet3/${OHOS_ARCH}/include) + ``` + +## 测试三方库 +进入到构建目录运行测试用例(注意arm64-v8a为构建64位的目录,armeabi-v7a为构建32位的目录),执行结果如图所示 + +```shell + cd /data/tpc_c_cplusplus/thirdparty/bullet3-3.22/arm64-v8a-build/ + ./ctest +``` + ![bullet3_test](pic/bullet3_test.png) + +## 参考资料 + +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) \ No newline at end of file diff --git a/thirdparty/bullet3-3.22/docs/pic/bullet3_install_dir.png b/thirdparty/bullet3-3.22/docs/pic/bullet3_install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..ce5b1ef256b6a9e8ee6b6bf855977c3fae8e6b1c Binary files /dev/null and b/thirdparty/bullet3-3.22/docs/pic/bullet3_install_dir.png differ diff --git a/thirdparty/bullet3-3.22/docs/pic/bullet3_test.png b/thirdparty/bullet3-3.22/docs/pic/bullet3_test.png new file mode 100644 index 0000000000000000000000000000000000000000..94fa9ed5dbdee850225239180b637e4f76e508a4 Binary files /dev/null and b/thirdparty/bullet3-3.22/docs/pic/bullet3_test.png differ