Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Integrating Obi's Collision Detection with Custom Particle Simulator
#1
I'm currently developing a custom particle simulation for our game, and I am at the point where collision detection with other objects (e.g., Unity/PhysX colliders, as well as other obi simplexes) is the next item to develop.

Given that Obi already has a comprehensive collision detection and handling system, and that all of the game objects in our project are configured to use it, I was hoping that I could leverage it instead of starting from scratch and having yet another collision management system running alongside the other two (PhysX and Obi).

However, after looking at the code (I appear to be on version 6.4 as CHANGELOG.txt contains a "## [6.4]" subsection), I am a but stumped on how I'd accomplish this.

Currently I have a particle simulation where each particle has position, velocity, mass, etc. Ideally, I'd queue up a job that takes the particles' states in and outputs the particles' and rigidbodies' new velocities/velocity changes. The new velocities would be applied to the particles with another job, and the rigidbodies would be updated on the main thread just prior to Physics.Update().

Further, I noticed that in Obi 7, the integration between Obi and Burst was announced to be cleaner. I presume this means removing the abstraction layer that'd allow Burst/Oni interchangeability, which is likely to make this work a bit easier. As such, I think beta access might be important.

(I sent an email to obi (at) virtualmethodstudio (dot) com about this, but I figured I'd start a thread here in case you are more active on the forums.)

I'm not entirely sure how to go about doing this, e.g. how tightly I should integrate the simulation I wrote with Obi. Any pointers on how I should go about doing this would be helpful! Sonrisa
Reply
#2
(19-07-2023, 01:18 AM)Hatchling Wrote: However, after looking at the code (I appear to be on version 6.4 as CHANGELOG.txt contains a "## [6.4]" subsection), I am a but stumped on how I'd accomplish this.

Currently I have a particle simulation where each particle has position, velocity, mass, etc. Ideally, I'd queue up a job that takes the particles' states in and outputs the particles' and rigidbodies' new velocities/velocity changes. The new velocities would be applied to the particles with another job, and the rigidbodies would be updated on the main thread just prior to Physics.Update().

There's an example on how to do this in the manual, see "using jobs to process particles" at the end of the following link:
http://obi.virtualmethodstudio.com/manua...icles.html

All particle data arrays in Obi can be converted to NativeArrays using AsNativeArray<T>(), which allows you to process them in a job. The example in the manual just calculates acceleration towards a point in space, it's up to you to implement your own collision detection/response there (which will be significantly more complex).

(19-07-2023, 01:18 AM)Hatchling Wrote: Further, I noticed that in Obi 7, the integration between Obi and Burst was announced to be cleaner. I presume this means removing the abstraction layer that'd allow Burst/Oni interchangeability, which is likely to make this work a bit easier. As such, I think beta access might be important.

The abstraction layer between ObiSolver and the backend in use is still pretty much in place, since we stilll have two backends: CPU based (Burst) and GPU based (Compute). The "tighter" integration comes from the fact that some data structures no longer need to cater to an old backend, so questionable decisions made while developing Oni no longer have any impact on the Burst backend. This has made them slimmer/cleaner, and improved Burst's performance.

The API exposed by Obi 7 and 6 is pretty much identical. There's only been a few changes regarding solver callbacks and execution order, but they're extremely unlikely to affect any code you write in a significant way.

(19-07-2023, 01:18 AM)Hatchling Wrote: I'm not entirely sure how to go about doing this, e.g. how tightly I should integrate the simulation I wrote with Obi. Any pointers on how I should go about doing this would be helpful! Sonrisa

I'd start by injecting a job that goes over all particles in ObiSolver's OnBeginStep (which takes place before particle simulation), doing your own custom processing.

let me know if you need further help,

kind regards,
Reply