-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.h
More file actions
178 lines (153 loc) · 6.04 KB
/
game.h
File metadata and controls
178 lines (153 loc) · 6.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#pragma once
#include <SDL2/SDL_ttf.h>
#include <stdint.h>
#include "model.h"
#include "anim.h"
#include "skeleton.h"
#include "linear_math/vector.h"
#include "linear_math/matrix.h"
#include "linear_math/quaternion.h"
#include "stack_alloc.h"
#include "heap_alloc.h"
#include "edit_animation.h"
#include "camera.h"
#include "render_data.h"
#include "text.h"
#include "entity.h"
#include "edit_animation.h"
#include "resource_manager.h"
#include "dynamics.h"
#include "motion_matching.h"
#include "ecs_management.h"
#include "movement_spline.h"
#include "blend_stack.h"
#include "entity_animation_control.h"
#include "testing_system.h"
const int32_t ENTITY_MAX_COUNT = 400;
const int32_t ENTITY_SELECTION_MAX_COUNT = 400;
const int32_t MESH_SELECTION_MAX_COUNT = 400;
const int32_t MAX_MM_ANIMATION_COUNT = 30;
#define FOR_ALL_NAMES(DO_FUNC) DO_FUNC(Entity) DO_FUNC(Mesh) DO_FUNC(Bone)
#define GENERATE_ENUM(Name) SELECT_##Name,
#define GENERATE_STRING(Name) #Name,
enum selection_mode
{
FOR_ALL_NAMES(GENERATE_ENUM) SELECT_EnumCount
};
static const char* g_SelectionEnumStrings[SELECT_EnumCount] = { FOR_ALL_NAMES(GENERATE_STRING) };
#undef FOR_ALL_NAMES
#undef GENERATE_ENUM
#undef GENERATE_STRING
struct mm_profile_editor
{
mm_params ActiveProfile;
rid ControllerRID;
bool SyncDynamic;
};
struct game_state
{
Memory::stack_allocator* PersistentMemStack;
Memory::stack_allocator* TemporaryMemStack;
render_data R;
EditAnimation::animation_editor AnimEditor;
rid CurrentModelID;
rid CurrentMaterialID;
rid CurrentAnimationID;
Resource::resource_manager Resources;
physics_world Physics;
ecs_runtime* ECSRuntime;
ecs_world* ECSWorld;
camera Camera;
camera PreviewCamera;
// Motion Matching
mm_profile_editor MMEditor;
mm_debug_settings MMDebug;
mm_timeline_state MMTimelineState;
testing_system TestingSystem;
spline_system SplineSystem;
bool OverlaySplines = false;
mm_entity_data MMEntityData;
bool UseHotReloading;
bool UpdatePathList;
bool UpdatePhysics;
// Models
rid SphereModelID;
rid LowPolySphereModelID;
rid UVSphereModelID;
rid QuadModelID;
rid GizmoModelID;
rid BoneDiamondModelID;
rid CubemapModelID;
// Temp textures (not their place)
int32_t CollapsedTextureID;
int32_t ExpandedTextureID;
// Entities
entity Entities[ENTITY_MAX_COUNT];
int32_t EntityCount;
int32_t SelectedEntityIndex;
int32_t SelectedMeshIndex;
// int32_t PlayerEntityIndex;
mat4 PrevFrameMVPMatrices[ENTITY_MAX_COUNT];
// Fonts/text
Text::font Font;
// Switches/Flags
bool DrawCubemap;
bool DrawGizmos;
bool DrawDebugLines;
bool DrawDebugSpheres;
bool DrawShadowCascadeVolumes;
bool DrawActorMeshes;
bool DrawActorSkeletons;
bool DrawTrajectoryWaypoints;
bool DrawTrajectoryLines;
bool DrawTrajectorySplines;
bool DrawSplinesLooped;
bool IsAnimationPlaying;
bool IsEntityCreationMode;
bool PreviewAnimationsInRootSpace;
bool ShowDebugFeatures;
float BoneSphereRadius;
uint32_t MagicChecksum;
uint32_t SelectionMode;
// ID buffer (selection)
uint32_t IndexFBO;
uint32_t DepthRBO;
uint32_t IDTexture;
};
void GetCubemapRIDs(rid* RIDs, Resource::resource_manager* Resources,
Memory::stack_allocator* const Allocator, char* CubemapPath, char* FileFormat);
void RegisterDebugModels(game_state* GameState);
uint32_t LoadCubemap(Resource::resource_manager* Resources, rid* RIDs);
void GenerateScreenQuad(uint32_t* VAO, uint32_t* VBO);
void GenerateFramebuffer(uint32_t* FBO, uint32_t* RBO, uint32_t* Texture, int Width = SCREEN_WIDTH,
int Height = SCREEN_HEIGHT);
void GenerateSSAOFrameBuffer(uint32_t* FBO, uint32_t* SSAOTextureID, int Width = SCREEN_WIDTH,
int Height = SCREEN_HEIGHT);
void GenerateFloatingPointFBO(uint32_t* FBO, uint32_t* ColorTextureID, uint32_t* DepthStencilRBO,
int Width = SCREEN_WIDTH, int Height = SCREEN_HEIGHT);
void GenerateGeometryDepthFrameBuffer(uint32_t* FBO, uint32_t* ViewSpacePositionTextureID,
uint32_t* VelocityTextureID, uint32_t* NormalTextureID,
uint32_t* DepthTextureID);
void GenerateDepthFramebuffer(uint32_t* FBO, uint32_t* Texture);
void GenerateShadowFramebuffer(uint32_t* FBO, uint32_t* Texture);
void BindNextFramebuffer(uint32_t* FBOs, uint32_t* CurrentFramebuffer);
void BindTextureAndSetNext(uint32_t* Textures, uint32_t* CurrentTexture);
void DrawTextureToFramebuffer(uint32_t VAO);
void DrawSkeleton(const Anim::skeleton* Skeleton, const mat4* HierarchicalModelSpaceMatrices,
mat4 MatModel, float JointSphereRadius, bool UseBoneDiamonds = true);
//-----------------------ENTITY RELATED UTILITY FUNCTIONS---------------------------
void AddEntity(game_state* GameState, rid ModelID, rid* MaterialIDs, transform Transform);
bool DeleteEntity(game_state* GameState, Resource::resource_manager* Resources, int32_t Index);
void RemoveReferencesAndResetAnimPlayer(Resource::resource_manager* Resources,
Anim::animation_player* AnimPlayer);
void RemoveAnimationPlayerComponent(game_state* GameState, Resource::resource_manager* Resources,
int32_t EntityIndex);
bool GetEntityAtIndex(game_state* GameState, entity** OutputEntity, int32_t EntityIndex);
void AttachEntityToAnimEditor(game_state* GameState, EditAnimation::animation_editor* Editor,
int32_t EntityIndex);
void DettachEntityFromAnimEditor(const game_state* GameState,
EditAnimation::animation_editor* Editor);
bool GetSelectedEntity(game_state* GameState, entity** OutputEntity);
bool GetSelectedMesh(game_state* GameState, Render::mesh** OutputMesh);
mat4 GetEntityModelMatrix(game_state* GameState, int32_t EntityIndex);
mat4 GetEntityMVPMatrix(game_state* GameState, int32_t EntityIndex);