Moved camera state into the state for each sculpture view
This commit is contained in:
parent
d5be2a2de8
commit
e9945df6ca
|
@ -86,12 +86,12 @@ GetCommandIndexInQueue(input_command_queue* Queue, input_command Command, input_
|
||||||
}
|
}
|
||||||
|
|
||||||
internal input_command_queue
|
internal input_command_queue
|
||||||
InitializeCommandQueue(command_queue_entry* Memory, s32 MemorySize)
|
CommandQueue_Create(gs_memory_arena* Storage, u64 CommandMaxCount)
|
||||||
{
|
{
|
||||||
input_command_queue Result = {};
|
input_command_queue Result = {};
|
||||||
Result.Size = MemorySize;
|
Result.Size = CommandMaxCount;
|
||||||
Result.Used = 0;
|
Result.Used = 0;
|
||||||
Result.Commands = Memory;
|
Result.Commands = PushArray(Storage, command_queue_entry, CommandMaxCount);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ Editor_HandleInput (app_state* State, rect2 WindowBounds, input_queue InputQueue
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
panel* PanelWithMouseOverIt = GetPanelContainingPoint(Mouse.Pos, State->PanelSystem.Panels + 0);
|
panel* PanelWithMouseOverIt = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Mouse.Pos);
|
||||||
if (!PanelWithMouseOverIt) { return; }
|
if (!PanelWithMouseOverIt) { return; }
|
||||||
State->HotPanel = PanelWithMouseOverIt;
|
State->HotPanel = PanelWithMouseOverIt;
|
||||||
|
|
||||||
|
@ -72,7 +72,6 @@ Editor_Update(app_state* State, context* Context, input_queue InputQueue)
|
||||||
Context->Mouse.CursorType = CursorType_Arrow;
|
Context->Mouse.CursorType = CursorType_Arrow;
|
||||||
State->WindowBounds = Context->WindowBounds;
|
State->WindowBounds = Context->WindowBounds;
|
||||||
State->Interface.Mouse = Context->Mouse;
|
State->Interface.Mouse = Context->Mouse;
|
||||||
State->Camera.AspectRatio = RectAspectRatio(Context->WindowBounds);
|
|
||||||
|
|
||||||
PanelSystem_UpdateLayout(&State->PanelSystem, State->WindowBounds);
|
PanelSystem_UpdateLayout(&State->PanelSystem, State->WindowBounds);
|
||||||
Editor_HandleInput(State, State->WindowBounds, InputQueue, Context->Mouse, *Context);
|
Editor_HandleInput(State, State->WindowBounds, InputQueue, Context->Mouse, *Context);
|
||||||
|
|
|
@ -396,7 +396,7 @@ PanelSystem_UpdateLayout(panel_system* System, rect2 WindowBounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal panel*
|
internal panel*
|
||||||
GetPanelContainingPoint(v2 Point, panel* Panel)
|
GetPanelContainingPoint(panel* Panel, v2 Point)
|
||||||
{
|
{
|
||||||
panel* Result = 0;
|
panel* Result = 0;
|
||||||
|
|
||||||
|
@ -414,11 +414,11 @@ GetPanelContainingPoint(v2 Point, panel* Panel)
|
||||||
{
|
{
|
||||||
if (PointIsInRect(Panel->Left->Bounds, Point))
|
if (PointIsInRect(Panel->Left->Bounds, Point))
|
||||||
{
|
{
|
||||||
Result = GetPanelContainingPoint(Point, Panel->Left);
|
Result = GetPanelContainingPoint(Panel->Left, Point);
|
||||||
}
|
}
|
||||||
else if (PointIsInRect(Panel->Right->Bounds, Point))
|
else if (PointIsInRect(Panel->Right->Bounds, Point))
|
||||||
{
|
{
|
||||||
Result = GetPanelContainingPoint(Point, Panel->Right);
|
Result = GetPanelContainingPoint(Panel->Right, Point);
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
@ -429,6 +429,14 @@ GetPanelContainingPoint(v2 Point, panel* Panel)
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal panel*
|
||||||
|
PanelSystem_GetPanelContainingPoint(panel_system* System, v2 Point)
|
||||||
|
{
|
||||||
|
panel* Result = 0;
|
||||||
|
panel* Root = System->Panels;
|
||||||
|
Result = GetPanelContainingPoint(Root, Point);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
#define FOLDHAUS_PANEL_H
|
#define FOLDHAUS_PANEL_H
|
||||||
#endif // FOLDHAUS_PANEL_H
|
#endif // FOLDHAUS_PANEL_H
|
|
@ -254,7 +254,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(AddAnimationBlockCommand)
|
||||||
{
|
{
|
||||||
animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem);
|
animation* ActiveAnim = AnimationSystem_GetActiveAnimation(&State->AnimationSystem);
|
||||||
|
|
||||||
panel* ActivePanel = GetPanelContainingPoint(Mouse.Pos, State->PanelSystem.Panels + 0);
|
panel* ActivePanel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Mouse.Pos);
|
||||||
animation_timeline_state* TimelineState = Panel_GetStateStruct(ActivePanel, animation_timeline_state);
|
animation_timeline_state* TimelineState = Panel_GetStateStruct(ActivePanel, animation_timeline_state);
|
||||||
frame_range Range = ActiveAnim->PlayableRange;
|
frame_range Range = ActiveAnim->PlayableRange;
|
||||||
u32 MouseDownFrame = GetFrameFromPointInAnimationPanel(Mouse.Pos, ActivePanel->Bounds, Range);
|
u32 MouseDownFrame = GetFrameFromPointInAnimationPanel(Mouse.Pos, ActivePanel->Bounds, Range);
|
||||||
|
|
|
@ -5,11 +5,17 @@
|
||||||
//
|
//
|
||||||
#ifndef FOLDHAUS_PANEL_SCULPTURE_VIEW_H
|
#ifndef FOLDHAUS_PANEL_SCULPTURE_VIEW_H
|
||||||
|
|
||||||
|
struct sculpture_view_panel_state
|
||||||
|
{
|
||||||
|
camera Camera;
|
||||||
|
};
|
||||||
|
|
||||||
// 3D Mouse View
|
// 3D Mouse View
|
||||||
|
|
||||||
OPERATION_STATE_DEF(mouse_rotate_view_operation_state)
|
OPERATION_STATE_DEF(mouse_rotate_view_operation_state)
|
||||||
{
|
{
|
||||||
v4 CameraStartPos;
|
v4 CameraStartPos;
|
||||||
|
camera* Camera;
|
||||||
};
|
};
|
||||||
|
|
||||||
OPERATION_RENDER_PROC(Update3DViewMouseRotate)
|
OPERATION_RENDER_PROC(Update3DViewMouseRotate)
|
||||||
|
@ -22,7 +28,7 @@ OPERATION_RENDER_PROC(Update3DViewMouseRotate)
|
||||||
m44 YRotation = M44RotationY(TotalDeltaPos.x * State->PixelsToWorldScale);
|
m44 YRotation = M44RotationY(TotalDeltaPos.x * State->PixelsToWorldScale);
|
||||||
m44 Combined = XRotation * YRotation;
|
m44 Combined = XRotation * YRotation;
|
||||||
|
|
||||||
State->Camera.Position = (Combined * OpState->CameraStartPos).xyz;
|
OpState->Camera->Position = (Combined * OpState->CameraStartPos).xyz;
|
||||||
}
|
}
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(End3DViewMouseRotate)
|
FOLDHAUS_INPUT_COMMAND_PROC(End3DViewMouseRotate)
|
||||||
|
@ -36,11 +42,15 @@ input_command MouseRotateViewCommands [] = {
|
||||||
|
|
||||||
FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate)
|
FOLDHAUS_INPUT_COMMAND_PROC(Begin3DViewMouseRotate)
|
||||||
{
|
{
|
||||||
|
panel* Panel = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Context.Mouse.DownPos);
|
||||||
|
sculpture_view_panel_state* PanelState = Panel_GetStateStruct(Panel, sculpture_view_panel_state);
|
||||||
|
|
||||||
operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, MouseRotateViewCommands, Update3DViewMouseRotate);
|
operation_mode* RotateViewMode = ActivateOperationModeWithCommands(&State->Modes, MouseRotateViewCommands, Update3DViewMouseRotate);
|
||||||
mouse_rotate_view_operation_state* OpState = CreateOperationState(RotateViewMode,
|
mouse_rotate_view_operation_state* OpState = CreateOperationState(RotateViewMode,
|
||||||
&State->Modes,
|
&State->Modes,
|
||||||
mouse_rotate_view_operation_state);
|
mouse_rotate_view_operation_state);
|
||||||
OpState->CameraStartPos = ToV4Point(State->Camera.Position);
|
OpState->CameraStartPos = ToV4Point(PanelState->Camera.Position);
|
||||||
|
OpState->Camera = &PanelState->Camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------
|
// ----------------
|
||||||
|
@ -57,7 +67,16 @@ GSMetaTag(panel_type_sculpture_view);
|
||||||
internal void
|
internal void
|
||||||
SculptureView_Init(panel* Panel, app_state* State, context Context)
|
SculptureView_Init(panel* Panel, app_state* State, context Context)
|
||||||
{
|
{
|
||||||
|
sculpture_view_panel_state* PanelState = PushStruct(&State->Permanent, sculpture_view_panel_state);
|
||||||
|
|
||||||
|
PanelState->Camera.FieldOfView = 45.0f;
|
||||||
|
PanelState->Camera.AspectRatio = RectAspectRatio(State->WindowBounds);
|
||||||
|
PanelState->Camera.Near = .1f;
|
||||||
|
PanelState->Camera.Far = 800.0f;
|
||||||
|
PanelState->Camera.Position = v3{0, 0, 400};
|
||||||
|
PanelState->Camera.LookAt = v3{0, 0, 0};
|
||||||
|
|
||||||
|
Panel->StateMemory = StructToData(PanelState, sculpture_view_panel_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
GSMetaTag(panel_cleanup);
|
GSMetaTag(panel_cleanup);
|
||||||
|
@ -159,9 +178,10 @@ internal void
|
||||||
SculptureView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context)
|
SculptureView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context)
|
||||||
{
|
{
|
||||||
DEBUG_TRACK_SCOPE(RenderSculpture);
|
DEBUG_TRACK_SCOPE(RenderSculpture);
|
||||||
State->Camera.AspectRatio = RectAspectRatio(PanelBounds);
|
sculpture_view_panel_state* PanelState = Panel_GetStateStruct(Panel, sculpture_view_panel_state);
|
||||||
|
PanelState->Camera.AspectRatio = RectAspectRatio(PanelBounds);
|
||||||
|
|
||||||
PushRenderPerspective(RenderBuffer, PanelBounds, State->Camera);
|
PushRenderPerspective(RenderBuffer, PanelBounds, PanelState->Camera);
|
||||||
|
|
||||||
u32 MaxLEDsPerJob = 2048;
|
u32 MaxLEDsPerJob = 2048;
|
||||||
render_quad_batch_constructor RenderLEDsBatch = PushRenderQuad3DBatch(RenderBuffer, State->LedSystem.LedsCountTotal);
|
render_quad_batch_constructor RenderLEDsBatch = PushRenderQuad3DBatch(RenderBuffer, State->LedSystem.LedsCountTotal);
|
||||||
|
@ -184,7 +204,7 @@ SculptureView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* Ren
|
||||||
JobData->Batch = &RenderLEDsBatch;
|
JobData->Batch = &RenderLEDsBatch;
|
||||||
JobData->BatchReservedRange = ReserveRangeInQuadConstructor(JobData->Batch, JobLedCount * 2);
|
JobData->BatchReservedRange = ReserveRangeInQuadConstructor(JobData->Batch, JobLedCount * 2);
|
||||||
JobData->LEDHalfWidth = .5f;
|
JobData->LEDHalfWidth = .5f;
|
||||||
JobData->CameraPosition = ToV4Point(State->Camera.Position);
|
JobData->CameraPosition = ToV4Point(PanelState->Camera.Position);
|
||||||
#if 1
|
#if 1
|
||||||
Context.GeneralWorkQueue->PushWorkOnQueue(Context.GeneralWorkQueue, (thread_proc*)DrawLEDsInBufferRangeJob, Data, ConstString("Sculpture Draw LEDS"));
|
Context.GeneralWorkQueue->PushWorkOnQueue(Context.GeneralWorkQueue, (thread_proc*)DrawLEDsInBufferRangeJob, Data, ConstString("Sculpture Draw LEDS"));
|
||||||
#else
|
#else
|
||||||
|
@ -204,7 +224,7 @@ SculptureView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* Ren
|
||||||
led_buffer* LedBuffer = LedSystemGetBuffer(&State->LedSystem, Assembly.LedBufferIndex);
|
led_buffer* LedBuffer = LedSystemGetBuffer(&State->LedSystem, Assembly.LedBufferIndex);
|
||||||
|
|
||||||
v4 LedPosition = LedBuffer->Positions[FocusPixel];
|
v4 LedPosition = LedBuffer->Positions[FocusPixel];
|
||||||
v2 LedOnScreenPosition = SculptureView_WorldToScreenPosition(LedPosition, State->Camera, PanelBounds);
|
v2 LedOnScreenPosition = SculptureView_WorldToScreenPosition(LedPosition, PanelState->Camera, PanelBounds);
|
||||||
|
|
||||||
gs_string Tempgs_string = PushString(State->Transient, 256);
|
gs_string Tempgs_string = PushString(State->Transient, 256);
|
||||||
PrintF(&Tempgs_string, "%f %f", LedOnScreenPosition.x, LedOnScreenPosition.y);
|
PrintF(&Tempgs_string, "%f %f", LedOnScreenPosition.x, LedOnScreenPosition.y);
|
||||||
|
|
|
@ -32,11 +32,7 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
State->GlobalLog = PushStruct(State->Transient, event_log);
|
State->GlobalLog = PushStruct(State->Transient, event_log);
|
||||||
*State->GlobalLog = {0};
|
*State->GlobalLog = {0};
|
||||||
|
|
||||||
s32 CommandQueueSize = 32;
|
State->CommandQueue = CommandQueue_Create(&State->Permanent, 32);
|
||||||
command_queue_entry* CommandQueueMemory = PushArray(&State->Permanent,
|
|
||||||
command_queue_entry,
|
|
||||||
CommandQueueSize);
|
|
||||||
State->CommandQueue = InitializeCommandQueue(CommandQueueMemory, CommandQueueSize);
|
|
||||||
|
|
||||||
// TODO(Peter): put in InitializeInterface?
|
// TODO(Peter): put in InitializeInterface?
|
||||||
r32 FontSize = 14;
|
r32 FontSize = 14;
|
||||||
|
@ -117,13 +113,6 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
||||||
|
|
||||||
State->SACN = SACN_Initialize(Context);
|
State->SACN = SACN_Initialize(Context);
|
||||||
|
|
||||||
State->Camera.FieldOfView = 45.0f;
|
|
||||||
State->Camera.AspectRatio = RectAspectRatio(State->WindowBounds);
|
|
||||||
State->Camera.Near = .1f;
|
|
||||||
State->Camera.Far = 800.0f;
|
|
||||||
State->Camera.Position = v3{0, 0, 400};
|
|
||||||
State->Camera.LookAt = v3{0, 0, 0};
|
|
||||||
|
|
||||||
State->LedSystem = LedSystemInitialize(Context.ThreadContext.Allocator, 128);
|
State->LedSystem = LedSystemInitialize(Context.ThreadContext.Allocator, 128);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
|
@ -62,7 +62,6 @@ struct app_state
|
||||||
panel_system PanelSystem;
|
panel_system PanelSystem;
|
||||||
panel* HotPanel;
|
panel* HotPanel;
|
||||||
|
|
||||||
camera Camera; // TODO(Peter): move into the sculpture view
|
|
||||||
r32 PixelsToWorldScale;
|
r32 PixelsToWorldScale;
|
||||||
handle SelectedAnimationBlockHandle; // TODO(Peter): move into animation panel
|
handle SelectedAnimationBlockHandle; // TODO(Peter): move into animation panel
|
||||||
u32 SelectedAnimationLayer; // TODO(Peter): move into animation panel
|
u32 SelectedAnimationLayer; // TODO(Peter): move into animation panel
|
||||||
|
|
Loading…
Reference in New Issue