From d2d8e0a07588b5bb25e4ef4bd7472664a4f416ac Mon Sep 17 00:00:00 2001 From: driAn Date: Tue, 6 May 2008 19:31:38 +0000 Subject: [PATCH] avoid spectator cam getting into map geometry git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1887 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/rendergl.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index de3276b9..e572ab3a 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -348,16 +348,17 @@ void recomputecamera() camera1 = &followcam; } followcam.o = p->o; + + // move camera into the desired direction using physics to avoid getting stuck in map geometry if(player1->spectating == SM_FOLLOWPLAYER) { - followcam.o.x -= (float)(cosf(RAD*(p->yaw-90)))*p->radius*1.5f; - followcam.o.y -= (float)(sinf(RAD*(p->yaw-90)))*p->radius*1.5f; - followcam.o.z += p->eyeheight/3.0f; - } - else - { - followcam.o.z += p->eyeheight/6.0f; + followcam.vel.x = -(float)(cosf(RAD*(p->yaw-90)))*p->radius*1.5f; + followcam.vel.y = -(float)(sinf(RAD*(p->yaw-90)))*p->radius*1.5f; + followcam.vel.z = p->eyeheight/3.0f; } + else followcam.vel.z = p->eyeheight/6.0f; + loopi(20) moveplayer(&followcam, 20, true, 50); + followcam.vel.x = followcam.vel.y = followcam.vel.z = 0.0f; followcam.yaw = p->yaw; break; }