-
-
Notifications
You must be signed in to change notification settings - Fork 957
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
Update BulletSharp to latest version #289
Conversation
I think our version is based on https://github.com/sinkingsugar/BulletSharpPInvoke which was indeed a fork of AndresTraks code. We might also use the mobile version from https://github.com/sinkingsugar/bullet2-sharp-mobile. Maybe kindly ping @sinkingsugar 😄 |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static implicit operator BulletSharp.Math.Matrix(Matrix value) | ||
{ | ||
unsafe { return *(BulletSharp.Math.Matrix*)&value; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at https://github.com/AndresTraks/BulletSharpPInvoke/blob/master/BulletSharp/Math/Matrix.cs#L58
and https://github.com/xenko3d/xenko/blob/master/sources/core/Xenko.Core.Mathematics/Matrix.cs#L64
Xenko has a different memory layout than Bullet (M21 vs M12)
Hmm the API is slightly different, many things were done towards Xenko perf/optimization. This is just a wrapper, not sure you get any benefit by updating it unless the C++ part is also updated ( and has outstanding changes ) So unless the native library is also updated and properly tested on all platforms I would pay attention. |
Well, no idea how I ended up looking at xenko's matrix and miss the difference in their order. Just to clarify, this PR wasn't made just to stay up to date with the wrapper, the main push behind this PR is the fact that the version used within xenko doesn't support multiple features of bullet, the main one being concave mesh collision. From what I gather you guys don't have the sources for the C# and C++ side anymore, I can't do much about that without them so unless you do end up finding them I'll just continue on and we'll see where we end up. |
Sorry, didn't realize you were looking for the old source (esp. after @Kryptos-FR mentionned a repository which was almost the proper one, I thought you had it and were more focusing on how to rebuild from new sources!) Here you go, it was there all along! |
Now I understand better why you did a compare with decompiled code (at first I thought you had the sources but wanted to see everything formatted the same way... should have understood that earlier!) |
BTW, while I still have it on top of my head, some remarks about how those native libs are compiled so far: We were usually building the sources for libbulletc and some other native libraries that needs target OS in manually in various computer/VM (hard for people to do it themselves from scratch since those VM had lot of specific software installed). It would be great if we were switching to something more reproducible and easier to test. That's probably something we should do for all those dependencies that can't be built using our C++ native layer directly in Xenko projects (which support only a very limited subset of the standard library) but instead need to be built on the target OS. |
that is indeed a bit problematic. since directx as well es opengl and i guess bullet have exactly the same memory layout. i wonder what was leading to that decision and which action was taken. my feeling is that there was a couple of wrong assumptions of how matrix transposition and coordinate system handedness works. |
thanks @xen2 , will need some time to get deeper into it. hope i will have time for this soon. |
Hey, thanks a bunch for the source @xen2 , 'BvhTriangleMeshShape' is already implemented on that repo, as well as a ton of other missing classes, could the dll included with xenko be out of date ? |
Doesn't seem to be included in the csproj: |
So, I ended up choosing to work on optimizing the main repo of BulletSharpPInvoke instead of keeping our own up to date, I already have posted a PR over there, we'll see how it works out. All contact data in xenko is in world space right ? |
@Eideren Took a quick look at our code and bullet code and yes, it looks like all |
May want to consider using https://github.com/bepu/bepuphysics2 instead of bullet altogether. |
@GutterLab bepuphysics doesn't look as mature as bullet, from their readme:
|
I'm still working on this but BulletSharpPInvoke's maintainer seems pretty busy right now, we might have to fork it instead, we'll see. |
To chime in on the different engine suggestions, PhysX could be a good consideration too, potentially providing some speedups though GPU support. |
Isn't that only on NVidia graphic cards. If so, we'll have a kind of vendor-lock. |
Afaik, it is. But having that optional, according to |
Quick update: after 3 long weeks of delays due to customs, I should receive all my stuff tomorrow. |
OK, got the computer today! I didn't investigate (yet) the details of the PR as well as if & how to merge it. |
@xen2 You didn't get back to me on the issue with extracting vertex data from disk, I did prod around a bit to see if I could figure it out myself and from what I understood the data is uploaded to the GPU as soon as it is deserialized ? Without any proper way to hook ourselves into the system ? I would love to help you out with the commandlist stuff but I don't have much experience with graphics api, so I won't be able to contribute significantly. I think I should put the editor-side mesh collider code in a separate PR so that we can finally merge this one if you're ready to do so ? |
@Eideren Yes, the issue is that data is loaded to GPU memory right away. Command list stuff would help in that you could get data from buffer without a command list, so you could just read back the GPU memory just like reading CPU memory. Also, if everything is somewhat usable without editor-side mesh collider, we should definitely split this in another PR and merge the other part. Sorry that I didn't realize it was OK without! |
@xen2 There you go, I'll create the mesh collider PR from the master branch as soon as this one is merged in. |
@Eideren thanks, code looks good to me! |
I noticed a bug when trying the ThirdPersonPlatformer. |
@xen2 I'll take a look at it |
Solved, the issue laid within ShapeSweep, that's what the TPP template uses by default for its camera collision, works fine now. |
8f6cb37
to
ae1f4b4
Compare
Thanks. Maybe one last thing before doing so: could you add a short markdown file at
Maybe you could also either update or delete the batch files (esp. build.bat & checkout.bat -- sign.bat looks OK already) so that people are not confused trying to fetch different repo. |
@xen2 Sure I meant to deal with those but kind of forgot, thanks for reminding me. I think you should probably fork/copy my repo to xenko3d's account and then modify |
Merged, thanks again and sorry it was delayed (esp. I didn't realize this could be split in two to take care of the more delicate part later) |
@xen2 Nah, it's my fault for not mentioning it sooner :) |
@Eideren no worries, the delicate part should have been taken care of sooner too! |
Content of this post where edited for future references, you can find previous records on the edit history located inside the header of this post.
Original Description:
Our version of BulletSharp is a modified, extremely old, pre-github version of https://github.com/AndresTraks/BulletSharpPInvoke , this PR should fix dependencies and the likes to allow us to pull from a clean and up to date nuget version of BulletSharpPInvoke instead.
Xenko's version contains a bunch of methods and fields which will have to be replaced with workarounds, some of which don't have any straightforward substitute.
Location of the sources, build scripts, tools and instructions used for this PR's libs located over here:
https://github.com/Eideren/BulletSharpPInvoke