Log inGet started
Package

scene_colliders.procNode

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

sim.scene_colliders (procNode)

The scene's colliders as a solver's collision environment: every box, sphere and capsule physics collider that is not a sensor, turned and moving with its entity, solid from every side, read where it stands in the graph's space at every step. Wire it into sim.particles' colliders beside any sim.collider shapes.

The colliders are read from the scene through the engine (each entity's collider shapes, with their position, rotation, shape type and size), carried into the graph's space by the inverse of where the graph stands, and kept when they reach within within of center.

Inputs

  • center (Vec3, default (0, 0, 0)): where within measures from, in the graph's space.
  • within (Float, default 0, min 0): only the colliders reaching within this distance of center are taken; 0 takes every one.
  • bounce (Float, default 0.5, 0 to 1): the share of its speed into a surface a particle keeps, turned back out. The same for every collider.
  • friction (Float, default 0.1, 0 to 1): the share of its speed along a surface a particle loses on contact.

Outputs

  • collider (Record): kind is "sim.collider" and shapes the shape table, a Points geometry with one point per collider shape, carrying shapeKind (1 sphere, 2 box, 3 capsule), center, extent (a sphere's radius in x, a box's half size, a capsule's radius and half height in x and y), rotation, reach (how far the shape reaches from its centre), bounce and friction. bounce and friction are also fields of the record.

A scene holding no collider gives an empty table, and the particles meet nothing from it.

Example

local source = g.sim.spawn({ points = g.points.grid({ countX = 1, countZ = 1, y = 2 }), rate = 60 })
local scene = g.sim.scene_colliders({ within = 20, bounce = 0.4 })
local sim = g.sim.particles({ sources = { source }, colliders = { scene }, gravity = vector.create(0, -9.8, 0) })