Pulled the universe view into the new modes system
This commit is contained in:
parent
e51400c313
commit
b2579a45b7
|
@ -352,8 +352,7 @@ RELOAD_STATIC_DATA(ReloadStaticData)
|
||||||
{
|
{
|
||||||
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_MouseLeftButton, true, KeyCode_Invalid,
|
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_MouseLeftButton, true, KeyCode_Invalid,
|
||||||
CameraMouseControl);
|
CameraMouseControl);
|
||||||
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_U, false, KeyCode_Invalid, ToggleUniverseDebugView);
|
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_U, false, KeyCode_Invalid, OpenUniverseView);
|
||||||
RegisterMouseWheelCommand(&State->InputCommandRegistry, CameraMouseZoom);
|
|
||||||
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_A, false, KeyCode_Invalid, OpenNodeLister);
|
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_A, false, KeyCode_Invalid, OpenNodeLister);
|
||||||
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_Tab, false, KeyCode_Invalid, ToggleNodeDisplay);
|
RegisterKeyPressCommand(&State->InputCommandRegistry, KeyCode_Tab, false, KeyCode_Invalid, ToggleNodeDisplay);
|
||||||
|
|
||||||
|
@ -475,9 +474,6 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
|
|
||||||
State->PixelsToWorldScale = .01f;
|
State->PixelsToWorldScale = .01f;
|
||||||
|
|
||||||
State->UniverseOutputDisplayOffset = v2{0, 0};
|
|
||||||
State->UniverseOutputDisplayZoom = 1.0f;
|
|
||||||
|
|
||||||
GlobalDebugServices->Interface.RenderSculpture = true;
|
GlobalDebugServices->Interface.RenderSculpture = true;
|
||||||
|
|
||||||
State->NodeList = AllocateNodeList(State->Permanent, Kilobytes(64));
|
State->NodeList = AllocateNodeList(State->Permanent, Kilobytes(64));
|
||||||
|
@ -719,57 +715,6 @@ UPDATE_AND_RENDER(UpdateAndRender)
|
||||||
|
|
||||||
PushRenderOrthographic(RenderBuffer, 0, 0, Context.WindowWidth, Context.WindowHeight);
|
PushRenderOrthographic(RenderBuffer, 0, 0, Context.WindowWidth, Context.WindowHeight);
|
||||||
|
|
||||||
// Universe Data View
|
|
||||||
if (State->DrawUniverseOutputDisplay)
|
|
||||||
{
|
|
||||||
DEBUG_TRACK_SCOPE(DrawUniverseOutputDisplay);
|
|
||||||
|
|
||||||
string TitleBarString = InitializeEmptyString(PushArray(State->Transient, char, 64), 64);
|
|
||||||
|
|
||||||
v2 DisplayArea_Dimension = v2{600, 600};
|
|
||||||
v2 DisplayContents_Offset = State->UniverseOutputDisplayOffset;
|
|
||||||
v2 DisplayArea_TopLeft = v2{300, Context.WindowHeight - 50} + DisplayContents_Offset;
|
|
||||||
v2 UniverseDisplayDimension = v2{100, 100} * State->UniverseOutputDisplayZoom;
|
|
||||||
v2 Padding = v2{25, 50} * State->UniverseOutputDisplayZoom;
|
|
||||||
|
|
||||||
v2 UniverseDisplayTopLeft = DisplayArea_TopLeft;
|
|
||||||
|
|
||||||
sacn_universe_buffer* UniverseList = State->SACN.UniverseBuffer;
|
|
||||||
while(UniverseList)
|
|
||||||
{
|
|
||||||
for (s32 UniverseIdx = 0;
|
|
||||||
UniverseIdx < UniverseList->Used;
|
|
||||||
UniverseIdx++)
|
|
||||||
{
|
|
||||||
sacn_universe* Universe = UniverseList->Universes + UniverseIdx;
|
|
||||||
|
|
||||||
DrawSACNUniversePixels(RenderBuffer, Universe,
|
|
||||||
UniverseDisplayTopLeft, UniverseDisplayDimension);
|
|
||||||
|
|
||||||
if (State->UniverseOutputDisplayZoom > .5f)
|
|
||||||
{
|
|
||||||
v2 TitleDisplayStart = UniverseDisplayTopLeft + v2{0, 12};
|
|
||||||
PrintF(&TitleBarString, "Universe %d", Universe->Universe);
|
|
||||||
DrawString(RenderBuffer, TitleBarString, State->Interface.Font, 12,
|
|
||||||
TitleDisplayStart, WhiteV4);
|
|
||||||
}
|
|
||||||
|
|
||||||
UniverseDisplayTopLeft.x += UniverseDisplayDimension.x + Padding.x;
|
|
||||||
if (UniverseDisplayTopLeft.x > DisplayArea_TopLeft.x + DisplayArea_Dimension.x)
|
|
||||||
{
|
|
||||||
UniverseDisplayTopLeft.x = DisplayArea_TopLeft.x;
|
|
||||||
UniverseDisplayTopLeft.y -= UniverseDisplayDimension.y + Padding.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UniverseDisplayTopLeft.y < DisplayArea_TopLeft.y - DisplayArea_Dimension.y)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UniverseList = UniverseList->Next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// Menu Bar
|
// Menu Bar
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
|
@ -97,12 +97,6 @@ struct app_state
|
||||||
r32 PixelsToWorldScale;
|
r32 PixelsToWorldScale;
|
||||||
v4 Camera_StartDragPos;
|
v4 Camera_StartDragPos;
|
||||||
|
|
||||||
b32 DrawUniverseOutputDisplay;
|
|
||||||
v2 UniverseOutputDisplayOffset;
|
|
||||||
r32 UniverseOutputDisplayZoom;
|
|
||||||
|
|
||||||
v2 NodeListMenuPosition;
|
|
||||||
|
|
||||||
node_list* NodeList;
|
node_list* NodeList;
|
||||||
node_interaction NodeInteraction;
|
node_interaction NodeInteraction;
|
||||||
node_render_settings NodeRenderSettings;
|
node_render_settings NodeRenderSettings;
|
||||||
|
|
|
@ -7,35 +7,13 @@ FOLDHAUS_INPUT_COMMAND_PROC(CameraMouseControl)
|
||||||
State->Camera_StartDragPos = V4(State->Camera.Position, 1);
|
State->Camera_StartDragPos = V4(State->Camera.Position, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!State->DrawUniverseOutputDisplay)
|
v2 TotalDeltaPos = Mouse.Pos - Mouse.DownPos;
|
||||||
{
|
|
||||||
v2 TotalDeltaPos = Mouse.Pos - Mouse.DownPos;
|
|
||||||
|
|
||||||
m44 XRotation = GetXRotation(-TotalDeltaPos.y * State->PixelsToWorldScale);
|
|
||||||
m44 YRotation = GetYRotation(TotalDeltaPos.x * State->PixelsToWorldScale);
|
|
||||||
m44 Combined = XRotation * YRotation;
|
|
||||||
|
|
||||||
State->Camera.Position = V3(Combined * State->Camera_StartDragPos);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
State->UniverseOutputDisplayOffset += Mouse.DeltaPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(CameraMouseZoom)
|
|
||||||
{
|
|
||||||
if (State->DrawUniverseOutputDisplay)
|
|
||||||
{
|
|
||||||
r32 DeltaZoom = (r32)(Mouse.Scroll) / 120;
|
|
||||||
State->UniverseOutputDisplayZoom = GSClamp(0.1f, State->UniverseOutputDisplayZoom + DeltaZoom, 4.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
m44 XRotation = GetXRotation(-TotalDeltaPos.y * State->PixelsToWorldScale);
|
||||||
|
m44 YRotation = GetYRotation(TotalDeltaPos.x * State->PixelsToWorldScale);
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(ToggleUniverseDebugView)
|
m44 Combined = XRotation * YRotation;
|
||||||
{
|
|
||||||
State->DrawUniverseOutputDisplay = !State->DrawUniverseOutputDisplay;
|
State->Camera.Position = V3(Combined * State->Camera_StartDragPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(ToggleNodeDisplay)
|
FOLDHAUS_INPUT_COMMAND_PROC(ToggleNodeDisplay)
|
||||||
|
@ -49,9 +27,107 @@ FOLDHAUS_INPUT_COMMAND_PROC(ToggleNodeDisplay)
|
||||||
//
|
//
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
|
|
||||||
|
struct universe_view_operation_state
|
||||||
|
{
|
||||||
|
v2 DisplayOffset;
|
||||||
|
r32 Zoom;
|
||||||
|
};
|
||||||
|
|
||||||
OPERATION_RENDER_PROC(RenderUniverseView)
|
OPERATION_RENDER_PROC(RenderUniverseView)
|
||||||
{
|
{
|
||||||
|
DEBUG_TRACK_SCOPE(DrawUniverseOutputDisplay);
|
||||||
|
|
||||||
|
// TODO(Peter): Pass this in as a parameter
|
||||||
|
operation_mode Mode = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1];
|
||||||
|
universe_view_operation_state* OpState = (universe_view_operation_state*)Mode.OpStateMemory;
|
||||||
|
|
||||||
|
string TitleBarString = InitializeEmptyString(PushArray(State->Transient, char, 64), 64);
|
||||||
|
|
||||||
|
v2 DisplayArea_Dimension = v2{600, 600};
|
||||||
|
v2 DisplayContents_Offset = OpState->DisplayOffset;
|
||||||
|
v2 DisplayArea_TopLeft = v2{300, (r32)RenderBuffer->ViewHeight - 50} + DisplayContents_Offset;
|
||||||
|
v2 UniverseDisplayDimension = v2{100, 100} * OpState->Zoom;
|
||||||
|
v2 Padding = v2{25, 50} * OpState->Zoom;
|
||||||
|
|
||||||
|
v2 UniverseDisplayTopLeft = DisplayArea_TopLeft;
|
||||||
|
|
||||||
|
sacn_universe_buffer* UniverseList = State->SACN.UniverseBuffer;
|
||||||
|
while(UniverseList)
|
||||||
|
{
|
||||||
|
for (s32 UniverseIdx = 0;
|
||||||
|
UniverseIdx < UniverseList->Used;
|
||||||
|
UniverseIdx++)
|
||||||
|
{
|
||||||
|
sacn_universe* Universe = UniverseList->Universes + UniverseIdx;
|
||||||
|
|
||||||
|
DrawSACNUniversePixels(RenderBuffer, Universe,
|
||||||
|
UniverseDisplayTopLeft, UniverseDisplayDimension);
|
||||||
|
|
||||||
|
if (OpState->Zoom > .5f)
|
||||||
|
{
|
||||||
|
v2 TitleDisplayStart = UniverseDisplayTopLeft + v2{0, 12};
|
||||||
|
PrintF(&TitleBarString, "Universe %d", Universe->Universe);
|
||||||
|
DrawString(RenderBuffer, TitleBarString, State->Interface.Font, 12,
|
||||||
|
TitleDisplayStart, WhiteV4);
|
||||||
|
}
|
||||||
|
|
||||||
|
UniverseDisplayTopLeft.x += UniverseDisplayDimension.x + Padding.x;
|
||||||
|
if (UniverseDisplayTopLeft.x > DisplayArea_TopLeft.x + DisplayArea_Dimension.x)
|
||||||
|
{
|
||||||
|
UniverseDisplayTopLeft.x = DisplayArea_TopLeft.x;
|
||||||
|
UniverseDisplayTopLeft.y -= UniverseDisplayDimension.y + Padding.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UniverseDisplayTopLeft.y < DisplayArea_TopLeft.y - DisplayArea_Dimension.y)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UniverseList = UniverseList->Next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(Peter): Something isn't working with my laptop trackpad's zoom
|
||||||
|
FOLDHAUS_INPUT_COMMAND_PROC(UniverseZoom)
|
||||||
|
{
|
||||||
|
// TODO(Peter): Pass this in as a parameter
|
||||||
|
operation_mode Mode = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1];
|
||||||
|
universe_view_operation_state* OpState = (universe_view_operation_state*)Mode.OpStateMemory;
|
||||||
|
r32 DeltaZoom = (r32)(Mouse.Scroll) / 120;
|
||||||
|
OpState->Zoom = GSClamp(0.1f, OpState->Zoom + DeltaZoom, 4.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
FOLDHAUS_INPUT_COMMAND_PROC(UniverseViewPan)
|
||||||
|
{
|
||||||
|
// TODO(Peter): Pass this in as a parameter
|
||||||
|
operation_mode Mode = State->Modes.ActiveModes[State->Modes.ActiveModesCount - 1];
|
||||||
|
universe_view_operation_state* OpState = (universe_view_operation_state*)Mode.OpStateMemory;
|
||||||
|
OpState->DisplayOffset += Mouse.DeltaPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
FOLDHAUS_INPUT_COMMAND_PROC(CloseUniverseView)
|
||||||
|
{
|
||||||
|
DeactivateCurrentOperationMode(&State->Modes);
|
||||||
|
}
|
||||||
|
|
||||||
|
FOLDHAUS_INPUT_COMMAND_PROC(OpenUniverseView)
|
||||||
|
{
|
||||||
|
operation_mode* UniverseViewMode = ActivateOperationMode(&State->Modes);
|
||||||
|
UniverseViewMode->Render = RenderUniverseView;
|
||||||
|
|
||||||
|
{ // Mode Commands
|
||||||
|
InitializeInputCommandRegistry(&UniverseViewMode->Commands, 3, &State->Modes.Arena);
|
||||||
|
RegisterKeyPressCommand(&UniverseViewMode->Commands, KeyCode_MouseLeftButton, true, KeyCode_Invalid, UniverseViewPan);
|
||||||
|
RegisterKeyPressCommand(&UniverseViewMode->Commands, KeyCode_U, false, KeyCode_Invalid, CloseUniverseView);
|
||||||
|
RegisterMouseWheelCommand(&UniverseViewMode->Commands, UniverseZoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
// State Setup
|
||||||
|
universe_view_operation_state* OpState = CreateOperationState(UniverseViewMode,
|
||||||
|
&State->Modes,
|
||||||
|
universe_view_operation_state);
|
||||||
|
OpState->DisplayOffset = v2{0, 0};
|
||||||
|
OpState->Zoom = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
@ -63,13 +139,14 @@ OPERATION_RENDER_PROC(RenderUniverseView)
|
||||||
struct node_lister_operation_state
|
struct node_lister_operation_state
|
||||||
{
|
{
|
||||||
search_lister SearchLister;
|
search_lister SearchLister;
|
||||||
|
v2 ListPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
OPERATION_RENDER_PROC(RenderNodeLister)
|
OPERATION_RENDER_PROC(RenderNodeLister)
|
||||||
{
|
{
|
||||||
node_lister_operation_state* OpState = (node_lister_operation_state*)Operation.OpStateMemory;
|
node_lister_operation_state* OpState = (node_lister_operation_state*)Operation.OpStateMemory;
|
||||||
|
|
||||||
v2 TopLeft = State->NodeListMenuPosition;
|
v2 TopLeft = OpState->ListPosition;
|
||||||
v2 Dimension = v2{300, 30};
|
v2 Dimension = v2{300, 30};
|
||||||
|
|
||||||
// Filter the lister
|
// Filter the lister
|
||||||
|
@ -139,8 +216,9 @@ FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister)
|
||||||
|
|
||||||
AddNodeOperation->Render = RenderNodeLister;
|
AddNodeOperation->Render = RenderNodeLister;
|
||||||
|
|
||||||
node_lister_operation_state* OpState = PushStruct(&State->Modes.Arena, node_lister_operation_state);
|
node_lister_operation_state* OpState = CreateOperationState(AddNodeOperation,
|
||||||
AddNodeOperation->OpStateMemory = (u8*)OpState;
|
&State->Modes,
|
||||||
|
node_lister_operation_state);
|
||||||
{
|
{
|
||||||
OpState->SearchLister.SourceListCount = NodeSpecificationsCount;
|
OpState->SearchLister.SourceListCount = NodeSpecificationsCount;
|
||||||
OpState->SearchLister.SourceList = PushArray(&State->Modes.Arena, string, OpState->SearchLister.SourceListCount);
|
OpState->SearchLister.SourceList = PushArray(&State->Modes.Arena, string, OpState->SearchLister.SourceListCount);
|
||||||
|
@ -160,6 +238,6 @@ FOLDHAUS_INPUT_COMMAND_PROC(OpenNodeLister)
|
||||||
OpState->SearchLister.FilteredIndexLUT = PushArray(&State->Modes.Arena, s32, OpState->SearchLister.SourceListCount);
|
OpState->SearchLister.FilteredIndexLUT = PushArray(&State->Modes.Arena, s32, OpState->SearchLister.SourceListCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
State->NodeListMenuPosition = Mouse.Pos;
|
OpState->ListPosition = Mouse.Pos;
|
||||||
SetTextInputDestinationToString(&State->ActiveTextEntry, &State->GeneralPurposeSearchString);
|
SetTextInputDestinationToString(&State->ActiveTextEntry, &State->GeneralPurposeSearchString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,4 +38,14 @@ DeactivateCurrentOperationMode (operation_mode_system* System)
|
||||||
Assert(System->ActiveModesCount > 0);
|
Assert(System->ActiveModesCount > 0);
|
||||||
s32 ModeIndex = --System->ActiveModesCount;
|
s32 ModeIndex = --System->ActiveModesCount;
|
||||||
ClearArenaToSnapshot(&System->Arena, System->ModeMemorySnapshots[ModeIndex]);
|
ClearArenaToSnapshot(&System->Arena, System->ModeMemorySnapshots[ModeIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CreateOperationState(mode, modeSystem, stateType) \
|
||||||
|
(stateType*)CreateOperationState_(mode, modeSystem, sizeof(stateType))
|
||||||
|
|
||||||
|
internal u8*
|
||||||
|
CreateOperationState_ (operation_mode* Mode, operation_mode_system* System, s32 StateSize)
|
||||||
|
{
|
||||||
|
Mode->OpStateMemory = PushSize(&System->Arena, StateSize);
|
||||||
|
return Mode->OpStateMemory;
|
||||||
}
|
}
|
|
@ -628,8 +628,11 @@ INT NCmdShow
|
||||||
|
|
||||||
// TODO(Peter): We shouldn't need to do this translation. the platform layer knows about win32_windows. We should just make that the interface
|
// TODO(Peter): We shouldn't need to do this translation. the platform layer knows about win32_windows. We should just make that the interface
|
||||||
// to all windows.
|
// to all windows.
|
||||||
|
// TODO(Peter): Decide which we want to use, context or renderbuffer. Should only be one
|
||||||
Context.WindowWidth = MainWindow.Width;
|
Context.WindowWidth = MainWindow.Width;
|
||||||
Context.WindowHeight = MainWindow.Height;
|
Context.WindowHeight = MainWindow.Height;
|
||||||
|
RenderBuffer.ViewWidth = MainWindow.Width;
|
||||||
|
RenderBuffer.ViewHeight = MainWindow.Height;
|
||||||
Context.DeltaTime = LastFrameSecondsElapsed;
|
Context.DeltaTime = LastFrameSecondsElapsed;
|
||||||
|
|
||||||
Context.UpdateAndRender(Context, InputQueue, Mouse, &RenderBuffer);
|
Context.UpdateAndRender(Context, InputQueue, Mouse, &RenderBuffer);
|
||||||
|
|
4
todo.txt
4
todo.txt
|
@ -1,7 +1,7 @@
|
||||||
TODO FOLDHAUS
|
TODO FOLDHAUS
|
||||||
|
|
||||||
Intermediate Lifetime Memory & Operations
|
Intermediate Lifetime Memory & Operations
|
||||||
- Intermediate lifetime memory arena
|
x Intermediate lifetime memory arena
|
||||||
- Temporary memory region = a multi frame operation
|
- Temporary memory region = a multi frame operation
|
||||||
- Concept of an operation - temporary memory + interface command registry
|
- Concept of an operation - temporary memory + interface command registry
|
||||||
- Allow one operation at a time at first
|
- Allow one operation at a time at first
|
||||||
|
@ -9,7 +9,7 @@ Intermediate Lifetime Memory & Operations
|
||||||
- Current Operations:
|
- Current Operations:
|
||||||
- - View Sculpture
|
- - View Sculpture
|
||||||
- - View/Edit Nodes
|
- - View/Edit Nodes
|
||||||
- - Add Node (needs nesting)
|
- x Add Node (needs nesting)
|
||||||
- - View SACN
|
- - View SACN
|
||||||
|
|
||||||
- Why does backspacing in text entry not save when you close and reopen the node lister?
|
- Why does backspacing in text entry not save when you close and reopen the node lister?
|
||||||
|
|
Loading…
Reference in New Issue