MCPcopy Create free account
hub / github.com/assaultcube/AC / recomputecamera

Function recomputecamera

source/src/rendergl.cpp:504–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502}
503
504void recomputecamera()
505{
506 if((player1->state==CS_SPECTATE || player1->state==CS_DEAD) && !editmode)
507 {
508 switch(player1->spectatemode)
509 {
510 case SM_DEATHCAM:
511 {
512 static physent deathcam;
513 if(camera1==&deathcam) return;
514 deathcam = *(physent *)player1;
515 deathcam.reset();
516 deathcam.type = ENT_CAMERA;
517 deathcam.roll = 0;
518 deathcam.move = -1;
519 camera1 = &deathcam;
520 loopi(10) moveplayer(camera1, 10, true, 50);
521 break;
522 }
523 case SM_FLY:
524 {
525 resetcamera();
526 camera1->eyeheight = 1.0f;
527 if(camera1->pitch==-90) camera1->pitch = 0; // from SM_OVERVIEW; location/yaw may be ugly => use a playerstart
528 break;
529 }
530 case SM_OVERVIEW:
531 {
532 // TODO : fix water rendering
533 camera1->o.x = clmapdims.xm;
534 camera1->o.y = clmapdims.ym;
535 camera1->o.z = clmapdims.maxceil + 1;
536 camera1->pitch = -90;
537 camera1->yaw = 0;
538
539 disableraytable();
540 break;
541 }
542 case SM_FOLLOW1ST:
543 {
544 playerent *f = updatefollowplayer();
545 //if(!f) { togglespect(); return; }//why turn off spectating - better to switch to SM_FLY
546 if(!f){ player1->spectatemode = SM_FLY; recomputecamera(); return; }
547 camera1 = f;
548 break;
549 }
550 case SM_FOLLOW3RD:
551 case SM_FOLLOW3RD_TRANSPARENT:
552 {
553 playerent *p = updatefollowplayer();
554 //if(!p) { togglespect(); return; }//why turn off spectating - better to switch to SM_FLY
555 if(!p){ player1->spectatemode = SM_FLY; recomputecamera(); return; }
556 static physent followcam;
557 static playerent *lastplayer;
558 if(lastplayer != p || &followcam != camera1)
559 {
560 followcam = *(physent *)p;
561 followcam.type = ENT_CAMERA;

Callers 1

gl_drawframeFunction · 0.85

Calls 6

moveplayerFunction · 0.85
resetcameraFunction · 0.85
disableraytableFunction · 0.85
updatefollowplayerFunction · 0.85
loopiFunction · 0.70
resetMethod · 0.45

Tested by

no test coverage detected