gelly-gmod / gelly

Library to integrate fluids into a game engine
GNU General Public License v3.0
18 stars 3 forks source link

Make FleX collision events available to Lua #64

Open Derpius opened 2 months ago

Derpius commented 2 months ago

Context

Scope

todo - I don't know enough of how the binary module is structured to scope this properly @yogwoggf

The algorithm is roughly as follows:

  1. Spawn a number of threads
  2. On each thread:
    1. Create an unordered map of shape IDs -> collision info
      • If shape IDs are roughly small and consecutive, could use an array of length MAX_SHAPE_ID
    2. For each particle allocated to this thread
      1. For each contact as given by counts[particleIndex]
        1. Get shape ID, force vector, other userdata (e.g. particle type for portal gel type things and material properties)
          • If we don't have a particle userdata buffer yet to store the material and other things, this should be added
        2. Aggregate the data with the thread-local shapeCollisionInfo[contactShapeId]
          • For force this should just be addition
          • For other props you may need a set of unique particle userdatas that were encountered (with e.g. a particle count assigned to each for weighted damage / other effects in lua)
  3. After all threads complete, aggregate each thread's local aggregations together using the same algorithm as on the thread

Acceptance Criteria

Other

No response