Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removeShape (RigidBody.hx) - Error #51

Closed
Snky opened this issue Jul 16, 2022 · 3 comments
Closed

removeShape (RigidBody.hx) - Error #51

Snky opened this issue Jul 16, 2022 · 3 comments
Labels

Comments

@Snky
Copy link

Snky commented Jul 16, 2022

	public function removeShape(shape:Shape):Void {
		// first, remove the shape from the linked list so that it will be ignored
		M.list_remove(_shapeList, _shapeListLast, _prev, _next, shape);
		_numShapes--;
		shape._rigidBody = null;

		// then remove the shape from the world
		if (_world != null) {
			_world._removeShape(shape);
		}

		_shapeModified();
	}

Should shape._rigidBody = null go (after) before _shapeModified();?
As _world.removeShape(shape); requires shape._rigidBody(NULL)._contactLinkList

@Dev-MarkoF
Copy link

Dev-MarkoF commented Jul 18, 2022

It's a bug, which i mentioned years ago, when i needed scaling bodies at runtime, but it seems it did not get fixed.
Just move the shape._rigidbody = null, below the if statement and there is no error.
I didn't notice any unwated side effects, by doing so, it now works like i think it is intended.

@saharan saharan added the bug label Oct 14, 2022
@saharan
Copy link
Owner

saharan commented Oct 14, 2022

Yes, you're right, the shape should firstly be removed from the world. Thank you for reporting, I'll fix it.

saharan added a commit that referenced this issue Oct 14, 2022
@saharan
Copy link
Owner

saharan commented Oct 14, 2022

Fixed in Release 1.2.4

@saharan saharan closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants