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

(Motor Bug) Joints cannot be removed if not on DEBUG mode #36

Open
nebular opened this issue Jul 21, 2024 · 1 comment
Open

(Motor Bug) Joints cannot be removed if not on DEBUG mode #36

nebular opened this issue Jul 21, 2024 · 1 comment

Comments

@nebular
Copy link

nebular commented Jul 21, 2024

So if you add a joint with "debug" turned off

  • no jointdebug is created in thre world
  • joint is added to the physics motor (root.post...)

When removing this joint, phy.remove(joint.name) --- the routine in Motor will do nothing, as phy.byName() returns null - however the joint is kept alive in the worker.

This causes many nasty bugs - for example

  • if you remove any object part of the joint, the worker (physx at least) will later crash on stepItems (when attempting to call getGlobalPose() on the existing joints, but their objects do not exist.

  • if joints belong to instancemeshes and instances are removed, joints are kept alive and sometimes point to the wrong instance, resulting in funny joints between incorrect objects in the scene

After that crash, worker must be restarted.

My temp fix:

	// RLP: SEND ALWAYS TO MOTOR to remove non-exising joints
	static remove(name, direct = false, physicsType = "joint") {

		if (name.constructor === Array) return Motor.removes(name, direct);

		let b = Motor.byName(name);

		if (b) {

			// remove on three side

			if (b.extraRemove) b.extraRemove();
			ITEM_LIBRARY[b.type].clear(b);

		}

		const objectType = b ? b.type : physicsType;

		// remove on physics side
		if (objectType) root.post({ m: "remove", o: { name: name, type: objectType } }, null, direct);

	}

So when removing joints, I call remove(jointName, false, "joint") - or remove(jointName, false) as physicsType is set to joint. It's not the most elegant but it works well.

@lo-th
Copy link
Owner

lo-th commented Jul 22, 2024

mm yep i have to make research about that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants