Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Chase_Update Update Goto page Previous 1, 2

| Inside3d Forums Forum Index -> Engine Programming

View previous topic :: View next topic
Author | Message
--- | ---
reckless Joined: 24 Jan 2008 Posts: 390 Location: inside tha debugger |

Posted: Tue May 12, 2009 12:08 pm Post subject: |

agree minor update btw fixing an old bug in the traceline code not sure where i got it from but i think its some of aquires.

Code:
void Chase_Clip (vec3_t start, vec3_t end, vec3_t impact) { trace_t trace; qboolean result; memset (&trace, 0, sizeof(trace));
result = SV_RecursiveHullCheck (cl.worldmodel->hulls, 0, 0, 1, start, end, &trace);
// If result, don't use trace.endpos, otherwise view might suddenly point straight down
VectorCopy ((result ? end : trace.endpos), impact);
}

and removed some redundant code for alpha in this

Code:
void Chase_Adjust (vec3_t chase_dest) { // certain surfaces can be viewed at an oblique enough angle that they are partially clipped // by znear, so now we fix that too... int chase_vert[] = {0, 0, 1, 1, 2, 2};
int dest_offset[] = {CHASE_DEST_OFFSET, -CHASE_DEST_OFFSET};
// calculate distance between chasecam and original org to establish number of tests we need.
// an int is good enough here.:) add a cvar multiplier to this...
int num_tests = sqrt ((r_refdef.vieworg[0] - chase_dest[0]) * (r_refdef.vieworg[0] - chase_dest[0]) +
(r_refdef.vieworg[1] - chase_dest[1]) * (r_refdef.vieworg[1] - chase_dest[1]) +
(r_refdef.vieworg[2] - chase_dest[2]) * (r_refdef.vieworg[2] - chase_dest[2])) * chase_scale.value;
// take the contents of the view leaf
int viewcontents = (Mod_PointInLeaf (r_refdef.vieworg, cl.worldmodel))->contents;
int best;
// move along path from r_refdef.vieworg to chase_dest
for (best = 0; best < num_tests; best++)
{
vec3_t chase_newdest;
chase_newdest[0] = r_refdef.vieworg[0] + (chase_dest[0] - r_refdef.vieworg[0]) * best / num_tests;
chase_newdest[1] = r_refdef.vieworg[1] + (chase_dest[1] - r_refdef.vieworg[1]) * best / num_tests;
chase_newdest[2] = r_refdef.vieworg[2] + (chase_dest[2] - r_refdef.vieworg[2]) * best / num_tests;
// check for a leaf hit with different contents
if (!Chase_Check (chase_newdest, viewcontents))
{
// go back to the previous best as this one is bad
if (best > 1)
{
best--;
}
else
{
best = num_tests;
}
break;
}
}
// move along path from chase_dest to r_refdef.vieworg
// this one will early-out the vast majority of cases
for (/**/; best >= 0; best--)
{
// number of matches
int test, nummatches = 0;
// adjust
chase_dest[0] = r_refdef.vieworg[0] + (chase_dest[0] - r_refdef.vieworg[0]) * best / num_tests;
chase_dest[1] = r_refdef.vieworg[1] + (chase_dest[1] - r_refdef.vieworg[1]) * best / num_tests;
chase_dest[2] = r_refdef.vieworg[2] + (chase_dest[2] - r_refdef.vieworg[2]) * best / num_tests;
// run 6 tests: -x/+x/-y/+y/-z/+z
for (test = 0; test < 6; test++)
{
// adjust, test and put back.
chase_dest[chase_vert[test]] -= dest_offset[test & 1];
if (Chase_Check (chase_dest, viewcontents))
{
nummatches++;
}
chase_dest[chase_vert[test]] += dest_offset[test & 1];
}
// test result, if all match we're done in here
if (nummatches == 6) break;
}
}

btw not sure if this was intended ? when close to a wall the view shifts to inside the player so only the gun is visble.
its pretty close to good but methinks it should be offset a bit cause at some angles you look out from the players torso which looks kinda weird

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> Engine Programming | All times are GMT Goto page Previous 1, 2
Page 2 of 2

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group