]> git.bts.cx Git - benzene.git/blob - src/bz/gfx/particle_drawing.c
Fixed Aseprite rendering system
[benzene.git] / src / bz / gfx / particle_drawing.c
1 #include <bz/gfx/particle_drawing.h>
2
3 #include <bz/fx/particle_simulation_internal.h>
4 #include <bz/gfx/gfx.h>
5
6 //static void drawBasicParticle(size_t particleCount, float ticks, float spawnTick[], float lifetimes[], float positionX[], float positionY[], float sizes[], float colors[], float alpha[]);
7
8 void bzGfxDrawParticles(BZParticleSimulationID simulation, BZDrawQueueID drawQueue) {
9 BZMatrix m;
10
11 for (size_t i = 0; i < simulation->maxParticles; ++i) {
12 float particleStartTicks = simulation->spawnTime[i];
13 float lifetime = simulation->lifetime[i];
14 if (particleStartTicks + lifetime >= simulation->time) {
15 if (simulation->alpha[i] < 0.25f) {
16 bzFillP(0);
17 } else if (simulation->alpha[i] < 0.50f) {
18 bzFillP(23130);//bzFillP(23130);
19 } else if (simulation->alpha[i] < 0.75f) {
20 bzFillP(32125);//bzFillP(32125);
21 } else {
22 bzFillP(32735);//bzFillP(0xFF); // FIXME
23 }
24
25 bzSetPaletteColor(0, 0, simulation->color[i]);
26 //bzSetGlobalBlendColor(simulation->color[i]);
27
28 bzMatrixSRT(&m, simulation->positionX[i], simulation->positionY[i], simulation->angle[i], simulation->size[i], simulation->size[i]);
29 bzSetGlobalViewMatrix(&m);
30 //bzMatrixTRS(&m, 0, 0, simulation->angle[i], simulation->size[i], simulation->size[i]);
31 //bzSetGlobalLocalMatrix(&m);
32
33 if (drawQueue != NULL) {
34 bzGfxDrawQueueRun(drawQueue);
35 } else {
36 bzCircFill(0, 0, 1, 0);
37 }
38 }
39 }
40 bzFillP(0);
41
42 bzMatrixIdentity(&m);
43 bzSetGlobalViewMatrix(&m);
44 //bzSetGlobalLocalMatrix(&m);
45 bzSetPaletteColor(0, 0, 0);
46 //bzSetGlobalBlendColor(0xFF);
47
48
49 //void bzGfxDrawParticles(BZParticleSimulationID simulation) {
50
51
52 // FIXME, allow registering draw lists for particles
53
54 // BZParticleSimulationDrawFunction drawFunction = drawBasicParticle; // FIXME, allow register others
55 // drawFunction(simulation->maxParticles, simulation->time, simulation->spawnTime, simulation->lifetime, simulation->positionX, simulation->positionY, simulation->size, simulation->color, simulation->alpha);
56 }
57
58 /*static void drawBasicParticle(size_t particleCount, float time, float spawnTime[], float lifetimes[], float positionX[], float positionY[], float sizes[], float colors[], float alpha[]) {
59 for (size_t i = 0; i < particleCount; ++i) {
60 float particleStartTicks = spawnTime[i];
61 float lifetime = lifetimes[i];
62 if (particleStartTicks + lifetime >= time) {
63 if (alpha[i] < 0.25f) {
64 bzFillP(0);
65 } else if (alpha[i] < 0.50f) {
66 bzFillP(23130);//bzFillP(23130);
67 } else if (alpha[i] < 0.75f) {
68 bzFillP(32125);//bzFillP(32125);
69 } else {
70 bzFillP(32735);//bzFillP(0xFF); // FIXME
71 }
72
73 bzGfxDrawQueueRun(BZDrawQueueID drawQueue);
74 //bzCircFill(positionX[i], positionY[i], sizes[i], colors[i]);
75 }
76 }
77 bzFillP(0);
78 }*/
79
80 //nil,32800.99988,▒,░,32735.99988