Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

[bug] Static bodies get broken if its transform changed after creation. #8

Closed
RonYanDaik opened this issue Apr 5, 2023 · 0 comments

Comments

@RonYanDaik
Copy link

If you create a body, defining it as static in BodyDef. And then you will try to transform to another position (even slightly), then it becomes completely broken. Collisions mostly stop working. Dynamic bodies don't interact with it, flying through, get pushed in random locations.

But debug draw draws them correctly.

To reproduce use this code for static bodies in Tiles Test:


			float a = 0.5f;
			int32 N = 200;
			int32 M = 10;
			b2Vec2 position;
			position.y = 0.0f;
			for (int32 j = 0; j < M; ++j)
			{
				position.x = -N * a;
				for (int32 i = 0; i < N; ++i)
				{
					b2BodyDef bd;
					bd.position = position;
					b2Body* ground = m_world->CreateBody(&bd);

					b2PolygonShape shape;
					shape.SetAsBox(a, a);
					ground->CreateFixture(&shape, 0.0f);
					++m_fixtureCount;
					position.x += 2.0f * a;
					ground->SetTransform(position+b2Vec2(-1, -1), 0.1);

				}
				position.y -= 2.0f * a;
			}

box2dbug

@RonYanDaik RonYanDaik changed the title [bug] Static bodys get broken if its transform changed after creation. [bug] Static bodies get broken if its transform changed after creation. Apr 5, 2023
@mtsamis mtsamis closed this as completed May 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants