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

[Physics] Bepu integration #2131

Open
wants to merge 450 commits into
base: master
Choose a base branch
from
Open

Conversation

Eideren
Copy link
Collaborator

@Eideren Eideren commented Jan 28, 2024

PR Details

Adds support for Bepu Physics as an alternative physics engine, we'll keep the current one but will move our focus towards this new one instead.

Motivation

Unified ecosystem, improved performance, flexibility and debugging experience compared to Bullet's physics engine.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

WIP

  • Navigation - @Doprez is taking care of that part
  • Replace car asset
  • Add license above all files
  • Check that physics does not occur between input sampling and update ... ensures that update receives the most up to date inputs
  • Deal with the last few outstanding warnings
  • Split softbodies into a future PR
  • Ask if Norbo is available to check some areas that could be improved
  • Scaling / sharing issue with hulls
  • Check if gizmos for hull are working properly
  • Gizmos for box collider seem to ignore local pos ?
  • Constraints detach from colliders after changing mass

Post release

  • Query mesh material index from physics tests
  • Ragdoll utilities
  • Ignore contact between specific objects, contact response utilities
  • Wider support of the different mesh formats (ExtractBepuMesh)

A huge thanks goes to @Nicogo1705 and @Doprez for working on this. As well as @RossNordby for Bepu and dealing with our nonsense.

N.B.: PR #2127 and #2120 were cherry-picked to support this PR.

COMMIT HISTORY HAS BEEN PRESERVED, DO NOT SQUASH OR REBASE - JUST MERGE

@Eideren Eideren changed the title [WIP][Physics] Bepu integration [Physics] Bepu integration Feb 8, 2024
using SRigidPose = Stride.BepuPhysics.Definitions.RigidPose;

using NBodyVelocity = BepuPhysics.BodyVelocity;
using BBodyVelocity = BepuPhysics.BodyVelocity;
using SBodyVelocity = Stride.BepuPhysics.Definitions.BodyVelocity;

using System.Runtime.CompilerServices;


internal static class BepuAndStrideExtensions
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these are dealing with System.Numerics and Stride.Math should this be added directly to the Stride math library? I feel like these would be useful in many places not only Bepu.

Copy link
Contributor

Choose a reason for hiding this comment

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

Some of these seem to already exist in the 3d importer as well

public static class Utils

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, feel free to open a PR for that :P

@Doprez
Copy link
Contributor

Doprez commented Apr 6, 2024

I was trying to use your branch locally but I cant seem to resolve the nugets to the demo project, am I missing a step?
image

@Doprez
Copy link
Contributor

Doprez commented Apr 6, 2024

I was trying to add configuration and the drop down seems to not show up.

I also cant build the project due to the previous error of not being able to find the 4.2.0.1 version from the compilerapp.

I am not sure if both are related but it seems like its just some build process that is missing.

adding components seem to work normally compared to the repo from Nicogo.

@Eideren
Copy link
Collaborator Author

Eideren commented Apr 6, 2024

Forgot to mention that nonsense, there is a ridiculous workaround in place because central package management is still an incomplete often buggy mess.
The issue goes something like this; Demo should behave like a normal stride game solution, so instead of referencing the engine projects, like other solutions in the engine, it references the packages of the engine, those packages must be the local ones to ensure that we catch changes the user made to the engine locally.
Previously this worked fine, but under central package management, we must add a package source to reference local packages. Obviously this is just for one specific project, so I shouldn't add it to the global one. Given that, here's what I tried:

  • <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
  • Adding a Directory.Packages.props to a sub-directory to override the global one.

It either only works on clean builds or is just ignored entirely.

So, what you should be doing is build all projects in build\Stride.sln then open sources\engine\Stride.BepuPhysics\Stride.BepuPhysic.Demo.sln in another VS instance and build/run it there ...

If someone want to take a look at this feel free to do so, I just don't have the patience to deal with nuget's garbage anymore.

Doprez and others added 8 commits April 9, 2024 15:16
* Remove docs, has been moved to Stride docs repo

* [OpenXR] Fixes build on graphics APIs other than D3D11

This build regression was introduced by previous commit d72aef5

* Update samples to Stride 4.2 (stride3d#2132)

* [Samples] Update to 4.2

* [Samples] Remove Newtonsoft.Json dependency in CSharpIntermediate

* [Tests] Fixes random test failures (stride3d#2133)

* [Tests] Fixes random test failures

Some of the tests in Stride.GameStudio.Tests must not run in parallel as they access a shared class which is not thread safe.

* Sets wait time in TestFileVersionManager to 500ms (from 200)

Should make it less likely that unit tests on teamcity fail.

* Repair projectwatcher (stride3d#2106)

* use positive 77

* repair projectwatcher

* remove unused line

* undo -77 change

* undo -77

* order usings

* fix formatting

* remove unused solution

* remove unused async

* use previous cancelation method

* remove extra task

* add check to not throw assembly changes away

* rework distribution of assemblychanges

* remove unused using

* add broadcast back in

* remove assembly broadcast

* add cancelation

* replace cancelation location

* improve if nesting

* improve naming, fix reload on new references

* fix loading chain of assets

* refactor

* [Editor] Refactor initialization of CodeViewModel

---------

Co-authored-by: IXLLEGACYIXL <ixllegacy123@outlook.com>
Co-authored-by: Nicolas Musset <musset.nicolas@gmail.com>

* [OpenVR] Adds a minimal API to request and control Passthrough (supported by OpenXR)

https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_FB_passthrough

* [OpenXR] Makes device construction internal and improves exception messages of new StartPassthrough method

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* [Assets] Prevent crash of the assets compiler when an assembly cannot be fully loaded. (stride3d#2144)

Fixes stride3d#2140

* [Build] Remove stylecop (stride3d#2105)

Co-authored-by: IXLLEGACYIXL <ixllegacy123@outlook.com>

* [Presentation] Rework AssetViewModelAttribute

* [Editor] Cleanup

* [Assets] Mark Editor as obsolete on AssetViewModel

* [Editor] Make Asset property public on all editors

* [Editor] Make IAssetEditorsManager a service

* [Editor] Keep track of asset/editor association in AssetEditorsManager

* [Editor] Add a method to find an opened editor

* [Editor] Change binding logic in editor views

The default DataContext is now the editor instead of the asset

* [Editor] Update sprite editor bindings

* [Editor] Update UI editor bindings

* [Editor] Update entity hierarchy editor bindings

* [Editor] Update script editor bindings

* [Editor] Update graphics compositor editor bindings

* [Editor] Removed pointless constraint on column width

Which is also spamming the console with binding errors.

* [Editor] Remove editor-related properties from AssetViewModel

* [Editor] Rework AssetEditorViewModelAttribute

- add AssetEditorViewAttribute
- rework view creation and initialization

* [Editor] Make AssetEditorViewModel.Asset property virtual

C# has covariant return types since version 9

* [Editor] Rework plugins initialization

* [Editor] Rework AssetPreviewViewModelAttribute & AssetPreviewAttribute

- add AssetPreviewViewAttribute to break the dependency between a preview and its UI-dependent view

* [Editor] Fix initialization of SpriteSheetEditorViewModel returning false

* [Editor] Make Stride.Core.Presentation.Quantum cross-platform

* [Editor] Make Stride.Core.Assets.Quantum cross-platform

* [Editor] Do not load StrideDefaultAssetsPlugin from module.

It currently hardcodes loading the templates from a package which causes some tests to fail.

Partially reverts c98c72e

* feat: Release.yml added for PR categorisation (stride3d#2137)

* feat: Release.yml added for PR categorisation

* Categories updated

* [Editor] Fix scene editor loading screen

* [VR] feat: Add haptic support to OpenVR and Oculus runtimes (stride3d#2169)

Co-authored-by: Eideren <contact@eideren.com>

* [Audio] Audio emitter multiple references to same asset bugfix (stride3d#2176)

Co-authored-by: Eideren <contact@eideren.com>

* Use correct destination path in asset import overwrite dialog

* Use GetFullPath to correct directory seperator for display

* fix: File GraphicsResourceMap.cs without references removed (stride3d#2181)

* feat: Update samples/template to top-level statements (stride3d#2187)

* Update README.md (prerequisites)

* Update README.md (VSIX prerequisites)

* [VSPackage] Revert a few package upgrades so that VSIX builds properly

* [Presentation] Fix issue with binding quantum nodes when associated name is not found (stride3d#2195)

Note: the solution is rather hackish at the moment. To be revisited once we have an Avalonia version.
Should we then introduce a service for setting/retrieving the Unset value

* fix: [Asset] Unified 3D asset importer (on behalf of Noa7/Noah7071) (stride3d#2163)

Co-authored-by: noa7 <noahwdv@gmail.com>
Co-authored-by: noa7707 <157441788+noa7707@users.noreply.github.com>
Co-authored-by: Noah7071 <157886157+Noah7071@users.noreply.github.com>

---------

Co-authored-by: JornosDesktop <aggror.jorn@gmail.com>
Co-authored-by: Elias Holzer <elias@vvvv.org>
Co-authored-by: Nicolas Musset <nicolas@color-rise.xyz>
Co-authored-by: IXLLEGACYIXL <107197024+IXLLEGACYIXL@users.noreply.github.com>
Co-authored-by: IXLLEGACYIXL <ixllegacy123@outlook.com>
Co-authored-by: Nicolas Musset <musset.nicolas@gmail.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Jorn Theunissen <aggror.jorn@stride3d.net>
Co-authored-by: Marian Dziubiak <marian.dziubiak@gmail.com>
Co-authored-by: Vaclav Elias <vaclavelias@gmail.com>
Co-authored-by: Addison Schmidt <addison@assurancefamily.com>
Co-authored-by: Eideren <contact@eideren.com>
Co-authored-by: Tim Conner <tim@timconner.com>
Co-authored-by: Jakub Ławreszuk <31008367+Jklawreszuk@users.noreply.github.com>
Co-authored-by: xen2 <virgile@stride3d.net>
Co-authored-by: noa7 <noahwdv@gmail.com>
Co-authored-by: noa7707 <157441788+noa7707@users.noreply.github.com>
Co-authored-by: Noah7071 <157886157+Noah7071@users.noreply.github.com>
@Doprez Doprez mentioned this pull request Apr 27, 2024
8 tasks
@delustra
Copy link

Testing the branch, couple of issues surfaced:

  1. Collidable Gizmo doesn't update in the editor when I change the Position of the Body Component.
    gizmo

  2. I have setup a constraint between two bodies. I set new Mass for the collider of one of the bodies. The next frame the constraint looses Constraint.A and Constraint.B and the Body itself looses it's velocity.
    My guess is that in CollidableComponent.cs.

 internal void TryUpdateFeatures()
    {
        if (Simulation is not null)
            ReAttach(Simulation);
    }

the items gets detached from the simulation and then gets attached again. That's where it probably looses all its values.

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

Successfully merging this pull request may close these issues.

None yet

5 participants