#ifndef WORLD_CHIPS_H #define WORLD_CHIPS_H /* * Bits that fly off work: wood chips off the axe (they land and lie a while) * and sawdust out of the chainsaw (it drifts down and is gone); puffs of * cigarette smoke. */ #include #include "math/linalg.h" #include "render/mesh.h" #include "render/renderer.h" #include "world/terrain.h" #define CHIP_MAX 400 typedef struct { Vec3 p, v; float life; /* seconds left */ float size; float angle, spin; Vec3 color; bool dust; bool smoke; /* a puff of smoke: drifts up, grows, gone */ bool down; /* lying on the ground */ } Chip; typedef struct { Chip chips[CHIP_MAX]; int next; unsigned rng; Mesh mesh; /* a small white block (tinted per chip) ... */ Mesh puff; /* ... and a ball for smoke */ } Chips; void Chips_init(Chips *c); void Chips_destroy(Chips *c); /* n bits from at, flying out along dir (roughly); dust: sawdust, else wood chips. */ void Chips_spray(Chips *c, Vec3 at, Vec3 dir, int n, bool dust); /* A little puff of smoke at at (breathed out along dir, or off a cigarette's tip: small). */ void Chips_puff(Chips *c, Vec3 at, Vec3 dir, bool small); /* Smoke off a fire (a big soft puff, rising). */ void Chips_smoke(Chips *c, Vec3 at); /* wind: m/s the air moves (smoke and dust go with it). */ void Chips_update(Chips *c, const Terrain *terrain, Vec3 wind, float dt); void Chips_draw(const Chips *c, Renderer *renderer); #endif /* WORLD_CHIPS_H */