generated from AfonsoCMSousa/CPP-OpenGLTemplate
feat: COLISIONS AND RADIUS INCLUDED
This commit is contained in:
parent
45ed43a968
commit
d3510b2ce8
@ -7,7 +7,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define G_CONSTANT 0.65f
|
#define G_CONSTANT 1.98f
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
@ -169,8 +169,8 @@ void *t_update(void *args) {
|
|||||||
p.position.y += p.velocity.y * params->time;
|
p.position.y += p.velocity.y * params->time;
|
||||||
p.position.z += p.velocity.z * params->time;
|
p.position.z += p.velocity.z * params->time;
|
||||||
|
|
||||||
if (p.position.y <= 0) {
|
if (p.position.y <= 0 + p.radius) {
|
||||||
p.position.y = 0;
|
p.position.y = 0 + p.radius;
|
||||||
p.velocity.y *= (-1 * p.dampening);
|
p.velocity.y *= (-1 * p.dampening);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,13 +20,13 @@ const char FRAGMENT_SHADER_SOURCE[] = "./source/shader/fragment.glsl";
|
|||||||
const char VERTEX_SHADER_SOURCE[] = "./source/shader/vertex.glsl";
|
const char VERTEX_SHADER_SOURCE[] = "./source/shader/vertex.glsl";
|
||||||
|
|
||||||
const char PROGRAM_NAME[] = "Particle Sim";
|
const char PROGRAM_NAME[] = "Particle Sim";
|
||||||
const unsigned int THREAD_COUNT = 8;
|
const unsigned int THREAD_COUNT = 1;
|
||||||
|
|
||||||
const unsigned int SCR_WIDTH = 1920;
|
const unsigned int SCR_WIDTH = 1920;
|
||||||
const unsigned int SCR_HEIGHT = 1080;
|
const unsigned int SCR_HEIGHT = 1080;
|
||||||
const char *glsl_version;
|
const char *glsl_version;
|
||||||
|
|
||||||
const unsigned int PARTICLE_COUNT = 2000;
|
const unsigned int PARTICLE_COUNT = 3;
|
||||||
|
|
||||||
GLFWwindow *window;
|
GLFWwindow *window;
|
||||||
unsigned int VBO, VAO;
|
unsigned int VBO, VAO;
|
||||||
@ -220,13 +220,9 @@ int main() {
|
|||||||
if (particles == NULL) {
|
if (particles == NULL) {
|
||||||
snprintf(errLog, 128, "There was a issue allocating memory for the particle list\n");
|
snprintf(errLog, 128, "There was a issue allocating memory for the particle list\n");
|
||||||
} else {
|
} else {
|
||||||
for (unsigned long long i = 0; i < PARTICLE_COUNT; i++) {
|
particles[0] = particle_init({1.000001f, 1.0f, 0.97f}, {1.0f, 0.0f, 0.0f, 255.0f});
|
||||||
float x = ((float)rand() / RAND_MAX) * 2.0f - 1.0f; // Random x between -1 and 1
|
particles[1] = particle_init({1.0f, 1.2f, 1.0f}, {0.0f, 1.0f, 0.0f, 255.0f});
|
||||||
float y = ((float)rand() / RAND_MAX) * 2.0f - 1.0f; // Random y between -1 and 1
|
particles[2] = particle_init({0.99995f, 1.4f, 1.004f}, {0.0f, 0.0f, 1.0f, 255.0f});
|
||||||
float z = ((float)rand() / RAND_MAX) * 2.0f - 1.0f; // Random z between -1 and 1
|
|
||||||
|
|
||||||
particles[i] = particle_init({x, 2, z}, {1.0f, 0.5f, 0.2f, 1.0f});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float current_time;
|
float current_time;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user