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

Fix Bullet Physics Server #47508

Closed
wants to merge 5 commits into from
Closed

Fix Bullet Physics Server #47508

wants to merge 5 commits into from

Conversation

kalysti
Copy link
Contributor

@kalysti kalysti commented Mar 30, 2021

Bullet2 physics compatibility for to new rendering server api in godot 4. Only small changes were necessary.

image

Next step: PhysX Integration (in progress)

@aaronfranke
Copy link
Member

Next step: PhysX Integration (in progress)

IIRC the plan was to have support for pluggable physics engines via GDNative, so integrating more physics engines into core likely is not desired.

@kalysti
Copy link
Contributor Author

kalysti commented Mar 30, 2021

Next step: PhysX Integration (in progress)

IIRC the plan was to have support for pluggable physics engines via GDNative, so integrating more physics engines into core likely is not desired.

Does not matter. Then I deliver it as a gd native module. I am currently at around 75% and I will be finished by the end of the week and will start the first tests. But I think that in the long term bullet should be replaced anyway.

@aaronfranke
Copy link
Member

@sboronczyk It does matter, because even if a feature is fully 100% implemented and working, it may not actually be desired to be merged into the engine. In general, if a big feature hasn't been approved by a core maintainer, a PR for it will be ignored.

@kalysti
Copy link
Contributor Author

kalysti commented Mar 30, 2021

@sboronczyk It does matter, because even if a feature is fully 100% implemented and working, it may not actually be desired to be merged into the engine. In general, if a big feature hasn't been approved by a core maintainer, a PR for it will be ignored.

Okay. Not important to me though. I need PhysiX for my purposes and of course I like to share it with the community (whether it will be delivered as a core module or as a GDNative module is another question). If a core mantainer thinks it makes sense, that would of course be so much the better. But back to the topic :-) Thats PR is only for the bullet physics. We can talk about it further via discord. greetings sj

@BastiaanOlij
Copy link
Contributor

@sboronczyk It does matter, because even if a feature is fully 100% implemented and working, it may not actually be desired to be merged into the engine. In general, if a big feature hasn't been approved by a core maintainer, a PR for it will be ignored.

But it can still be tested and evaluated and used by people and thus gain useful insights for a better implementation down the road.
Just because it is never merged because the long term plans require a different implementation isn't good enough reason to tell people not to even bother.

@kalysti
Copy link
Contributor Author

kalysti commented Mar 31, 2021

Thank you guys for your different opinions. But we should keep the PR free for important questions about the request and not talk about other PRs or projects. I think that's just confusing :-)

Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! The plan is to move Bullet to a separate plugin, but in the meantime it's good to have it working again, and these changes would be needed anyway.

I haven't tested yet. For info, you can use this test suite to check for regression and test with multi-threaded configuration:
https://github.com/godotengine/godot-demo-projects/tree/master/3d/physics_tests

doc/classes/ProjectSettings.xml Outdated Show resolved Hide resolved
modules/bullet/area_bullet.cpp Outdated Show resolved Hide resolved
modules/bullet/area_bullet.cpp Outdated Show resolved Hide resolved
modules/bullet/area_bullet.cpp Outdated Show resolved Hide resolved
modules/bullet/bullet_physics_server.cpp Outdated Show resolved Hide resolved
modules/bullet/constraint_bullet.h Outdated Show resolved Hide resolved
modules/bullet/register_types.cpp Outdated Show resolved Hide resolved
modules/bullet/register_types.cpp Outdated Show resolved Hide resolved
modules/bullet/space_bullet.cpp Outdated Show resolved Hide resolved
modules/bullet/space_bullet.h Outdated Show resolved Hide resolved
@kalysti
Copy link
Contributor Author

kalysti commented Apr 14, 2021

Okai tomorrow i will start to check and round the pr up.

@kalysti kalysti requested review from a team as code owners April 22, 2021 03:53
modules/bullet/area_bullet.h Outdated Show resolved Hide resolved
doc/classes/ProjectSettings.xml Outdated Show resolved Hide resolved
modules/bullet/bullet_physics_server.cpp Outdated Show resolved Hide resolved
modules/bullet/bullet_physics_server.cpp Outdated Show resolved Hide resolved
modules/bullet/bullet_physics_server.cpp Outdated Show resolved Hide resolved
modules/bullet/bullet_physics_server.h Show resolved Hide resolved
modules/bullet/register_types.cpp Outdated Show resolved Hide resolved
modules/bullet/register_types.cpp Outdated Show resolved Hide resolved
modules/bullet/space_bullet.h Outdated Show resolved Hide resolved
modules/bullet/space_bullet.cpp Outdated Show resolved Hide resolved
@akien-mga
Copy link
Member

You mention "Bullet3", but I don't see any changes to the modules/bullet/SCsub so I think it's still using the Bullet2 API, no?
(See Bullet3Dynamics vs BulletDynamics in thirdparty/bullet, and other related Bullet3 vs Bullet folders - we only compile the Bullet ones, albeit they do include a couple shared headers from the AFAIK never finished Bullet3 API.)

Once this is ready, please remember to squash the commits into one, as the history of whitespace fixes in PRs is not relevant to the engine's Git history.

@kalysti
Copy link
Contributor Author

kalysti commented Apr 22, 2021

You mention "Bullet3", but I don't see any changes to the modules/bullet/SCsub so I think it's still using the Bullet2 API, no?
(See Bullet3Dynamics vs BulletDynamics in thirdparty/bullet, and other related Bullet3 vs Bullet folders - we only compile the Bullet ones, albeit they do include a couple shared headers from the AFAIK never finished Bullet3 API.)

Once this is ready, please remember to squash the commits into one, as the history of whitespace fixes in PRs is not relevant to the engine's Git history.

sorry my mistake. of course it's bullet 2 (I assumed that godot is already using bullet3). but i can extend it to bullet 3 (but guess that will cause more problems than fix). I therefore recommend changing the whole thing to bullet 3 when bullet is delivered as a native plugin. your decision!

@pouleyKetchoupp pouleyKetchoupp changed the title Add bullet 3 physics to godot 4 Fix Bullet Physics Server Apr 22, 2021
@pouleyKetchoupp
Copy link
Contributor

@sboron There's no plan to update Bullet. I've updated the PR title to reflect more accurately what it does.

@kalysti
Copy link
Contributor Author

kalysti commented Apr 22, 2021

@sboron There's no plan to update Bullet. I've updated the PR title to reflect more accurately what it does.

Okai sorry for the misscommunication.

@kalysti
Copy link
Contributor Author

kalysti commented Apr 22, 2021

I compressed all commits into one and adjusted the commit name. Changes are included (except for the unresolved ones).

kalysti and others added 3 commits April 23, 2021 02:00
fix whitespaces :-)

Remove whitespaces

Fix whitespaces

fix whitespaces space_bullet.h

cleanup

cleanup

Add bullet2 to godot4

fix wrong line
@akien-mga
Copy link
Member

Nitpick but I'd suggest using "Fix and re-enable Bullet physics for 4.0" instead of "Add bullet 2 physics to godot 4". The latter sounds like you're adding a full blown implementation of bullet2 for Godot, which we've already had since Godot 3.0, but it was disabled a couple of months ago during API changes.

Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've stopped reviewing when I've found again some conversations marked as resolved without the comments being addressed.

I'm not going to spend extra time reviewing the same things over and over again, so you need to stop doing that. Make sure you address all the comments that were made before, including conversations you've closed, and answer to them if you don't agree, and then you can request another review.

Edit: The general idea behind lots of my comments is, this PR is meant to make the Bullet server work again, but it doesn't need to entirely match headers from Godot Physics when not needed. Each server implementation has some specific variations, and it's not needed to copy all methods and members over just for the sake of making things identical.

for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
overlappingObjects[i].object->on_exit_area(this);
overlappingObjects.write[i].object->on_exit_area(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.write doesn't seem to be needed here and is going to cause unnecessary copies.

@@ -139,6 +140,9 @@ class AreaBullet : public RigidCollisionObjectBullet {
_FORCE_INLINE_ void set_spOv_priority(int p_priority) { spOv_priority = p_priority; }
_FORCE_INLINE_ int get_spOv_priority() { return spOv_priority; }

_FORCE_INLINE_ void set_priority(int p_priority) { priority = p_priority; }
_FORCE_INLINE_ int get_priority() const { return priority; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods and the priority member are not needed, they are not used anywhere.

BulletPhysicsServer3D::BulletPhysicsServer3D(bool p_using_threads) {
using_threads = p_using_threads;
active = true;
doing_sync = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

active and doing_sync are already initialized in the header, they don't need to be set here.

mutable RID_PtrOwner<RigidBodyBullet> rigid_body_owner;
mutable RID_PtrOwner<SoftBodyBullet> soft_body_owner;
mutable RID_PtrOwner<JointBullet> joint_owner;
Set<SpaceBullet *> active_spaces;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was marked as resolved, but wasn't addressed.

@Blackiris
Copy link
Contributor

Sorry to bump on it, is there any way to help unlock this PR?

I have tried this branch and except some conflict because of some API changes (Transform -> Transform3D, PhysicsServer3D::MODE_DYNAMIC_LOCKED -> PhysicsServer3D::BODY_MODE_DYNAMIC_LOCKED...)

Just got a crash on the editor side that is easy to fix, but otherwise, the main features are mostly back (need to check the constraints maybe).

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

Successfully merging this pull request may close these issues.

8 participants