-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some mac ports, floating point stuff.
- Loading branch information
Showing
6 changed files
with
67 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,6 @@ | ||
#pragma once | ||
|
||
double g_current_time = 0; | ||
double g_frame_time = 1/30.0f; | ||
Vector g_gravity = Vector(0, 0, -9.8); | ||
|
||
float RandFloat(float min, float max) | ||
{ | ||
return ((float)mtrand()) * (max-min) /MTRAND_MAX + min; | ||
} | ||
|
||
struct Particle | ||
{ | ||
Vector m_position; | ||
Vector m_velocity; | ||
bool m_gravity; | ||
}; | ||
|
||
struct ParticleSystem | ||
{ | ||
vector<Particle> m_particles; | ||
int m_first_with_gravity; | ||
|
||
void Initialize() | ||
{ | ||
m_particles.reserve(1024*10); | ||
} | ||
|
||
void SpawnParticle() | ||
{ | ||
m_particles.push_back(Particle()); | ||
Particle* new_particle = &m_particles[m_particles.size()-1]; | ||
|
||
new_particle->m_position.x = 0; | ||
new_particle->m_position.y = 0; | ||
new_particle->m_position.z = 0; | ||
|
||
new_particle->m_velocity.x = RandFloat(-1, 1); | ||
new_particle->m_velocity.y = RandFloat(-1, 1); | ||
new_particle->m_velocity.z = 1; | ||
} | ||
|
||
void Update() | ||
{ | ||
int particles = m_particles.size(); | ||
|
||
for (size_t i = 0; i < particles; i++) | ||
{ | ||
Particle* p = &m_particles[i]; | ||
|
||
p->m_position = p->m_position + p->m_velocity * g_frame_time; | ||
if (p->m_gravity) | ||
p->m_velocity = p->m_velocity + g_gravity; | ||
} | ||
} | ||
}; | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters