{"id":15051862,"url":"https://github.com/vokegpu/bicudo","last_synced_at":"2025-04-10T03:07:18.921Z","repository":{"id":256119391,"uuid":"853841180","full_name":"vokegpu/bicudo","owner":"vokegpu","description":"Separation Axis Theorem (SAT) physics engine library accelerated via GPGPU API (ROCm/OpenCL/CUDA) / or CPU-side","archived":false,"fork":false,"pushed_at":"2024-11-21T23:00:18.000Z","size":1609,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-02T18:34:37.899Z","etag":null,"topics":["opengl","opengl4","physics","physics-2d","physics-simulation","rocm","rocm-kernel","sat","sdl","separation-axis-theorem"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vokegpu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-07T17:24:00.000Z","updated_at":"2024-11-21T23:00:22.000Z","dependencies_parsed_at":"2024-09-18T07:37:35.260Z","dependency_job_id":"ac8942cc-0037-4150-8b0f-5fd8d636d189","html_url":"https://github.com/vokegpu/bicudo","commit_stats":{"total_commits":70,"total_committers":2,"mean_commits":35.0,"dds":"0.22857142857142854","last_synced_commit":"5127cda81e97bf04dc05b7d907c9edbf92d1f97c"},"previous_names":["vokegpu/bicudo"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vokegpu%2Fbicudo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vokegpu%2Fbicudo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vokegpu%2Fbicudo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vokegpu%2Fbicudo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vokegpu","download_url":"https://codeload.github.com/vokegpu/bicudo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239126447,"owners_count":19586097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["opengl","opengl4","physics","physics-2d","physics-simulation","rocm","rocm-kernel","sat","sdl","separation-axis-theorem"],"created_at":"2024-09-24T21:37:04.379Z","updated_at":"2025-02-16T11:32:12.659Z","avatar_url":"https://github.com/vokegpu.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bicudo 🐤\n\nBicudo is a physics engine library being develop to process Separation Axis Theorem (SAT) and Newton's laws under GPU via an GPGPU API (ROCm/HIP, OpenCL, CUDA/HIP). The project contains an optionally client called Meow OpenGL-4 based to test the library.\n\nThe name \"Bicudo\" refers to a baby chick I had some years ago, but 🐤 died... then I named this project as Bicudo! 💕\n\n---\n\n# Getting Started 😊\n\nBicudo library is a multi-API GPU-accelerated physics engine, bellow the supported APIs but you are able to use CPU-side too.\n\n| API | Support | OS |\n| --- | --- | --- |\n| [ROCm/HIP](https://github.com/ROCm/HIP) | Buildable, Bad Performance | Windows \u0026 Linux |\n| [OpenCL](https://github.com/KhronosGroup/OpenCL-SDK) | ? | ? |\n| [CUDA/HIP](https://github.com/ROCm/HIP) | ? | ? |\n\nROCm is the priority, however it is only supported by RX series 6000 or higher. OpenCL must be implemented when the ROCm implementation be totally stable, safe and high-performance.\n\n### Linker 🐈\n\nBicudo must be linked after all libraries, for example `-letc -lamdgpu64 -lbicudo`.\n\n### Application-Implementation 🐈‍⬛\n\nBicudo is hardware-interface based, which means that you need by application initialize the API you want to use.\n\nFor example CPU-side only.\n```C++\n#include \u003cbicudo/bicudo.hpp\u003e\n\nbicudo::runtime bicudo_runtime {\n  .gravity = {}, // by default is 0.0 (x and y)\n  .physics_runtime_type = bicudo::physics_runtime_type::CPU_SIDE\n};\n\nbicudo::init(\u0026bicudo_runtime);\n```\n\nFor example ROCm/HIP API:\n```C++\n#include \u003cbicudo/bicudo.hpp\u003e\n#include \u003cbicudo/api/rocm.hpp\u003e\n\nbicudo::runtime bicudo_runtime {\n  .gravity = {}, // by default is 0.0 (x and y)\n  .physics_runtime_type = bicudo::physics_runtime_type::GPU_ROCM,\n  .p_rocm_api = new bicudo::api::rocm()\n};\n\nbicudo::init(\u0026bicudo_runtime);\n```\n\nRunning Bicudo is simple, be sure the application is calculating correctly the delta time.\n\nCalling `bicudo::update(bicudo::runtime *p_runtime)` update position and process collision resolution.  \n```C++\n// any framework media layer initialization\n// bicudo initialization\n\nwhile (mainloop) {\n  bicudo::dt = 0.16f; // 60fps\n  bicudo::update(\u0026bicudo_runtime);\n  bicudo::log::flush(); // flush log\n\n  // etc render\n}\n```\n\nAlternatively there are two separate functions to update each physic step:  \n-- `bicudo::update_position(bicudo::runtime *p_runtime, bicudo::physics::placement *p_placement)`  \n-- `bicudo::update_collision(bicudo::runtime *p_runtime)`\n\n```C++\n// any framework media layer initialization\n// bicudo initialization\n\nwhile (mainloop) {\n  bicudo::dt = 0.16f; // 60fps\n\n  for (bicudo::physics::placement *\u0026p_placements : bicudo_runtime.placement_list) {\n    bicudo::update_position(\n      \u0026bicudo_runtime,\n      p_placements\n    );\n  }\n\n  bicudo::update_collisions(\n    \u0026bicudo_runtime\n  );\n\n  bicudo::log::flush(); // flush log\n\n  // etc render\n}\n```\n\nRendering is application-side, Bicudo does not provide any rendering engine, only geometry data. All meshes are rotated but it is not the most efficient method send it all to the GPU, so on render application must calculate rotation using an Euller rotation-matrix or some other way.\n\n```C++\nbicudo::vec4 rect {};\nfor (bicudo::physics::placement *\u0026p_placements : bicudo_runtime.placement_list) {\n  rect.x = p_placements-\u003epos.x;\n  rect.y = p_placements-\u003epos.y;\n  rect.z = p_placements-\u003esize.x;\n  rect.w = p_placements-\u003esize.y;\n\n  if (!bicudo::vec4_collide_with_vec4(rect, my_camera_rect)) {\n    continue; // frustum clip\n  }\n\n  bicudo::mat4 mat4x4_rotate = bicudo::mat4(1.0f);\n\n  if (!bicudo::assert_float(p_placement-\u003eangle, 0.0f)) {\n    bicudo::vec2 center {\n      rect.x + (rect.z / 2), rect.y + (rect.w / 2)\n    };\n\n    mat4x4_rotate = bicudo::translate(mat4x4_rotate, center);\n    mat4x4_rotate = bicudo::rotate(mat4x4_rotate, {0.0f, 0.0f, 1.0f}, -p_placement-\u003eangle);\n    mat4x4_rotate = bicudo::translate(mat4x4_rotate, -center);\n  }\n\n  // do render etc\n}\n```\n\n### Placement 🐮\n\nInsert placements objects by function `bicudo::insert(bicudo::physics::placement *p_placement)`, the object physic properties is application-side.\n\n```C++\nbicudo::insert(\n  new bicudo::physics::placement {\n    .p_tag = \"cow\",\n    .mass = 2000.0f, // for infinity mass set to 0.0 (no gravity effect).\n    .friction = 0.8f, // min 0.0 max 1.0\n    .restitution = 1.0f, // min 0.0 max 1.0\n    .inertia = 0.2f, // min 0.0 max 1.0\n    .pos = {20, 20},\n    .size = {96, 96}\n  }\n);\n```\n\n### Events Callback 🧼\n\nBicudo offers two events callback for invoke on collision, an pre collision before apply physics forces and an after.\n\n```C++\nvoid on_collision_pre_apply_forces(\n  bicudo::physics::placement *\u0026p_a,\n  bicudo::physics::placement *\u0026p_b\n) {\n  bicudo::log() \u003c\u003c \"pre-forces: \" \u003c\u003c p_a-\u003ep_tag \u003c\u003c \" x \" \u003c\u003c p_b-\u003ep_tag;\n  p_a-\u003evelocity = {}; // you are able to modify the forces here\n}\n\nvoid on_collision(\n  bicudo::physics::placement *\u0026p_a,\n  bicudo::physics::placement *\u0026p_b\n) {\n  bicudo::log() \u003c\u003c \"after forces: \" \u003c\u003c p_a-\u003ep_tag \u003c\u003c \" x \" \u003c\u003c p_b-\u003ep_tag;\n  p_a-\u003evelocity = {}; // you are able to modify the forces here too\n}\n\nbicudo_runtime.p_on_collision_pre_apply_forces = \u0026on_collision_pre_apply_forces;\nbicudo_runtime.p_on_collision = \u0026on_collision;\n```\n\n---\n\n# Bicudo Building 🔧🐤\n\nBicudo library requires all the three APIs include dir (ROCm/HIP, OpenCL, CUDA/HIP). For now only [ROCm/HIP](https://github.com/ROCm/HIP).  \nInstall the ROCm-SDK, for Windows download the official AMD installer, for Linux run command from the package manager.\n\nFor CMake building on Linux:\n```sh\ncmake -S . -B ./cmake-build-debug -G Ninja\ncmake --build ./cmake-build-debug\n```\n\nWindows:\n```sh\ncmake -S . -B ./cmake-build-debug -G Ninja -DHIP_PATH=\"/path-to-rocm-dir/AMD/ROCm/x.x/\"\ncmake --build ./cmake-build-debug\n```\n\nOutputs: `/lib/windows/libbicudo.a`, `/lib/linux/libbicudo.a`\n\n# Meow Building 🔧🐱\n\nMeow is the graphical application used to test and showcase the Bicudo engine. It is not necessary, you can skip if you want.\n\nFor building Meow you must download all these libraries:  \n[EKG GUI Library](https://github.com/vokegpu/ekg-ui-library)  \n[FreeType](http://freetype.org/)  \n[SDL2](https://www.libsdl.org/)  \n[ROCm/HIP](https://github.com/ROCm/HIP)  \n[GLEW](https://glew.sourceforge.net/)  \n\nAnd a GCC/Clang compiler.\nRun the following command:\n\n```sh\ncd ./meow # Meow is a sub-folder in this project\n\ncmake -S . -B ./cmake-build-debug/ -G Ninja\ncmake --build ./cmake-build-debug/\n```\n\nOutputs: `./meow/bin/meow`, `./meow/bin/meow.exe`\n\n# Thanks 💕\n\nMichael Tanaya (Author), Huaming Chen (Author), Jebediah Pavleas (Author), Kelvin Sung (Author); of book [Building a 2D Game Physics Engine: Using HTML5 and JavaScript](https://www.amazon.com/Building-Game-Physics-Engine-JavaScript/dp/1484225821) 😊🐄\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvokegpu%2Fbicudo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvokegpu%2Fbicudo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvokegpu%2Fbicudo/lists"}