#ifndef EDITOR_H #define EDITOR_H #include "common.h" #include "ent.h" #include "cam.h" typedef enum { ED_ACTION_TRANSFORM, ED_ACTION_CREATE, ED_ACTION_DELETE, ED_ACTION_RENAME, ED_ACTION_MODEL, ED_ACTION_PHYSICS, } EditorActionTag; typedef union { struct { Vec3 pos, scale; Quaternion rot; } transform; /* stored meaning 'stored entity', shared by creation/deletion */ struct { Entity ent; u64 parent, prev, next; } stored; struct { char *name; } rename; ModelCmp model; PhysicsCmp physics; } EditorActionData; typedef struct { EditorActionTag tag; u32 item_cnt; struct { u64 pid; EditorActionData before, after; } *item; } EditorAction; typedef enum { ED_PNL_NULL, ED_PNL_LEFT, ED_PNL_RIGHT, ED_PNL_CENTER, ED_PNL_CNT, } EditorPanelContainer; typedef enum { ED_PNL_TYPE_SCENE, ED_PNL_TYPE_PROPERTIES, ED_PNL_TYPE_SPACE, ED_PNL_TYPE_MODEL_PICKER, ED_PNL_TYPE_PHYSICS_ELEMENTS, ED_PNL_TYPE_PHYSICS_PROPERTIES, ED_PNL_TYPE_CMD, } EditorPanelType; typedef enum { ED_MODE_SCENE, ED_MODE_ENTITY, ED_MODE_PHYSICS, } EditorModeTag; typedef enum { ED_INTERACT_NONE, ED_INTERACT_SELECT, ED_INTERACT_MOVE, ED_INTERACT_ROTATE, ED_INTERACT_SCALE, ED_INTERACT_CAMERA, } EditorInteraction; typedef struct { Vec3 sel_point; Quaternion sel_rot; int sel_cnt; f32 grid_sz; int rotation_snap; u64 physics_pid; int physics_body, physics_shape; Vec2 physics_scroll; CameraInfo scene_cam; bool draw_physics; EditorModeTag mode, prev_mode; EditorInteraction interact; EditorPanelContainer focus; bool focus_captured; int move_axis; bool move_plane; Vec3 move_snap_origin; int rotate_axis; bool rotate_group; Vec3 rotate_pivot; Quaternion move_rotation; int scale_axis; bool scale_group; Vec3 scale_pivot; f32 scale_factor; struct { EditorPanelType type; Rect bounds; Vec2 scroll; bool enabled; } panel[ED_PNL_CNT]; EditorAction *history; // history_save_csr UINT32_MAX means no saved position and marks file // as having unsaved changes. u32 history_cnt, history_cap, history_csr, history_save_csr; } EditorInfo; extern EditorInfo ed; void editor_init(void); void editor_exit(void); void editor_update(void); /* tools */ void editor_select(void); void editor_move(void); void editor_rotate(void); void editor_scale(void); /* draw */ void editor_draw_ui(void); void editor_draw_3d(void); /* utils */ f32 editor_label_w(cstr); void editor_rename_selected(cstr); #endif