@@ -74,7 +74,7 @@ void UpdateDrawFrame(void); // Update and Draw one frame
74
74
75
75
void DrawLevel ();
76
76
77
- void UpdateCameraAngle (Camera * camera , Vector2 * rot , float headTimer , float walkLerp , Vector2 lean );
77
+ void UpdateCameraAngle ();
78
78
79
79
void UpdateBody (Body * body , float rot , char side , char forward , bool jumpPressed , bool crouchHold );
80
80
@@ -167,7 +167,7 @@ void UpdateDrawFrame(void)
167
167
lean .x = Lerp (lean .x , sideway * 0.02f , 10.f * delta );
168
168
lean .y = Lerp (lean .y , forward * 0.015f , 10.f * delta );
169
169
170
- UpdateCameraAngle (& camera , & lookRotation , headTimer , walkLerp , lean );
170
+ UpdateCameraAngle ();
171
171
172
172
// Draw
173
173
//----------------------------------------------------------------------------------
@@ -272,46 +272,46 @@ void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed
272
272
}
273
273
}
274
274
275
- void UpdateCameraAngle (Camera * camera , Vector2 * rot , float headTimer , float walkLerp , Vector2 lean )
275
+ void UpdateCameraAngle ()
276
276
{
277
277
const Vector3 up = (Vector3 ){ 0.f , 1.f , 0.f };
278
278
const Vector3 targetOffset = (Vector3 ){ 0.f , 0.f , -1.f };
279
279
280
280
/* Left & Right */
281
- Vector3 yaw = Vector3RotateByAxisAngle (targetOffset , up , rot -> x );
281
+ Vector3 yaw = Vector3RotateByAxisAngle (targetOffset , up , lookRotation . x );
282
282
283
283
// Clamp view up
284
284
float maxAngleUp = Vector3Angle (up , yaw );
285
285
maxAngleUp -= 0.001f ; // avoid numerical errors
286
- if ( - (rot -> y ) > maxAngleUp ) { rot -> y = - maxAngleUp ; }
286
+ if ( - (lookRotation . y ) > maxAngleUp ) { lookRotation . y = - maxAngleUp ; }
287
287
288
288
// Clamp view down
289
289
float maxAngleDown = Vector3Angle (Vector3Negate (up ), yaw );
290
290
maxAngleDown *= -1.0f ; // downwards angle is negative
291
291
maxAngleDown += 0.001f ; // avoid numerical errors
292
- if ( - (rot -> y ) < maxAngleDown ) { rot -> y = - maxAngleDown ; }
292
+ if ( - (lookRotation . y ) < maxAngleDown ) { lookRotation . y = - maxAngleDown ; }
293
293
294
294
/* Up & Down */
295
295
Vector3 right = Vector3Normalize (Vector3CrossProduct (yaw , up ));
296
296
297
297
// Rotate view vector around right axis
298
- Vector3 pitch = Vector3RotateByAxisAngle (yaw , right , - rot -> y - lean .y );
298
+ Vector3 pitch = Vector3RotateByAxisAngle (yaw , right , - lookRotation . y - lean .y );
299
299
300
300
// Head animation
301
301
// Rotate up direction around forward axis
302
302
float _sin = sin (headTimer * PI );
303
303
float _cos = cos (headTimer * PI );
304
304
const float stepRotation = 0.01f ;
305
- camera -> up = Vector3RotateByAxisAngle (up , pitch , _sin * stepRotation + lean .x );
305
+ camera . up = Vector3RotateByAxisAngle (up , pitch , _sin * stepRotation + lean .x );
306
306
307
307
/* BOB */
308
308
const float bobSide = 0.1f ;
309
309
const float bobUp = 0.15f ;
310
310
Vector3 bobbing = Vector3Scale (right , _sin * bobSide );
311
311
bobbing .y = fabsf (_cos * bobUp );
312
- camera -> position = Vector3Add (camera -> position , Vector3Scale (bobbing , walkLerp ));
312
+ camera . position = Vector3Add (camera . position , Vector3Scale (bobbing , walkLerp ));
313
313
314
- camera -> target = Vector3Add (camera -> position , pitch );
314
+ camera . target = Vector3Add (camera . position , pitch );
315
315
}
316
316
317
317
0 commit comments