|
|
|
|
@ -2,6 +2,13 @@
|
|
|
|
|
#include "game.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// forware declarations
|
|
|
|
|
|
|
|
|
|
void changeOrbitColor(GameOrbit* orbit, vec3* color_data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// interface
|
|
|
|
|
|
|
|
|
|
GameOrbit* |
|
|
|
|
getFreeOrbit(GameState* gs) |
|
|
|
|
{ |
|
|
|
|
@ -60,40 +67,46 @@ ellipse3DUpdate(EllipseParameters ep, Ellipse3D& e3d)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
changeOrbitColor(GameOrbit* orbit, vec3* color_data) |
|
|
|
|
{ |
|
|
|
|
GLBuffer* color_buf; |
|
|
|
|
GLMesh* gl_mesh = &orbit->ellipse_entity->meshes[0]; |
|
|
|
|
|
|
|
|
|
for (u32 i = 0; i < gl_mesh->num_vertex_attrib_buffers; i ++) { |
|
|
|
|
if (utilCStrMatch(gl_mesh->vertex_attrib_buffers[i].name, "color")) |
|
|
|
|
color_buf = &gl_mesh->vertex_attrib_buffers[i]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
assert(color_buf && color_buf->data_size == orbit->e3d.vert_count * 3 * 4); |
|
|
|
|
updateGLBuffer(color_buf, color_data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
updateOrbitColors(GameOrbit* last_selected_orbit, GameOrbit* orbit) |
|
|
|
|
selectOrbit(GameState* gs, GameOrbit* orbit) |
|
|
|
|
{ |
|
|
|
|
assert(orbit && orbit->ellipse_entity); |
|
|
|
|
|
|
|
|
|
// FIXME: need to allocate these somewhere other than stack
|
|
|
|
|
static vec3 selected_colors[DEFAULT_ORBIT_VERTICES]; |
|
|
|
|
static vec3 default_colors[DEFAULT_ORBIT_VERTICES]; |
|
|
|
|
|
|
|
|
|
for (u32 i = 0; i < DEFAULT_ORBIT_VERTICES; i++) |
|
|
|
|
selected_colors[i] = SELECTED_ELLIPSE_COLOR; |
|
|
|
|
|
|
|
|
|
static vec3 default_colors[DEFAULT_ORBIT_VERTICES]; |
|
|
|
|
|
|
|
|
|
for (u32 i = 0; i < DEFAULT_ORBIT_VERTICES; i++) |
|
|
|
|
default_colors[i] = DEFAULT_ELLIPSE_COLOR; |
|
|
|
|
|
|
|
|
|
if (gs->last_selected_orbit != nullptr) { |
|
|
|
|
changeOrbitColor(gs->last_selected_orbit, default_colors); |
|
|
|
|
gs->last_selected_orbit->selected = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
changeOrbitColor(orbit, selected_colors); |
|
|
|
|
orbit->selected = true; |
|
|
|
|
gs->last_selected_orbit = orbit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// repeat for last orbit
|
|
|
|
|
if (last_selected_orbit != nullptr) { |
|
|
|
|
for (u32 i = 0; i < DEFAULT_ORBIT_VERTICES; i++) |
|
|
|
|
default_colors[i] = DEFAULT_ELLIPSE_COLOR; |
|
|
|
|
// internal
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
changeOrbitColor(GameOrbit* orbit, vec3* color_data) |
|
|
|
|
{ |
|
|
|
|
GLBuffer* color_buf; |
|
|
|
|
GLMesh* gl_mesh = &orbit->ellipse_entity->meshes[0]; |
|
|
|
|
|
|
|
|
|
changeOrbitColor(last_selected_orbit, default_colors); |
|
|
|
|
for (u32 i = 0; i < gl_mesh->num_vertex_attrib_buffers; i ++) { |
|
|
|
|
if (utilCStrMatch(gl_mesh->vertex_attrib_buffers[i].name, "color")) |
|
|
|
|
color_buf = &gl_mesh->vertex_attrib_buffers[i]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
assert(color_buf && color_buf->data_size == orbit->e3d.vert_count * 3 * 4); |
|
|
|
|
updateGLBuffer(color_buf, color_data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|