{"id":19661091,"url":"https://github.com/sundeepk/splitter","last_synced_at":"2026-05-10T23:36:36.534Z","repository":{"id":149188695,"uuid":"20699910","full_name":"SundeepK/Splitter","owner":"SundeepK","description":"Splitter is a box2d slicing engine used to split shapes into smaller ones","archived":false,"fork":false,"pushed_at":"2015-01-02T20:09:30.000Z","size":24408,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T01:44:00.329Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SundeepK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-10T20:09:54.000Z","updated_at":"2015-01-02T20:09:30.000Z","dependencies_parsed_at":"2023-03-30T17:07:28.988Z","dependency_job_id":null,"html_url":"https://github.com/SundeepK/Splitter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SundeepK%2FSplitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SundeepK%2FSplitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SundeepK%2FSplitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SundeepK%2FSplitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SundeepK","download_url":"https://codeload.github.com/SundeepK/Splitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240970214,"owners_count":19886526,"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":[],"created_at":"2024-11-11T16:06:20.797Z","updated_at":"2026-05-10T23:36:36.506Z","avatar_url":"https://github.com/SundeepK.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Splitter\n========\n\nSplitter is a box2d slicing engine used to split shapes into smaller ones. It comes with a simple texture mapping class that can texture your split shapes for you, given the original box2d body and texture co-ordinates. Also, its under MIT liscence. Still under active development.\n\n\n![ScreenShot](https://raw.githubusercontent.com/SundeepK/Splitter/master/images/splitter_test_image.png)\n\n## Dependencies\nSplitter needs a few things to build and run:\n- C++ compiler (gcc for instance)\n- Opengl\n- SFML\n- Box2d\n- Codeblocks (if you wish to open the project file)\n- coffee\n\n## Build instructions\nTo build the demo sandbox test that comes with Splitter, you will need to do the following:\n\n```bash\n\n/Splitter $ mkdir build\n/Splitter $ cd build/\n/Splitter/build $ cmake ..\n/Splitter/build $ make\n```\nThen simply run the Splitter example.\n\n## Usage\nSplitter extends b2RayCastCallback, so you will only need to perform 2 raycasts to get box2d bodies to split, (Check the example main class for details).\n\n```CPP\n    //example usage\n    Splitter splitter;\n    m_world.RayCast(\u0026splitter, point1, point2);\n    m_world.RayCast(\u0026splitter, point2, point1);\n\n```\n\nSplitter allows you to register both a callback class (which much extend B2BodySplitCallback) or a function to recieve callbacks when a box2d body has been split. You can then use TextureMapper class to get a vector of b2Vecs of your texture coords (see example main for more details). This callback will give you builder objects to which you pass your world to construct your new split Box2d bodies and the original box2d body that was split. Below is a simple example:\n\n```CPP\n\n    //example callback\n    std::vector\u003cb2Body*\u003e bodiesToDelete;\n    splitter.registerBodySplitCallback([\u0026box2dWorld](std::vector\u003cB2BoxBuilder\u003e splitBodies, b2Body* parentBody) -\u003e void {\n       TextureMapper textureMapper(30.0f); //world scale\n       Texcoords *parentBodyTexCoords   = (Texcoords*) parentBody-\u003eGetUserData();\n       std::vector\u003cb2Vec2\u003e texCoords = parentBodyTexCoords-\u003etextCoords;\n       \n        for(auto builder : splitBodies) {\n            b2Body* newSplitBody = builder.build(box2dWorld); //your box2d world\n            Texcoords *texturesForNewBody = new Texcoords();\n            std::vector\u003cb2Vec2\u003e newBodyTexCoords =  textureMapper.mapSplitBody(newSplitBody, parentBody, texCoords);\n            texturesForNewBody-\u003etextCoords = newBodyTexCoords;\n            newSplitBody-\u003eSetUserData(texturesForNewBody);\n        }\n\n        bodiesToDelete.push_back(parentBody); //keep pointers to b2Body to delete at a safe time\n        delete parentBodyTexCoords; \n    });\n\n```\n\nTo use TextureMapper class, you must make sure that the original body was textured correcly before. With it's verticies mapping in the same order as it's texture coordinates.\n\nThat's all there is to it.\n\nThe test texture used in the main example and screenshot is taken from here http://www.isc.tamu.edu/~lewing/linux/index.html. \n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsundeepk%2Fsplitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsundeepk%2Fsplitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsundeepk%2Fsplitter/lists"}