Skip to main content

classicube_sys/
particle.rs

1use crate::bindings::{Gfx, PackedCol, TextureRec, Vec2, Vec3, VertexTextured};
2
3#[must_use]
4pub fn Particle_DoRender(
5    size: &Vec2,
6    pos: &Vec3,
7    rec: &TextureRec,
8    col: PackedCol,
9) -> [VertexTextured; 4] {
10    let sX = size.x * 0.5;
11    let sY = size.y * 0.5;
12    let mut centre = *pos;
13    centre.y += sY;
14    let view = unsafe { Gfx.View };
15
16    let aX = view.row1.x * sX;
17    let aY = view.row2.x * sX;
18    let aZ = view.row3.x * sX; // right * size.x * 0.5f
19    let bX = view.row1.y * sY;
20    let bY = view.row2.y * sY;
21    let bZ = view.row3.y * sY; // up    * size.y * 0.5f
22
23    [
24        VertexTextured {
25            x: centre.x - aX - bX,
26            y: centre.y - aY - bY,
27            z: centre.z - aZ - bZ,
28            Col: col,
29            U: rec.u1,
30            V: rec.v2,
31        },
32        VertexTextured {
33            x: centre.x - aX + bX,
34            y: centre.y - aY + bY,
35            z: centre.z - aZ + bZ,
36            Col: col,
37            U: rec.u1,
38            V: rec.v1,
39        },
40        VertexTextured {
41            x: centre.x + aX + bX,
42            y: centre.y + aY + bY,
43            z: centre.z + aZ + bZ,
44            Col: col,
45            U: rec.u2,
46            V: rec.v1,
47        },
48        VertexTextured {
49            x: centre.x + aX - bX,
50            y: centre.y + aY - bY,
51            z: centre.z + aZ - bZ,
52            Col: col,
53            U: rec.u2,
54            V: rec.v2,
55        },
56    ]
57}