Code Monkey home page Code Monkey logo

joltphysicssharp's Introduction

Hey! I am Amer Koleci, my github id is `amerkoleci`

I'm a self-taught, passionate software developer from Italy

Amer streak Amer top langs

Amer's github activity graph

  • ๐Ÿ”ญ Iโ€™m currently working as senior software engineer using C#/VB .NET and .NET in general writing WMS software.
  • โค๏ธ I love open source and work on personal projects whether possible, I enjoy contributing to other projects and share opinions with other people.
  • ๐ŸŒŸ I like to write game engine code and explore the different graphics APIs out there (Direct3D12, Vulkan, Metal or OpenGL). Therefore, I have created several projects to abstract the graphics APIs to make it easier to do graphics programming, which is where my main focus is. I love learning and read about new rendering techniques and try to implement them.
  • ๐Ÿ’ฌ If you have any question feel free to contact me and I will gladly reply.
  • ๐Ÿค” If you like to join my open source project feel free to do so by submitting PR or opening issues.
  • โšก Consider SPONSORING me to help me out reach my goals sooner.

If you are curious, I suggest you check out the following repositories:

joltphysicssharp's People

Contributors

amerkoleci avatar aquagoose avatar bjornbytes avatar jasperkr avatar jmiskovic avatar littlecodingfox avatar tianxing113 avatar veloctor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

joltphysicssharp's Issues

Multiple Implementations of JoltC

I noticed that both the C# port as well as the Zig port of Jolt implement a C port of Jolt underneath to use as a compatibility layer (both happen to be named JoltC, even).

Is it an issue that there are two different C APIs reproducing the same work? Could it benefit from more collaboration?

Vehicle classes missing

I cant find classes like VehicleController and others. Is there a way to compile this package with the vehicle support?

RVec3/RMat44 use doubles even in single-precision mode

JPH_RVec3 and JPH_RMat44 are currently always defined to use doubles, even when DOUBLE_PRECISION option isn't set.

This causes extra float <-> double conversions: If a user is representing their vectors as floats, they need to convert them to doubles to send them to JoltC, but JoltC will immediately convert them back to floats to send to Jolt. These conversions aren't that slow, but they are unnecessary and can start to add up.

Example:

void setBodyPosition(Body* body, float x, float y, float z) {
  // floats get converted to doubles here:
  JPH_RVec3 position = { x, y, z };

  // this calls ToRVec3, which converts the doubles back to floats:
  JPH_BodyInterface_SetPosition(world->body_interface, body->id, &position, JPH_Activation_Activate);
}

It also means that we can't operate on RVec3/RMat44 as though they were arrays of floats in memory, so we need to write custom functions to convert between floats and JoltC's types instead of using e.g. memcpy or casts.

I can send a PR to change the "R" types to conditionally use floats or doubles based on the JPH_DOUBLE_PRECISION define, but I wanted to discuss first to make sure this sort of change would work with the C# bindings.

I don't think there are any concerns with ABI compatibility, since the library is currently set up to use different names (joltc vs. joltc_double) for the different precision modes.

property comparson maybe wrong

struct MassProperties's Property:
public bool IsNull => Handle != 0;
public bool IsNotNull => Handle == 0;
maybe it inverted?

[BUG] DllImport makes problems on some Pcs

Issue description

Hello, I'm encountering an issue with the .dll importer in C#. It's a bit puzzling because it seems to work on some PCs but not others. On my main development machine, everything runs smoothly. However, on my test PC, I consistently encounter an error. Interestingly, on my sister's PC, it works flawlessly. It's quite perplexing, but I found that replacing the .dll with the original joltc one resolves the issue on any PC.

Issue screenshot

image

"Error: Invalid convex radius"

I am getting 2 of those entries, when I call

var body = _physicsSystem.BodyInterface.CreateBody(bodyCreationSettings);

where bodyCreationSettings is a BoxShapeSettings which i have created via

var halfSize = modelMesh.MeshData.BoundingBox.HalfSize;
BoxShapeSettings = new BoxShapeSettings(new Vector3(halfSize.X, halfSize.Y, halfSize.Z));

BSS's ctor has an optional parameter convexRadius which defaults to 0.05f. Setting it to something else, 0.5f, 0.0f, 1.0f, ... doesn't change anything. The docs talk about 0.0f in that case

Double Precision?

Hello,

I can see the there are settings to set DoublePrecision in the JoltApi.cs but the referenced functions such as

public static extern void JPH_Body_GetPosition(IntPtr handle, out Vector3 result);

seem to return a single precision vector3.

is it the case that the c++ implementation supports double precision but the binding does not?

Thanks very much for the work so far.

set ScaleToMass doesn't work for Shape's MassProperties

To create a rigidbody with my destination mass, in JoltPhysics docs' method, do following:

SphereShape shape = new(0.5f);
MassProperties massProperties = shape.MassProperties;
massProperties.ScaleToMass(10);
BodyCreationSettings spherSettings = new(shape, new Double3(0, 2, 0), Quaternion.Identity, MotionType.Dynamic, Layers.Moving);
Body sphereBody = bodyInterface.CreateBody(spherSettings);
Console.WriteLine("Mass: " + 1 / sphereBody.MotionProperties.InverseMassUnchecked); // not 10

That doesn't work.
Maybe do sphereBody.MotionProperties.SetMassProperties(AllowedDOFs.All, massProperties); after that works, but what to do if I create Rigidbody with multiple Shapes with CompoundShape? there's no way to get CompoundShape's massProperties, and ConvexHullShape even have no MassProperties, so there's only one way to do that:

SphereShape boxShapeForWorkAroundMass = new(1);
MassProperties createdMassProp = boxShapeForWorkAroundMass.MassProperties;
createdMassProp.ScaleToMass(128);
SphereShape shap = new(0.5f);
BodyCreationSettings spherSettings = new(shap, new Double3(0, 2, 0), Quaternion.Identity, MotionType.Dynamic, Layers.Moving);
Body sphereBody = bodyInterface.CreateBody(spherSettings);
bodyInterface.AddBody(sphereBody.ID, 0);
sphereBody.MotionProperties.SetMassProperties(AllowedDOFs.All, createdMassProp);
Console.WriteLine("Mass: " + 1 / sphereBody.MotionProperties.InverseMassUnchecked);//128

Maybe there's many important APIs missing?

[Feature] Add LockX/Y/Z, Mass

Could you pls add:

  • LockX/Y/Z (To disable of a physical object to fall in a setet direction, like X).
  • Mass

I hope you can add this features :)

Android support

Hi, I am porting my project to Android but unfortunately this library doesn't include the correct native libraries.
As I understand you are quite busy but I don't really know how can I add them myself so I would really appreciate some pointers to some resources on this topic.

Confirming Unity support?

Since this is C#, is there anything that would keep me from integrating with Unity Engine projects? The advantage would be to support cross-engine physics with similar behaviors and APIs.

I realize that the native interface might work, but that wouldnโ€™t be as simple for getting started.

CompoundShape is missing

When looking at the Jolt documentation I noticed a few shapes missing, including the CompoundShape which I need for my application.

I'm going to look into adding it and creating a PR shortly but I thought I'd open an issue in case it gets added before I open a PR.

Attempted to read or write protected memory

How to reproduce bug:
commit set : 9b764ca
Run hello world project without any modify under .NET7.0
Console output:

A body got activated
A body got activated
A body got activated
A body got activated
A body got activated
A body got activated
A body got activated
A body got activated
A body got activated
A body got activated
A body got activated
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:

at JoltPhysicsSharp.JoltApi.JPH_MeshShapeSettings_Create2(System.Numerics.Vector3*, Int32, JoltPhysicsSharp.IndexedTriangle*, Int32)

at JoltPhysicsSharp.MeshShapeSettings..ctor(System.Span1<System.Numerics.Vector3>, System.Span1<JoltPhysicsSharp.IndexedTriangle>)
at HelloWorld.Program.CreateTorusMesh(Single, Single, Int32, Int32)
at HelloWorld.Program.Main()

Null reference exception when calling GetWorldTransform(bodyID)

Not sure if this is a JoltC, Jolt C# or my own issue but calling bodyInterface.GetWorldTransform(bodyID) with a valid bodyID causes a NullReference exception. I can call other methods such as GetRotation or GetPosition and they work correctly. If it should work let me know and I'll post an example but it's not much different to the HelloWorld example just using GetWorldTransform.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.