#ifndef STATE_H #define STATE_H #include "twn_game_api.h" #define POINTS_PER_METER 128 #define UNDO_STACK_SIZE 32 #define CAMERA_FOV ((float)M_PI_2 * 0.75f) #define POINT_LIMIT 65534 #define FACE_LIMIT 2048 #define OBJECT_LIMIT 16 #define TEXTURE_LIMIT 32 #define INVALID_POINT (POINT_LIMIT+1) #define INVALID_FACE (FACE_LIMIT+1) #define INVALID_OBJECT (OBJECT_LIMIT+1) #define INVALID_TEXTURE (TEXTURE_LIMIT+1) #define CAMERA_ROTATION_SPEED 0.04f #define SELECTION_SPHERE_RADIUS 32 typedef struct Operation { enum { OPERATION_MOVE_POINT, } kind; union { struct { uint16_t id; int16_t delta_x; int16_t delta_y; } move_point; } data; } Operation; typedef struct Point { int16_t x, y, z; } Point; /* triangles have p3 = INVALID_POINT */ /* lines have p2, p3 = INVALID_POINT */ /* points have p1, p2, p3 = INVALID_POINT */ typedef struct Face { uint16_t p[4]; uint8_t texture; } Face; typedef struct Object { char *name; bool is_invisible; Point position; char *textures[TEXTURE_LIMIT]; uint8_t textures_sz; Point rotation; Face faces[FACE_LIMIT]; uint16_t faces_sz; } Object; typedef struct State { Operation undo_stack[UNDO_STACK_SIZE]; uint32_t undo_stack_ptr; Vec3 camera_position; Vec3 camera_direction; float camera_zoom; bool camera_is_orthographic; /* defaults to wireframe */ bool solid_display_mode; /* positions skipped */ uint8_t grid_snap_granularity; Point points[POINT_LIMIT]; uint16_t points_sz; Object *objects; uint8_t objects_sz; } State; #endif