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
|
||||
InitializeCommandQueue(command_queue_entry* Memory, s32 MemorySize)
|
||||
CommandQueue_Create(gs_memory_arena* Storage, u64 CommandMaxCount)
|
||||
{
|
||||
input_command_queue Result = {};
|
||||
Result.Size = MemorySize;
|
||||
Result.Size = CommandMaxCount;
|
||||
Result.Used = 0;
|
||||
Result.Commands = Memory;
|
||||
Result.Commands = PushArray(Storage, command_queue_entry, CommandMaxCount);
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Editor_HandleInput (app_state* State, rect2 WindowBounds, input_queue InputQueue
|
|||
}
|
||||
else
|
||||
{
|
||||
panel* PanelWithMouseOverIt = GetPanelContainingPoint(Mouse.Pos, State->PanelSystem.Panels + 0);
|
||||
panel* PanelWithMouseOverIt = PanelSystem_GetPanelContainingPoint(&State->PanelSystem, Mouse.Pos);
|
||||
if (!PanelWithMouseOverIt) { return; }
|
||||
State->HotPanel = PanelWithMouseOverIt;
|
||||
|
||||
|
@ -72,7 +72,6 @@ Editor_Update(app_state* State, context* Context, input_queue InputQueue)
|
|||
Context->Mouse.CursorType = CursorType_Arrow;
|
||||
State->WindowBounds = Context->WindowBounds;
|
||||
State->Interface.Mouse = Context->Mouse;
|
||||
State->Camera.AspectRatio = RectAspectRatio(Context->WindowBounds);
|
||||
|
||||
PanelSystem_UpdateLayout(&State->PanelSystem, State->WindowBounds);
|
||||
Editor_HandleInput(State, State->WindowBounds, InputQueue, Context->Mouse, *Context);
|
||||
|
|
|
@ -396,7 +396,7 @@ PanelSystem_UpdateLayout(panel_system* System, rect2 WindowBounds)
|
|||
}
|
||||
|
||||
internal panel*
|
||||
GetPanelContainingPoint(v2 Point, panel* Panel)
|
||||
GetPanelContainingPoint(panel* Panel, v2 Point)
|
||||
{
|
||||
panel* Result = 0;
|
||||
|
||||
|
@ -414,11 +414,11 @@ GetPanelContainingPoint(v2 Point, panel* Panel)
|
|||
{
|
||||
if (PointIsInRect(Panel->Left->Bounds, Point))
|
||||
{
|
||||
Result = GetPanelContainingPoint(Point, Panel->Left);
|
||||
Result = GetPanelContainingPoint(Panel->Left, Point);
|
||||
}
|
||||
else if (PointIsInRect(Panel->Right->Bounds, Point))
|
||||
{
|
||||
Result = GetPanelContainingPoint(Point, Panel->Right);
|
||||
Result = GetPanelContainingPoint(Panel->Right, Point);
|
||||
}
|
||||
}break;
|
||||
|
||||
|
@ -429,6 +429,14 @@ GetPanelContainingPoint(v2 Point, panel* Panel)
|
|||
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
|
||||
#endif // FOLDHAUS_PANEL_H
|
|
@ -254,7 +254,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(AddAnimationBlockCommand)
|
|||
{
|
||||
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);
|
||||
frame_range Range = ActiveAnim->PlayableRange;
|
||||
u32 MouseDownFrame = GetFrameFromPointInAnimationPanel(Mouse.Pos, ActivePanel->Bounds, Range);
|
||||
|
|
|
@ -5,11 +5,17 @@
|
|||
//
|
||||
#ifndef FOLDHAUS_PANEL_SCULPTURE_VIEW_H
|
||||
|
||||
struct sculpture_view_panel_state
|
||||
{
|
||||
camera Camera;
|
||||
};
|
||||
|
||||
// 3D Mouse View
|
||||
|
||||
OPERATION_STATE_DEF(mouse_rotate_view_operation_state)
|
||||
{
|
||||
v4 CameraStartPos;
|
||||
camera* Camera;
|
||||
};
|
||||
|
||||
OPERATION_RENDER_PROC(Update3DViewMouseRotate)
|
||||
|
@ -22,7 +28,7 @@ OPERATION_RENDER_PROC(Update3DViewMouseRotate)
|
|||
m44 YRotation = M44RotationY(TotalDeltaPos.x * State->PixelsToWorldScale);
|
||||
m44 Combined = XRotation * YRotation;
|
||||
|
||||
State->Camera.Position = (Combined * OpState->CameraStartPos).xyz;
|
||||
OpState->Camera->Position = (Combined * OpState->CameraStartPos).xyz;
|
||||
}
|
||||
|
||||
FOLDHAUS_INPUT_COMMAND_PROC(End3DViewMouseRotate)
|
||||
|
@ -36,11 +42,15 @@ input_command MouseRotateViewCommands [] = {
|
|||
|
||||
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);
|
||||
mouse_rotate_view_operation_state* OpState = CreateOperationState(RotateViewMode,
|
||||
&State->Modes,
|
||||
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
|
||||
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);
|
||||
|
@ -159,9 +178,10 @@ internal void
|
|||
SculptureView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context)
|
||||
{
|
||||
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;
|
||||
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->BatchReservedRange = ReserveRangeInQuadConstructor(JobData->Batch, JobLedCount * 2);
|
||||
JobData->LEDHalfWidth = .5f;
|
||||
JobData->CameraPosition = ToV4Point(State->Camera.Position);
|
||||
JobData->CameraPosition = ToV4Point(PanelState->Camera.Position);
|
||||
#if 1
|
||||
Context.GeneralWorkQueue->PushWorkOnQueue(Context.GeneralWorkQueue, (thread_proc*)DrawLEDsInBufferRangeJob, Data, ConstString("Sculpture Draw LEDS"));
|
||||
#else
|
||||
|
@ -204,7 +224,7 @@ SculptureView_Render(panel* Panel, rect2 PanelBounds, render_command_buffer* Ren
|
|||
led_buffer* LedBuffer = LedSystemGetBuffer(&State->LedSystem, Assembly.LedBufferIndex);
|
||||
|
||||
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);
|
||||
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 = {0};
|
||||
|
||||
s32 CommandQueueSize = 32;
|
||||
command_queue_entry* CommandQueueMemory = PushArray(&State->Permanent,
|
||||
command_queue_entry,
|
||||
CommandQueueSize);
|
||||
State->CommandQueue = InitializeCommandQueue(CommandQueueMemory, CommandQueueSize);
|
||||
State->CommandQueue = CommandQueue_Create(&State->Permanent, 32);
|
||||
|
||||
// TODO(Peter): put in InitializeInterface?
|
||||
r32 FontSize = 14;
|
||||
|
@ -117,13 +113,6 @@ INITIALIZE_APPLICATION(InitializeApplication)
|
|||
|
||||
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);
|
||||
|
||||
#if 1
|
||||
|
|
|
@ -62,7 +62,6 @@ struct app_state
|
|||
panel_system PanelSystem;
|
||||
panel* HotPanel;
|
||||
|
||||
camera Camera; // TODO(Peter): move into the sculpture view
|
||||
r32 PixelsToWorldScale;
|
||||
handle SelectedAnimationBlockHandle; // TODO(Peter): move into animation panel
|
||||
u32 SelectedAnimationLayer; // TODO(Peter): move into animation panel
|
||||
|
|
Loading…
Reference in New Issue