fixing decay code
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
s
|
s
|
||||||
20000 0.5 0.33333333333 0 360 cyan
|
20000 0.5 0.33333333333 0 360 cyan 1 2
|
||||||
20000 0.3555 0.783 0 360 magenta
|
20000 0.3555 0.783 0 360 magenta 1 2
|
||||||
20000 0.6445 0.783 0 360 yellow
|
20000 0.6445 0.783 0 360 yellow 1 2
|
||||||
|
|||||||
+6
-13
@@ -28,12 +28,14 @@ int main(int argc, char* argv[]) {
|
|||||||
if (argv[i] == "--rotate"s || argv[i] == "-r"s) {
|
if (argv[i] == "--rotate"s || argv[i] == "-r"s) {
|
||||||
rotate = true;
|
rotate = true;
|
||||||
}
|
}
|
||||||
|
if (argv[i] == "--nolines"s || argv[i] == "-l"s) {
|
||||||
|
drawLines = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Polyparti::Room sim(screenWidth, screenHeight, fps);
|
Polyparti::Room sim(screenWidth, screenHeight, fps);
|
||||||
|
|
||||||
vector<raylib::Vector2> lines;
|
vector<raylib::Vector2> lines;
|
||||||
cout << "ok-1" << endl;
|
|
||||||
|
|
||||||
sim.loadRoom(roomName);
|
sim.loadRoom(roomName);
|
||||||
sim.loadParticles(partName);
|
sim.loadParticles(partName);
|
||||||
@@ -66,19 +68,8 @@ int main(int argc, char* argv[]) {
|
|||||||
if (IsKeyPressed(KEY_B)) useShader = !useShader;
|
if (IsKeyPressed(KEY_B)) useShader = !useShader;
|
||||||
if (IsKeyPressed(KEY_SPACE)) paused = !paused;
|
if (IsKeyPressed(KEY_SPACE)) paused = !paused;
|
||||||
if (IsKeyPressed(KEY_T)) sim.reverseInterval();
|
if (IsKeyPressed(KEY_T)) sim.reverseInterval();
|
||||||
//if (IsKeyPressed(KEY_UP)) sim.adjustInterval(d_interval_pct);
|
|
||||||
//if (IsKeyPressed(KEY_DOWN)) sim.adjustInterval(-d_interval_pct);
|
|
||||||
/*if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
|
||||||
mouse_f = GetMousePosition();
|
|
||||||
mouse_f -= midpoint;
|
|
||||||
mouse_d = GetMouseDelta();
|
|
||||||
mouse_i = mouse_f - mouse_d;
|
|
||||||
angle = mouse_f.DotProduct(mouse_i);
|
|
||||||
angle = angle / mouse_f.Length() * mouse_i.Length();
|
|
||||||
angle = acos(angle);
|
|
||||||
}*/
|
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
sim.updateFields();
|
sim.updateFields(window.GetTime());
|
||||||
if (rotate) sim.rotateRoom(angle);
|
if (rotate) sim.rotateRoom(angle);
|
||||||
lines.clear();
|
lines.clear();
|
||||||
}
|
}
|
||||||
@@ -129,9 +120,11 @@ int main(int argc, char* argv[]) {
|
|||||||
DrawTextureRec(blur.texture, {0, 0, resolution[0], -resolution[1]}, {0,0}, WHITE);
|
DrawTextureRec(blur.texture, {0, 0, resolution[0], -resolution[1]}, {0,0}, WHITE);
|
||||||
blurShader.EndMode();
|
blurShader.EndMode();
|
||||||
} else {
|
} else {
|
||||||
|
if (drawLines) {
|
||||||
for (int i = 0; i < (int)lines.size() - 1; i++) {
|
for (int i = 0; i < (int)lines.size() - 1; i++) {
|
||||||
lines[i].DrawLine(lines[i+1], WHITE);
|
lines[i].DrawLine(lines[i+1], WHITE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < sim.getFieldCount(); i++) {
|
for (int i = 0; i < sim.getFieldCount(); i++) {
|
||||||
auto& field = sim.getField(i);
|
auto& field = sim.getField(i);
|
||||||
|
|||||||
+8
-8
@@ -12,7 +12,7 @@ using namespace sycl;
|
|||||||
|
|
||||||
struct Polyparti::ParticleField::ColCode {
|
struct Polyparti::ParticleField::ColCode {
|
||||||
std::vector<XYVector> positions, velocities;
|
std::vector<XYVector> positions, velocities;
|
||||||
float t, fieldTime, lifeTime;
|
float t, fieldTime = 0, lifeTime = 0;
|
||||||
int count, decay = 0;
|
int count, decay = 0;
|
||||||
int color[4];
|
int color[4];
|
||||||
//float decay = 1.0f;
|
//float decay = 1.0f;
|
||||||
@@ -230,7 +230,7 @@ void Polyparti::ParticleField::updateField(std::vector<XYVector> verticies) {
|
|||||||
colcode->moveParticles();
|
colcode->moveParticles();
|
||||||
colcode->fieldTime += colcode->t;
|
colcode->fieldTime += colcode->t;
|
||||||
if (colcode->dies) {
|
if (colcode->dies) {
|
||||||
if (colcode->lifeTime >= colcode->fieldTime) {
|
if (colcode->fieldTime >= colcode->lifeTime) {
|
||||||
colcode->color[3] -= colcode->decay;
|
colcode->color[3] -= colcode->decay;
|
||||||
}
|
}
|
||||||
if (colcode->color[3] <= 0) {
|
if (colcode->color[3] <= 0) {
|
||||||
@@ -311,8 +311,8 @@ void Polyparti::ParticleField::setInterval(const float interval) {
|
|||||||
void Polyparti::ParticleField::setDecay(const float t, const float d) {
|
void Polyparti::ParticleField::setDecay(const float t, const float d) {
|
||||||
if (t != 0) {
|
if (t != 0) {
|
||||||
colcode->dies = true;
|
colcode->dies = true;
|
||||||
colcode->lifeTime = fabs(t);
|
colcode->lifeTime = t;
|
||||||
colcode->decay = static_cast<int>(fabs(d) * 255);
|
colcode->decay = static_cast<int>(fabs(d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,7 +421,7 @@ void Polyparti::Room::loadParticles(std::string name) {
|
|||||||
else if (check == 'r') { relativeRoom = true; }
|
else if (check == 'r') { relativeRoom = true; }
|
||||||
|
|
||||||
if (partfile.is_open()) {
|
if (partfile.is_open()) {
|
||||||
while (partfile >> count >> x >> y >> deg_start >> deg_end >> color) {
|
while (partfile >> count >> x >> y >> deg_start >> deg_end >> color >> life >> decay) {
|
||||||
if (relativeScreen) {
|
if (relativeScreen) {
|
||||||
x *= screenWidth;
|
x *= screenWidth;
|
||||||
y *= screenHeight;
|
y *= screenHeight;
|
||||||
@@ -435,8 +435,8 @@ void Polyparti::Room::loadParticles(std::string name) {
|
|||||||
newEntry.deg_start = deg_start;
|
newEntry.deg_start = deg_start;
|
||||||
newEntry.deg_end = deg_end;
|
newEntry.deg_end = deg_end;
|
||||||
newEntry.color = color;
|
newEntry.color = color;
|
||||||
//newEntry.life = life;
|
newEntry.life = life;
|
||||||
//newEntry.decayRate = decay;
|
newEntry.decayRate = decay;
|
||||||
|
|
||||||
this->info.push_back(newEntry);
|
this->info.push_back(newEntry);
|
||||||
}
|
}
|
||||||
@@ -484,7 +484,7 @@ void Polyparti::Room::rotateRoom(float degrees) {
|
|||||||
|
|
||||||
void Polyparti::Room::addFields() { for (auto& i: info) initField(i);}
|
void Polyparti::Room::addFields() { for (auto& i: info) initField(i);}
|
||||||
|
|
||||||
void Polyparti::Room::updateFields() {
|
void Polyparti::Room::updateFields(double time) {
|
||||||
for (auto& f : field) {
|
for (auto& f : field) {
|
||||||
f.updateField(implRoom->corners);
|
f.updateField(implRoom->corners);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ namespace Polyparti {
|
|||||||
void rotateRoom(float degrees);
|
void rotateRoom(float degrees);
|
||||||
void initField(fieldInfo info);
|
void initField(fieldInfo info);
|
||||||
void addFields();
|
void addFields();
|
||||||
void updateFields();
|
void updateFields(double time);
|
||||||
ParticleField& getField(int index);
|
ParticleField& getField(int index);
|
||||||
void adjustInterval(const float pct);
|
void adjustInterval(const float pct);
|
||||||
void reverseInterval();
|
void reverseInterval();
|
||||||
|
|||||||
Reference in New Issue
Block a user