atl/sm/physics
import "atl/sm/physics"Physics queries and forces (sm.physics).
Functions
Section titled "Functions"func ShapesInSphere(center sm.Vec3, radius float64, world sm.World) []sm.Shapefunc ShapesInBox(center sm.Vec3, rotation sm.Quat, halfExtents sm.Vec3, world sm.World) []sm.ShapeShapes overlapping a sphere / box.
func SphereHasContact(center sm.Vec3, radius float64, includeTerrain, countWater bool) boolfunc SphereContactCount(center sm.Vec3, radius float64, includeTerrain, countWater bool) intWhether anything overlaps a sphere, and how many things.
func CapsuleHasContact(from, to sm.Vec3, radius float64, mask *int) boolfunc CapsuleContactCount(from, to sm.Vec3, radius float64, mask *int) intWhether anything overlaps a capsule, and how many things.
func DistanceRaycast(start, direction sm.Vec3) (float64, bool)A cheap ray: just the fraction (0..1) of direction travelled before a hit; false on a miss.
func IsPointInLiquid(point sm.Vec3) boolfunc IsSphereInLiquid(center sm.Vec3, radius float64) boolTrue if the point / sphere is in liquid.
func GroundMaterial(point sm.Vec3) stringThe ground material at a point.
func MaterialID(material string) intA physics material's id by name.
func Filter(name string) intA raycast filter value by name (sm.physics.filter[name]).
func Gravity() float64[server] The gravity strength.
func SetGravity(g float64)[server] Sets the gravity strength.
func Explode(position sm.Vec3, o ExplosionOptions)[server] Creates an explosion.
RaycastHit
Section titled "RaycastHit"type RaycastHit struct { Type string Point sm.Vec3 Normal sm.Vec3 PointLocal sm.Vec3 NormalLocal sm.Vec3 Origin sm.Vec3 Direction sm.Vec3 Fraction float64 Raw atl.Value}What a raycast hit. Type is "body", "character", "terrainSurface", "areaTrigger", ... Point/Normal are in world space; PointLocal/NormalLocal relative to what was hit.
func ToHit(r []atl.Value) (RaycastHit, bool)Converts the engine's (hit, result) pair to a RaycastHit; false on a miss.
func Raycast(from, to sm.Vec3, o RaycastOptions) (RaycastHit, bool)Casts a ray from from to to; false on a miss.
func RaycastTarget(from, to sm.Vec3, target sm.Body) (RaycastHit, bool)Casts a ray that only hits target.
func Spherecast(from, to sm.Vec3, radius float64, o RaycastOptions) (RaycastHit, bool)func Capsulecast(from, to sm.Vec3, radius, height float64, o RaycastOptions) (RaycastHit, bool)Casts a sphere / capsule along a line.
func Multicast(casts []Cast, world sm.World) []*RaycastHitRuns every cast in one engine call; results are in the same order (nil for a miss).
Methods
func (h RaycastHit) Is(t string) boolTrue if the hit type is t.
func (h RaycastHit) Shape() sm.Shapefunc (h RaycastHit) Body() sm.Bodyfunc (h RaycastHit) Character() sm.Characterfunc (h RaycastHit) Harvestable() sm.Harvestablefunc (h RaycastHit) Joint() sm.Jointfunc (h RaycastHit) AreaTrigger() sm.AreaTriggerThe object that was hit, when the type matches.
func (h RaycastHit) Lift() LiftHitReads a lift hit.
func (h RaycastHit) TerrainAssetMaterial() stringThe material name of a hit terrain asset.
LiftHit
Section titled "LiftHit"type LiftHit struct { Lift sm.Lift IsTop bool}A lift hit, and whether its top was hit.
RaycastOptions
Section titled "RaycastOptions"type RaycastOptions struct { Ignore sm.Body Mask *int}Optional raycast settings: a body to ignore and an sm.physics.filter mask.
Contacts
Section titled "Contacts"type Contacts struct { Bodies []sm.Body Characters []sm.Character Harvestables []sm.Harvestable Raw atl.Value}What overlaps a volume.
func ToContacts(t atl.Value) ContactsReads a contacts table.
func SphereContacts(center sm.Vec3, radius float64, mask *int) Contactsfunc BoxContacts(center sm.Vec3, rotation sm.Quat, halfExtents sm.Vec3, world sm.World, mask *int) ContactsEverything overlapping a sphere / box.
CastKind
Section titled "CastKind"type CastKind intThe kind of a Cast.
const ( CastRay CastKind = iota CastSphere)type Cast struct { Kind CastKind From, To sm.Vec3 Radius float64 Mask *int IgnoreUuids []sm.Uuid}One cast of a multicast batch.
func Ray(from, to sm.Vec3, mask *int) Castfunc Sphere(from, to sm.Vec3, radius float64, mask *int) CastA ray / sphere cast.
ExplosionOptions
Section titled "ExplosionOptions"type ExplosionOptions struct { Level int DestructionRadius float64 ImpulseRadius float64 Magnitude float64 Effect *string}Explosion settings. NewExplosionOptions gives the defaults.
func NewExplosionOptions() ExplosionOptionsThe default explosion settings.