X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=chase.c;h=1d0fe2a6b83a4fdf4a889f92d49b4cfe8be300bc;hb=efd89dee09ac8a3c6b31dd71d61dd5bca54ca6eb;hp=7633ff6cc9be4a3a815aeff8d06dc130a96c250b;hpb=837e8a44a74cd515d8bd2c6663131f69efa760f1;p=xonotic%2Fdarkplaces.git diff --git a/chase.c b/chase.c index 7633ff6c..1d0fe2a6 100644 --- a/chase.c +++ b/chase.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -20,16 +20,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // chase.c -- chase camera code #include "quakedef.h" +#include "cl_collision.h" -cvar_t chase_back = {"chase_back", "48", true}; -cvar_t chase_up = {"chase_up", "48", true}; -cvar_t chase_active = {"chase_active", "0", true}; +cvar_t chase_back = {CVAR_SAVE, "chase_back", "48"}; +cvar_t chase_up = {CVAR_SAVE, "chase_up", "24"}; +cvar_t chase_active = {CVAR_SAVE, "chase_active", "0"}; +// GAME_GOODVSBAD2 +cvar_t chase_stevie = {0, "chase_stevie", "0"}; void Chase_Init (void) { Cvar_RegisterVariable (&chase_back); Cvar_RegisterVariable (&chase_up); Cvar_RegisterVariable (&chase_active); + if (gamemode == GAME_GOODVSBAD2) + Cvar_RegisterVariable (&chase_stevie); } void Chase_Reset (void) @@ -38,38 +43,35 @@ void Chase_Reset (void) // start position 12 units behind head } -float TraceLine (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal) -{ - trace_t trace; - - memset (&trace, 0, sizeof(trace)); - VectorCopy (end, trace.endpos); - trace.fraction = 1; - SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace); - VectorCopy (trace.endpos, impact); - VectorCopy (trace.plane.normal, normal); - return trace.fraction; -} - void Chase_Update (void) { - vec3_t forward, stop, chase_dest, normal; - float dist; - - chase_back.value = bound(0, chase_back.value, 128); - chase_up.value = bound(-48, chase_up.value, 96); - - AngleVectors (cl.viewangles, forward, NULL, NULL); + vec_t camback, camup, dist, forward[3], stop[3], chase_dest[3], normal[3], projectangles[3]; + + camback = bound(0, chase_back.value, 128); + if (chase_back.value != camback) + Cvar_SetValueQuick(&chase_back, camback); + camup = bound(-48, chase_up.value, 96); + if (chase_up.value != camup) + Cvar_SetValueQuick(&chase_up, camup); + + VectorCopy(cl.viewangles, projectangles); + if (gamemode == GAME_GOODVSBAD2 && chase_stevie.integer) + { + projectangles[0] = 90; + r_refdef.viewangles[0] = 90; + camback = 1024; + } + AngleVectors (projectangles, forward, NULL, NULL); dist = -chase_back.value - 8; chase_dest[0] = r_refdef.vieworg[0] + forward[0] * dist; chase_dest[1] = r_refdef.vieworg[1] + forward[1] * dist; chase_dest[2] = r_refdef.vieworg[2] + forward[2] * dist + chase_up.value; - TraceLine (r_refdef.vieworg, chase_dest, stop, normal); - chase_dest[0] = stop[0] + forward[0] * 8; - chase_dest[1] = stop[1] + forward[1] * 8; - chase_dest[2] = stop[2] + forward[2] * 8; + CL_TraceLine (r_refdef.vieworg, chase_dest, stop, normal, 0, true, NULL); + chase_dest[0] = stop[0] + forward[0] * 8 + normal[0] * 4; + chase_dest[1] = stop[1] + forward[1] * 8 + normal[1] * 4; + chase_dest[2] = stop[2] + forward[2] * 8 + normal[2] * 4; VectorCopy (chase_dest, r_refdef.vieworg); }