<commit_before>#include <game-objects/Rope.h>
#include <components/PhysicsComponent.h>
#include <components/Texcoords.h>
#include <components/SplitDirectionComponent.h>

class Rope::RopeImpl {

public:
	RopeImpl() {
	}

	~RopeImpl() {
	}

	b2RopeJointDef m_ropeDef;
	b2Joint* m_rope;

	void createRope(b2World& m_world, anax::World& anaxWorld) {
		b2Body* ground = NULL;
		{
			b2BodyDef bd;
			ground = m_world.CreateBody(&bd);
			bd.position = b2Vec2(40.0f, 10.0f);
			b2EdgeShape shape;
			shape.Set(b2Vec2(40.0f, 10.0f), b2Vec2(80.0f, 10.0f));
			ground->CreateFixture(&shape, 0.0f);
		}

		{
			b2PolygonShape shape;
			shape.SetAsBox(0.5f, 0.125f);

			b2FixtureDef fd;
			fd.shape = &shape;
			fd.density = 20.0f;
			fd.friction = 0.2f;
			fd.filter.categoryBits = 0x0001;
			fd.filter.maskBits =  ~0x0003;

			b2RevoluteJointDef jd;
			jd.collideConnected = false;

			const int32 N = 30;
			const float32 y = 5.0f;
			m_ropeDef.localAnchorA.Set(0.0f, y);

			b2Body* prevBody = ground;
			for (int32 i = 20; i < N; ++i) {
				b2BodyDef bd;
				bd.type = b2_dynamicBody;
				bd.position.Set(0.5f + 1.0f * i, y);
				if (i == N - 1) {
					shape.SetAsBox(1.5f, 1.5f);
					fd.density = 1.0f;
					fd.filter.maskBits = 0x0003;
					bd.position.Set(1.0f * i, y);
					bd.linearDamping = 10.0f;
					bd.angularDamping = 100.0f;
				}

				b2Body* body = m_world.CreateBody(&bd);

				body->CreateFixture(&fd);

				auto objectEntity = anaxWorld.createEntity();
				auto& texCoordsComp = objectEntity.addComponent<Texcoords>();
				auto& physComp = objectEntity.addComponent<PhysicsComponent>();
				auto& splitDirectionComp = objectEntity.addComponent<SplitDirectionComponent>();

				b2Vec2 anchor(float32(i), y);
				jd.Initialize(prevBody, body, anchor);
				m_world.CreateJoint(&jd);

				physComp.physicsBody = body;

				objectEntity.activate();
				prevBody = body;
			}<commit_msg>Improved rope object<commit_after>#include <game-objects/Rope.h>
#include <components/PhysicsComponent.h>
#include <components/Texcoords.h>
#include <components/SplitDirectionComponent.h>

class Rope::RopeImpl {

public:
	RopeImpl() {
	}

	~RopeImpl() {
	}

	b2RopeJointDef m_ropeDef;
	b2Joint* m_rope;

	void createRope(b2World& m_world, anax::World& anaxWorld) {
		b2Body* ground = NULL;
		{
			b2BodyDef bd;
			bd.type = b2_staticBody;
			bd.position = b2Vec2(20.0f, 0.0f);
			b2PolygonShape shape;
			shape.SetAsBox(2.0f, 0.5f);
			b2FixtureDef fd;
			fd.shape = &shape;
			ground = m_world.CreateBody(&bd);
			ground->CreateFixture(&fd);
		}

		{
			b2PolygonShape shape;
			shape.SetAsBox(0.1f, 0.5f);

			b2FixtureDef fd;
			fd.shape = &shape;
			fd.density = 20.0f;
			fd.friction = 0.2f;
			fd.filter.categoryBits = 0x0001;
			fd.filter.maskBits =  ~0x0003;

			b2RevoluteJointDef jd;
			jd.collideConnected = false;

			const int32 N = 10;
			const float32 x = 20.0f;
			m_ropeDef.localAnchorA.Set(0.0f, x);

			b2Body* prevBody = ground;
			for (int32 yVal = 0; yVal < N; ++yVal) {
				b2BodyDef bd;
				bd.type = b2_dynamicBody;
				bd.position.Set(x,  yVal);
				if (yVal == N - 1) {
					shape.SetAsBox(1.5f, 1.5f);
					fd.density = 1.0f;
					fd.filter.maskBits = 0x0003;
					bd.position.Set(x,   yVal);
//					bd.linearDamping = 2.0f;
//					bd.angularDamping = 10.0f;
					//bd.fixedRotation = true;
				}

				b2Body* body = m_world.CreateBody(&bd);

				body->CreateFixture(&fd);

				auto objectEntity = anaxWorld.createEntity();
				auto& texCoordsComp = objectEntity.addComponent<Texcoords>();
				auto& physComp = objectEntity.addComponent<PhysicsComponent>();
				auto& splitDirectionComp = objectEntity.addComponent<SplitDirectionComponent>();

				b2Vec2 anchor(x, float32(yVal) - 0.5f);
				jd.Initialize(prevBody, body, anchor);
				m_world.CreateJoint(&jd);

				physComp.physicsBody = body;

				objectEntity.activate();
				prevBody = body;
			}
{'fraction_non_alphanumeric': 0.1413071557737019, 'fraction_numerical': 0.04779126840609661, 'mean_word_length': 3.269018743109151, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3918352', 'n_tokens_mistral': 1908, 'n_tokens_neox': 1534, 'n_words': 271}