mirror of
https://github.com/overte-org/overte.git
synced 2025-06-19 00:40:36 +02:00
Removing some of the triangle code in main.cpp
This commit is contained in:
parent
4174364adc
commit
cb52fb7f04
2 changed files with 26 additions and 37 deletions
Binary file not shown.
55
main.cpp
55
main.cpp
|
@ -125,9 +125,6 @@ Cloud cloud(250000, // Particles
|
||||||
struct {
|
struct {
|
||||||
float vertices[NUM_TRIS * 3];
|
float vertices[NUM_TRIS * 3];
|
||||||
float vel [NUM_TRIS * 3];
|
float vel [NUM_TRIS * 3];
|
||||||
glm::vec3 vel1[NUM_TRIS];
|
|
||||||
glm::vec3 vel2[NUM_TRIS];
|
|
||||||
int element[NUM_TRIS];
|
|
||||||
}tris;
|
}tris;
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,7 +322,6 @@ void init(void)
|
||||||
//tris.normals[i*3+2] = pos.z;
|
//tris.normals[i*3+2] = pos.z;
|
||||||
|
|
||||||
// Moving - white
|
// Moving - white
|
||||||
tris.element[i] = 1;
|
|
||||||
//tris.colors[i*3] = 1.0; tris.colors[i*3+1] = 1.0; tris.colors[i*3+2] = 1.0;
|
//tris.colors[i*3] = 1.0; tris.colors[i*3+1] = 1.0; tris.colors[i*3+2] = 1.0;
|
||||||
tris.vel[i*3] = (randFloat() - 0.5)*VEL_SCALE;
|
tris.vel[i*3] = (randFloat() - 0.5)*VEL_SCALE;
|
||||||
tris.vel[i*3+1] = (randFloat() - 0.5)*VEL_SCALE;
|
tris.vel[i*3+1] = (randFloat() - 0.5)*VEL_SCALE;
|
||||||
|
@ -376,40 +372,33 @@ void update_tris()
|
||||||
float field_contrib[3];
|
float field_contrib[3];
|
||||||
for (i = 0; i < NUM_TRIS; i++)
|
for (i = 0; i < NUM_TRIS; i++)
|
||||||
{
|
{
|
||||||
if (tris.element[i] == 1) // If moving object, move and drag
|
// Update position
|
||||||
{
|
tris.vertices[i*3+0] += tris.vel[i*3];
|
||||||
// Update position
|
tris.vertices[i*3+1] += tris.vel[i*3+1];
|
||||||
tris.vertices[i*3+0] += tris.vel[i*3];
|
tris.vertices[i*3+2] += tris.vel[i*3+2];
|
||||||
tris.vertices[i*3+1] += tris.vel[i*3+1];
|
|
||||||
tris.vertices[i*3+2] += tris.vel[i*3+2];
|
|
||||||
|
|
||||||
// Add a little gravity
|
// Add a little gravity
|
||||||
//tris.vel[i*3+1] -= 0.0001;
|
//tris.vel[i*3+1] -= 0.0001;
|
||||||
|
|
||||||
const float DRAG = 0.99;
|
const float DRAG = 0.99;
|
||||||
// Drag: Decay velocity
|
// Drag: Decay velocity
|
||||||
tris.vel[i*3] *= DRAG;
|
tris.vel[i*3] *= DRAG;
|
||||||
tris.vel[i*3+1] *= DRAG;
|
tris.vel[i*3+1] *= DRAG;
|
||||||
tris.vel[i*3+2] *= DRAG;
|
tris.vel[i*3+2] *= DRAG;
|
||||||
}
|
|
||||||
|
|
||||||
if (tris.element[i] == 1)
|
// Read and add velocity from field
|
||||||
{
|
field_value(field_val, &tris.vertices[i*3]);
|
||||||
|
tris.vel[i*3] += field_val[0];
|
||||||
|
tris.vel[i*3+1] += field_val[1];
|
||||||
|
tris.vel[i*3+2] += field_val[2];
|
||||||
|
|
||||||
// Read and add velocity from field
|
// Add a tiny bit of energy back to the field
|
||||||
field_value(field_val, &tris.vertices[i*3]);
|
const float FIELD_COUPLE = 0.0000001;
|
||||||
tris.vel[i*3] += field_val[0];
|
field_contrib[0] = tris.vel[i*3]*FIELD_COUPLE;
|
||||||
tris.vel[i*3+1] += field_val[1];
|
field_contrib[1] = tris.vel[i*3+1]*FIELD_COUPLE;
|
||||||
tris.vel[i*3+2] += field_val[2];
|
field_contrib[2] = tris.vel[i*3+2]*FIELD_COUPLE;
|
||||||
|
field_add(field_contrib, &tris.vertices[i*3]);
|
||||||
|
|
||||||
// Add a tiny bit of energy back to the field
|
|
||||||
const float FIELD_COUPLE = 0.0000001;
|
|
||||||
field_contrib[0] = tris.vel[i*3]*FIELD_COUPLE;
|
|
||||||
field_contrib[1] = tris.vel[i*3+1]*FIELD_COUPLE;
|
|
||||||
field_contrib[2] = tris.vel[i*3+2]*FIELD_COUPLE;
|
|
||||||
field_add(field_contrib, &tris.vertices[i*3]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// bounce at edge of world
|
// bounce at edge of world
|
||||||
for (j=0; j < 3; j++) {
|
for (j=0; j < 3; j++) {
|
||||||
|
|
Loading…
Reference in a new issue