@ -32,13 +32,13 @@
struct Editor_State
{
bool enabled ;
bool renderer_settings_window ;
int selected_entity_id ;
int top_panel_height ;
float camera_turn_speed ;
float camera_move_speed ;
float camera_sprint_multiplier ;
bool enabled ;
bool renderer_settings_window ;
struct Entity * selected_entity ;
int top_panel_height ;
float camera_turn_speed ;
float camera_move_speed ;
float camera_sprint_multiplier ;
} ;
struct Debug_Variable
@ -52,6 +52,7 @@ static struct Debug_Variable* debug_vars_list = NULL;
static int * empty_indices = NULL ;
static void editor_camera_update ( float dt ) ;
static void editor_show_entity_in_list ( struct nk_context * context , struct Scene * scene , struct Entity * entity ) ;
static void editor_widget_color_combov3 ( struct nk_context * context , vec3 * color , int width , int height ) ;
static void editor_widget_color_combov4 ( struct nk_context * context , vec4 * color , int width , int height ) ;
static bool editor_widget_v3 ( struct nk_context * context ,
@ -69,30 +70,27 @@ void editor_init(void)
{
editor_state . enabled = true ;
editor_state . renderer_settings_window = false ;
editor_state . selected_entity_id = - 1 ;
editor_state . selected_entity = NULL ;
editor_state . top_panel_height = 20 ;
editor_state . camera_turn_speed = 50.f ;
editor_state . camera_move_speed = 1 0.f;
editor_state . camera_move_speed = 2 0.f;
editor_state . camera_sprint_multiplier = 2.f ;
debug_vars_list = array_new ( struct Debug_Variable ) ;
empty_indices = array_new ( int ) ;
struct Camera * editor_camera = & game_state_get ( ) - > scene - > cameras [ CAM_EDITOR ] ;
entity_rename ( editor_camera , " Editor_Camera " ) ;
editor_camera - > base . active = true ;
vec3 cam_pos = { 0.f , 15.f , - 5.f } ;
transform_translate ( editor_camera , & cam_pos , TS_WORLD ) ;
editor_camera - > clear_color . x = 0.3f ;
editor_camera - > clear_color . y = 0.6f ;
editor_camera - > clear_color . z = 0.9f ;
editor_camera - > clear_color . w = 1.f ;
struct Hashmap * config = platform - > config . get ( ) ;
int render_width = hashmap_int_get ( config , " render_width " ) ;
int render_height = hashmap_int_get ( config , " render_height " ) ;
camera_attach_fbo ( editor_camera , render_width , render_height , true , true , true ) ;
vec3 axis = { 1.f , 0.f , 0.f } ;
transform_rotate ( editor_camera , & axis , - 25.f , TS_WORLD ) ;
}
int editor_debugvar_slot_create ( const char * name , int value_type )
@ -227,36 +225,20 @@ void editor_update(float dt)
if ( nk_group_begin ( context , " Editor Left " , NK_WINDOW_SCROLL_AUTO_HIDE ) )
{
/* Entities List */
struct Scene * scene = game_state_get ( ) - > scene ;
if ( nk_tree_push ( context , NK_TREE_TAB , " Entities " , NK_MAXIMIZED ) )
{
/*nk_layout_row_dynamic(context, 250, 1);
nk_layout_row_dynamic ( context , 250 , 1 ) ;
if ( nk_group_begin ( context , " Entity Name " , NK_WINDOW_SCROLL_AUTO_HIDE ) )
{
struct Entity * entity_list = entity_get_all ( ) ;
for ( int i = 0 ; i < array_len ( entity_list ) ; i + + )
{
struct Entity * entity = & entity_list [ i ] ;
nk_layout_row_dynamic ( context , 20 , 1 ) ;
if ( nk_selectable_label ( context , entity - > name , NK_TEXT_ALIGN_LEFT , & entity - > editor_selected ) )
{
if ( editor_state . selected_entity_id ! = - 1 )
{
struct Entity * currently_selected = entity_get ( editor_state . selected_entity_id ) ;
currently_selected - > editor_selected = false ;
}
if ( entity - > editor_selected )
{
editor_state . selected_entity_id = entity - > id ;
}
else
{
editor_state . selected_entity_id = - 1 ;
}
}
}
for ( int i = 0 ; i < MAX_ENTITIES ; i + + ) editor_show_entity_in_list ( context , scene , & scene - > entities [ i ] ) ;
for ( int i = 0 ; i < MAX_CAMERAS ; i + + ) editor_show_entity_in_list ( context , scene , & scene - > cameras [ i ] ) ;
for ( int i = 0 ; i < MAX_LIGHTS ; i + + ) editor_show_entity_in_list ( context , scene , & scene - > lights [ i ] ) ;
for ( int i = 0 ; i < MAX_STATIC_MESHES ; i + + ) editor_show_entity_in_list ( context , scene , & scene - > static_meshes [ i ] ) ;
nk_group_end ( context ) ;
} */
}
nk_tree_pop ( context ) ;
}
@ -292,186 +274,185 @@ void editor_update(float dt)
if ( nk_group_begin ( context , " Editor Right " , NK_WINDOW_NO_SCROLLBAR ) )
{
/* Entity Inspector */
//if(nk_tree_push(context, NK_TREE_TAB, "Inspector", NK_MAXIMIZED))
//{
// const int row_height = 18;
// if(editor_state.selected_entity_id != -1)
// {
// struct Entity* entity = entity_get(editor_state.selected_entity_id);
// nk_layout_row_dynamic(context, row_height, 2);
// nk_label(context, "Name", NK_TEXT_ALIGN_LEFT); nk_label(context, entity->name, NK_TEXT_ALIGN_RIGHT);
// nk_layout_row_dynamic(context, row_height, 2);
// nk_label(context, "ID", NK_TEXT_ALIGN_LEFT); nk_labelf(context, NK_TEXT_ALIGN_RIGHT, "%d", entity->id);
// nk_layout_row_dynamic(context, row_height, 2);
// nk_label(context, "Entity Type", NK_TEXT_ALIGN_LEFT); nk_labelf(context, NK_TEXT_ALIGN_RIGHT, "%s", entity_type_name_get(entity));
// nk_layout_row_dynamic(context, row_height, 2);
// struct Entity* parent_ent = entity_get(entity->transform.parent);
// nk_label(context, "Parent Name", NK_TEXT_ALIGN_LEFT); nk_label(context, parent_ent ? parent_ent->name : "NONE", NK_TEXT_ALIGN_RIGHT);
// /* Transform */
// {
// nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Position", NK_TEXT_ALIGN_CENTERED);
// vec3 abs_pos = {0.f, 0.f, 0.f};
// transform_get_absolute_position(entity, &abs_pos);
// if(editor_widget_v3(context, &abs_pos, "Px", "Py", "Pz", -FLT_MAX, FLT_MAX, 5.f, 1.f, row_height)) transform_set_position(entity, &abs_pos);
// nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Rotation", NK_TEXT_ALIGN_CENTERED);
// quat abs_rot = {0.f, 0.f, 0.f, 1.f};
// transform_get_absolute_rot(entity, &abs_rot);
// vec3 rot_angles = {0.f, 0.f, 0.f};
// rot_angles.x = TO_DEGREES(quat_get_pitch(&abs_rot));
// rot_angles.y = TO_DEGREES(quat_get_yaw(&abs_rot));
// rot_angles.z = TO_DEGREES(quat_get_roll(&abs_rot));
// vec3 curr_rot = {rot_angles.x, rot_angles.y, rot_angles.z};
// nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "Rx", -FLT_MAX, &curr_rot.x, FLT_MAX, 5.f, 1.f);
// nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "Ry", -FLT_MAX, &curr_rot.y, FLT_MAX, 5.f, 1.f);
// nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "Rz", -FLT_MAX, &curr_rot.z, FLT_MAX, 5.f, 1.f);
// vec3 delta = {0.f, 0.f, 0.f};
// vec3_sub(&delta, &rot_angles, &curr_rot);
// vec3 AXIS_X = {1.f, 0.f, 0.f};
// vec3 AXIS_Y = {0.f, 1.f, 0.f};
// vec3 AXIS_Z = {0.f, 0.f, 1.f};
// const float epsilon = 0.0001f;
// if(fabsf(delta.x) > epsilon) transform_rotate(entity, &AXIS_X, delta.x, TS_WORLD);
// if(fabsf(delta.y) > epsilon) transform_rotate(entity, &AXIS_Y, delta.y, TS_WORLD);
// if(fabsf(delta.z) > epsilon) transform_rotate(entity, &AXIS_Z, delta.z, TS_WORLD);
// nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Scale", NK_TEXT_ALIGN_CENTERED);
// vec3 abs_scale = {0.f, 0.f, 0.f};
// transform_get_absolute_scale(entity, &abs_scale);
// if(editor_widget_v3(context, &abs_scale, "SX", "SY", "SZ", 0.1f, FLT_MAX, 1.f, 0.1f, row_height))
// {
// entity->transform.scale = abs_scale;
// transform_update_transmat(entity);
// }
// }
// /* Light */
// if(entity->type == ET_LIGHT)
// {
// if(nk_tree_push(context, NK_TREE_TAB, "Light", NK_MAXIMIZED))
// {
// struct Light* light = &entity->light;
// if(light->type > LT_POINT)
// {
// nk_layout_row_dynamic(context, row_height, 1);
// nk_label(context, "Invalid light type!", NK_TEXT_ALIGN_CENTERED);
// }
// else
// {
// static const char* light_types[] = {"Spot", "Directional", "Point"};
// float combo_width = nk_widget_width(context), combo_height = row_height * (LT_MAX);
//
// nk_layout_row_dynamic(context, row_height, 2);
// nk_label(context, "Light Type", NK_TEXT_ALIGN_LEFT);
// nk_combobox(context, light_types, LT_MAX - 1, &light->type, row_height, nk_vec2(combo_width, combo_height));
//
// nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Light Color", NK_TEXT_ALIGN_CENTERED);
// nk_layout_row_dynamic(context, row_height, 1);
// editor_widget_color_combov3(context, &light->color, 200, 300);
// nk_layout_row_dynamic(context, row_height, 1);
// nk_property_float(context, "Intensity", 0.f, &light->intensity, 100.f, 0.1f, 0.05f);
// if(light->type != LT_DIR)
// {
// nk_layout_row_dynamic(context, row_height, 1);
// light->outer_angle = TO_RADIANS(nk_propertyf(context, "Outer Angle", TO_DEGREES(light->inner_angle), TO_DEGREES(light->outer_angle), 360, 1.f, 0.5f));
// nk_layout_row_dynamic(context, row_height, 1);
// light->inner_angle = TO_RADIANS(nk_propertyf(context, "Inner Angle", 1.f, TO_DEGREES(light->inner_angle), TO_DEGREES(light->outer_angle), 1.f, 0.5f));
// nk_layout_row_dynamic(context, row_height, 1);
// nk_property_int(context, "Radius", 1, &light->radius, INT_MAX, 1, 1);
// nk_layout_row_dynamic(context, row_height, 1);
// nk_property_float(context, "Falloff", 0.f, &light->falloff, 100.f, 0.1f, 0.05f);
// }
// }
// nk_tree_pop(context);
// }
// }
// /* Camera */
// if(entity->type == ET_CAMERA)
// {
// if(nk_tree_push(context, NK_TREE_TAB, "Camera", NK_MAXIMIZED))
// {
// bool update = false;
// struct Camera* camera = &entity->camera;
//
// nk_layout_row_dynamic(context, row_height, 2);
// nk_label(context, "Orthographic", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE);
// bool ortho = nk_checkbox_label(context, "", &camera->ortho);
// if(ortho != camera->ortho)
// {
// update = true;
// }
//
// if(!camera->ortho)
// {
// nk_layout_row_dynamic(context, row_height, 1);
// float new_fov = nk_propertyf(context, "Fov", 30.f, camera->fov, 90.f, 0.1f, 1.f);
// if(new_fov != camera->fov)
// {
// camera->fov = new_fov;
// update = true;
// }
// nk_layout_row_dynamic(context, row_height, 2);
// nk_label(context, "Aspect Ratio", NK_TEXT_ALIGN_LEFT); nk_labelf(context, NK_TEXT_ALIGN_RIGHT, "%.5f", camera->aspect_ratio);
// }
// nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Clear Color", NK_TEXT_ALIGN_CENTERED);
// nk_layout_row_dynamic(context, row_height, 1);
// editor_widget_color_combov4(context, &camera->clear_color, 200, 300);
// nk_layout_row_dynamic(context, row_height, 1);
// float new_zoom = nk_propertyf(context, "Zoom", 1.f, camera->zoom, FLT_MAX, 0.1f, 1.f);
// if(new_zoom != camera->zoom)
// {
// camera->zoom = new_zoom;
// update = true;
// }
// nk_layout_row_dynamic(context, row_height, 1);
// float new_near_z = nk_propertyf(context, "NearZ", -FLT_MAX, camera->nearz, camera->farz, 0.1f, 1.f);
// if(new_near_z != camera->nearz)
// {
// camera->nearz = new_near_z;
// update = true;
// }
//
// nk_layout_row_dynamic(context, row_height, 1);
// float new_far_z = nk_propertyf(context, "FarZ", camera->nearz, camera->farz, FLT_MAX, 0.1f, 2.f);
// if(new_far_z != camera->farz)
// {
// camera->farz = new_far_z;
// update = true;
// }
// if(update)
// {
// camera_update_view(entity);
// camera_update_proj(entity);
// }
// nk_tree_pop(context);
// }
// }
// }
// else
// {
// nk_label(context, "No Entity Selected", NK_TEXT_ALIGN_CENTERED);
// }
// nk_tree_pop(context);
//}
//
if ( nk_tree_push ( context , NK_TREE_TAB , " Inspector " , NK_MAXIMIZED ) )
{
const int row_height = 18 ;
if ( editor_state . selected_entity )
{
struct Scene * scene = game_state_get ( ) - > scene ;
struct Entity * entity = editor_state . selected_entity ;
struct Entity * parent_ent = entity - > transform . parent ;
nk_layout_row_dynamic ( context , row_height , 2 ) ; nk_label ( context , " Name " , NK_TEXT_ALIGN_LEFT ) ; nk_label ( context , entity - > name , NK_TEXT_ALIGN_RIGHT ) ;
nk_layout_row_dynamic ( context , row_height , 2 ) ; nk_label ( context , " ID " , NK_TEXT_ALIGN_LEFT ) ; nk_labelf ( context , NK_TEXT_ALIGN_RIGHT , " %d " , entity - > id ) ;
nk_layout_row_dynamic ( context , row_height , 2 ) ; nk_label ( context , " Selected " , NK_TEXT_ALIGN_LEFT ) ; nk_labelf ( context , NK_TEXT_ALIGN_RIGHT , " %s " , entity - > editor_selected ? " True " : " False " ) ;
nk_layout_row_dynamic ( context , row_height , 2 ) ; nk_label ( context , " Entity Type " , NK_TEXT_ALIGN_LEFT ) ; nk_labelf ( context , NK_TEXT_ALIGN_RIGHT , " %s " , entity_type_name_get ( entity ) ) ;
nk_layout_row_dynamic ( context , row_height , 2 ) ; nk_label ( context , " Parent Name " , NK_TEXT_ALIGN_LEFT ) ; nk_label ( context , parent_ent ? parent_ent - > name : " NONE " , NK_TEXT_ALIGN_RIGHT ) ;
/* Transform */
{
nk_layout_row_dynamic ( context , row_height , 1 ) ; nk_label ( context , " Position " , NK_TEXT_ALIGN_CENTERED ) ;
vec3 abs_pos = { 0.f , 0.f , 0.f } ;
transform_get_absolute_position ( entity , & abs_pos ) ;
if ( editor_widget_v3 ( context , & abs_pos , " Px " , " Py " , " Pz " , - FLT_MAX , FLT_MAX , 5.f , 1.f , row_height ) ) transform_set_position ( entity , & abs_pos ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ; nk_label ( context , " Rotation " , NK_TEXT_ALIGN_CENTERED ) ;
quat abs_rot = { 0.f , 0.f , 0.f , 1.f } ;
transform_get_absolute_rot ( entity , & abs_rot ) ;
vec3 rot_angles = { 0.f , 0.f , 0.f } ;
rot_angles . x = TO_DEGREES ( quat_get_pitch ( & abs_rot ) ) ;
rot_angles . y = TO_DEGREES ( quat_get_yaw ( & abs_rot ) ) ;
rot_angles . z = TO_DEGREES ( quat_get_roll ( & abs_rot ) ) ;
vec3 curr_rot = { rot_angles . x , rot_angles . y , rot_angles . z } ;
nk_layout_row_dynamic ( context , row_height , 1 ) ; nk_property_float ( context , " Rx " , - FLT_MAX , & curr_rot . x , FLT_MAX , 5.f , 1.f ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ; nk_property_float ( context , " Ry " , - FLT_MAX , & curr_rot . y , FLT_MAX , 5.f , 1.f ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ; nk_property_float ( context , " Rz " , - FLT_MAX , & curr_rot . z , FLT_MAX , 5.f , 1.f ) ;
vec3 delta = { 0.f , 0.f , 0.f } ;
vec3_sub ( & delta , & rot_angles , & curr_rot ) ;
vec3 AXIS_X = { 1.f , 0.f , 0.f } ;
vec3 AXIS_Y = { 0.f , 1.f , 0.f } ;
vec3 AXIS_Z = { 0.f , 0.f , 1.f } ;
const float epsilon = 0.0001f ;
if ( fabsf ( delta . x ) > epsilon ) transform_rotate ( entity , & AXIS_X , delta . x , TS_WORLD ) ;
if ( fabsf ( delta . y ) > epsilon ) transform_rotate ( entity , & AXIS_Y , delta . y , TS_WORLD ) ;
if ( fabsf ( delta . z ) > epsilon ) transform_rotate ( entity , & AXIS_Z , delta . z , TS_WORLD ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ; nk_label ( context , " Scale " , NK_TEXT_ALIGN_CENTERED ) ;
vec3 abs_scale = { 0.f , 0.f , 0.f } ;
transform_get_absolute_scale ( entity , & abs_scale ) ;
if ( editor_widget_v3 ( context , & abs_scale , " SX " , " SY " , " SZ " , 0.1f , FLT_MAX , 1.f , 0.1f , row_height ) )
{
entity - > transform . scale = abs_scale ;
transform_update_transmat ( entity ) ;
}
}
/* Light */
if ( entity - > type = = ET_LIGHT )
{
if ( nk_tree_push ( context , NK_TREE_TAB , " Light " , NK_MAXIMIZED ) )
{
struct Light * light = ( struct Light * ) entity ;
if ( light - > type > LT_POINT )
{
nk_layout_row_dynamic ( context , row_height , 1 ) ;
nk_label ( context , " Invalid light type! " , NK_TEXT_ALIGN_CENTERED ) ;
}
else
{
static const char * light_types [ ] = { " Spot " , " Directional " , " Point " } ;
float combo_width = nk_widget_width ( context ) , combo_height = row_height * ( LT_MAX ) ;
nk_layout_row_dynamic ( context , row_height , 2 ) ;
nk_label ( context , " Light Type " , NK_TEXT_ALIGN_LEFT ) ;
nk_combobox ( context , light_types , LT_MAX - 1 , & light - > type , row_height , nk_vec2 ( combo_width , combo_height ) ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ; nk_label ( context , " Light Color " , NK_TEXT_ALIGN_CENTERED ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ;
editor_widget_color_combov3 ( context , & light - > color , 200 , 300 ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ;
nk_property_float ( context , " Intensity " , 0.f , & light - > intensity , 100.f , 0.1f , 0.05f ) ;
if ( light - > type ! = LT_DIR )
{
nk_layout_row_dynamic ( context , row_height , 1 ) ;
light - > outer_angle = TO_RADIANS ( nk_propertyf ( context , " Outer Angle " , TO_DEGREES ( light - > inner_angle ) , TO_DEGREES ( light - > outer_angle ) , 360 , 1.f , 0.5f ) ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ;
light - > inner_angle = TO_RADIANS ( nk_propertyf ( context , " Inner Angle " , 1.f , TO_DEGREES ( light - > inner_angle ) , TO_DEGREES ( light - > outer_angle ) , 1.f , 0.5f ) ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ;
nk_property_int ( context , " Radius " , 1 , & light - > radius , INT_MAX , 1 , 1 ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ;
nk_property_float ( context , " Falloff " , 0.f , & light - > falloff , 100.f , 0.1f , 0.05f ) ;
}
}
nk_tree_pop ( context ) ;
}
}
/* Camera */
if ( entity - > type = = ET_CAMERA )
{
if ( nk_tree_push ( context , NK_TREE_TAB , " Camera " , NK_MAXIMIZED ) )
{
bool update = false ;
struct Camera * camera = ( struct Camera * ) entity ;
nk_layout_row_dynamic ( context , row_height , 2 ) ;
nk_label ( context , " Orthographic " , NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE ) ;
bool ortho = nk_checkbox_label ( context , " " , & camera - > ortho ) ;
if ( ortho ! = camera - > ortho )
{
update = true ;
}
if ( ! camera - > ortho )
{
nk_layout_row_dynamic ( context , row_height , 1 ) ;
float new_fov = nk_propertyf ( context , " Fov " , 30.f , camera - > fov , 90.f , 0.1f , 1.f ) ;
if ( new_fov ! = camera - > fov )
{
camera - > fov = new_fov ;
update = true ;
}
nk_layout_row_dynamic ( context , row_height , 2 ) ;
nk_label ( context , " Aspect Ratio " , NK_TEXT_ALIGN_LEFT ) ; nk_labelf ( context , NK_TEXT_ALIGN_RIGHT , " %.5f " , camera - > aspect_ratio ) ;
}
nk_layout_row_dynamic ( context , row_height , 1 ) ; nk_label ( context , " Clear Color " , NK_TEXT_ALIGN_CENTERED ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ;
editor_widget_color_combov4 ( context , & camera - > clear_color , 200 , 300 ) ;
nk_layout_row_dynamic ( context , row_height , 1 ) ;
float new_zoom = nk_propertyf ( context , " Zoom " , 1.f , camera - > zoom , FLT_MAX , 0.1f , 1.f ) ;
if ( new_zoom ! = camera - > zoom )
{
camera - > zoom = new_zoom ;
update = true ;
}
nk_layout_row_dynamic ( context , row_height , 1 ) ;
float new_near_z = nk_propertyf ( context , " NearZ " , - FLT_MAX , camera - > nearz , camera - > farz , 0.1f , 1.f ) ;
if ( new_near_z ! = camera - > nearz )
{
camera - > nearz = new_near_z ;
update = true ;
}
nk_layout_row_dynamic ( context , row_height , 1 ) ;
float new_far_z = nk_propertyf ( context , " FarZ " , camera - > nearz , camera - > farz , FLT_MAX , 0.1f , 2.f ) ;
if ( new_far_z ! = camera - > farz )
{
camera - > farz = new_far_z ;
update = true ;
}
if ( update )
{
camera_update_view ( entity ) ;
camera_update_proj ( entity ) ;
}
nk_tree_pop ( context ) ;
}
}
}
else
{
nk_label ( context , " No Entity Selected " , NK_TEXT_ALIGN_CENTERED ) ;
}
nk_tree_pop ( context ) ;
}
nk_group_end ( context ) ;
}
}
@ -597,12 +578,12 @@ void editor_camera_update(float dt)
turn_up_down = - cursor_ud * turn_speed * dt * scale ;
turn_left_right = cursor_lr * turn_speed * dt * scale ;
// log_message("ud : %d, lr : %d", cursor_ud, cursor_lr);
//log_message("ud : %d, lr : %d", cursor_ud, cursor_lr);
}
else
{
input_mouse_mode_set ( MM_NORMAL ) ;
// log_message("ud : %.3f, lr : %.3f", turn_up_down, turn_left_right);
//log_message("ud : %.3f, lr : %.3f", turn_up_down, turn_left_right);
turn_up_down * = dt ;
turn_left_right * = dt ;
}
@ -621,27 +602,13 @@ void editor_camera_update(float dt)
if ( turn_left_right ! = 0.f )
{
/*transform_rotate(player_entity, &rot_axis_left_right, -turn_left_right, TS_WORLD);
vec3 up = { 0.f , 0.f , 0.f } ;
vec3 forward = { 0.f , 0.f , 0.f } ;
vec3 lookat = { 0.f , 0.f , 0.f } ;
transform_get_up ( player_entity , & up ) ;
transform_get_forward ( player_entity , & forward ) ;
transform_get_lookat ( player_entity , & lookat ) ; */
/* log_message("Up : %s", tostr_vec3(&up)); */
/* log_message("FR : %s", tostr_vec3(&forward)); */
transform_rotate ( editor_camera , & rot_axis_left_right , - turn_left_right , TS_WORLD ) ;
}
if ( turn_up_down ! = 0.f )
{
/*transform_rotate(player_entity, &rot_axis_up_down, turn_up_down, TS_LOCAL);
vec3 up = { 0.f , 0.f , 0.f } ;
vec3 forward = { 0.f , 0.f , 0.f } ;
vec3 lookat = { 0.f , 0.f , 0.f } ;
transform_get_up ( player_entity , & up ) ;
transform_get_forward ( player_entity , & forward ) ;
transform_get_lookat ( player_entity , & lookat ) ; */
/* log_message("Up : %s", tostr_vec3(&up)); */
/* log_message("FR : %s", tostr_vec3(&forward)); */
//transform_rotate(editor_camera, &rot_axis_up_down, turn_up_down, TS_LOCAL);
transform_rotate ( editor_camera , & rot_axis_up_down , turn_up_down , TS_LOCAL ) ;
}
/* Movement */
@ -750,3 +717,28 @@ bool editor_widget_v3(struct nk_context* context, vec3* value, const char* name_
if ( ! vec3_equals ( & val_copy , value ) ) changed = true ;
return changed ;
}
void editor_show_entity_in_list ( struct nk_context * context , struct Scene * scene , struct Entity * entity )
{
if ( ! entity - > active ) return ;
nk_layout_row_dynamic ( context , 20 , 1 ) ;
if ( nk_selectable_label ( context , entity - > name , NK_TEXT_ALIGN_LEFT , & entity - > editor_selected ) )
{
if ( editor_state . selected_entity & & editor_state . selected_entity ! = entity )
{
editor_state . selected_entity - > editor_selected = false ;
editor_state . selected_entity = NULL ;
}
else if ( editor_state . selected_entity & & editor_state . selected_entity = = entity & & ! entity - > editor_selected )
{
editor_state . selected_entity = NULL ;
}
if ( entity - > editor_selected )
{
editor_state . selected_entity = entity ;
}
}
}