Handmade Hero » Forums » Code » day 365
people
39 posts
#10916 day 365
3 months ago Edited by people on Feb. 16, 2017, 11:18 a.m.

I know Casey likes to find bugs independently but seeing all that math just work when the card ray was properly included in the camera ray equation was too exciting to not post. I find it amazing when a whole bunch of abstract math becomes concrete and useful :)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
--- a/code/handmade_render_group.cpp
+++ b/code/handmade_render_group.cpp
@@ -119,11 +119,11 @@ PushBitmap(render_group *Group, object_transform\
 *ObjectTransform,

         if(ObjectTransform->Upright)
         {
-#if 0
+#if 1
+            v2 CardRyz = {0.25f, 0.75f};
             v2 CamPyz = Group->CameraP.yz;
-            v2 CamRyz = Entry->P.yz + Size.y*Group->CameraY.yz - Grou\
p->CameraP.yz;
+            v2 CamRyz = Entry->P.yz + Size.y*CardRyz - Group->CameraP\
.yz;
             v2 CardPyz = Entry->P.yz;
-            v2 CardRyz = {0.25f, 0.75f};
             
             v2 In = RayIntersect2(CamPyz, CamRyz, CardPyz, CardRyz);
             // TODO(casey): Use the input YAxis again.


I understand that mouse camera rotation direction is a preference, but it seems to me that if you imagine a sphere centered on the world you would have a preference for either rotating the world by attaching the mouse to the side of the sphere closest to you or attaching the mouse to the side of the sphere furthest away from you. At the moment the orbit is being controlled as if the mouse is attached to the far side of the sphere, but the pitch is being controlled as if it attached to the near side of the sphere. Maybe some people like to mix them together, and if this is intentional please ignore this, but if not, attaching both axes to the near or far side of the sphere might be a good idea.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
--- a/code/handmade_world_mode.cpp
+++ b/code/handmade_world_mode.cpp
@@ -778,7 +778,7 @@ UpdateAndRenderWorld(game_state *GameState, game_m\
ode_world *WorldMode, transien
         if(Input->AltDown && IsDown(Input->MouseButtons[PlatformMouse\
Button_Left]))
         {
             f32 RotationSpeed = 0.001f*Pi32;
-            WorldMode->DebugCameraOrbit += RotationSpeed*dMouseP.x;
+            WorldMode->DebugCameraOrbit -= RotationSpeed*dMouseP.x;
             WorldMode->DebugCameraPitch += RotationSpeed*dMouseP.y;
         }
         else if(Input->AltDown && IsDown(Input->MouseButtons[Platform\
MouseButton_Middle]))


Anyway, happy birthday and thankyou for the incredible effort of producing this series. Before handmade hero started I was lost in the caked layer of bull**** that seems to be inherent to the internet's view of the programming world.