alright, i haven't had time to try get this working properly since my last post, and i can't get the 3D line stuff working (line_3d or whatever is undocumented as it is in beta, and 2D line calculations aren't worth my time at the moment as i've already explained my workaround). my biggest problem is that people don't seem to understand the problem, and i didn't like this being dismissed as a coding error but i couldn't explain it well enough so i conceded to this topic being moved here. so i thought i'd give explaining it one last go:
Code:
vec_for_vertex(temp,me,g[d]);
vec_set(wheelpos[d][0],up);
vec_inverse(wheelpos[d][0]);
vec_normalize(wheelpos[d][0],48);
vec_add(wheelpos[d][0],temp);
result = c_trace(temp,wheelpos[d][0],IGNORE_ME|IGNORE_PASSENTS|IGNORE_PASSABLE);
debugger[d] = result;
you = wheel[d];
if(trace_hit)
{
gdist[d] = 4-result/12;
vec_set(you.x,target);
}
okay, that's basically a copy of the code from the first post, so it's easier for u (whoever reads this) to view as u read my explanation. that is exactly how it appeared in my script, except "[d]" was "[ i]", but [ i] makes things
italics in this forum so that wasn't working so well.
variable details:
temp <- GLOBAL VECTOR
g[4] <- LOCAL ARRAY STORES THE VERTEX NUMBERS CORRESPONDING TO POINTS ON THE CAR EACH WHEEL PROTRUDES FROM
wheelpos[4][3] <- LOCAL 2-DIMENSIONAL ARRAY CONTAINING THE POSITION EACH WHEEL IS PROJECTED TOWARDS
result <- LENGTH OF C_TRACE
debugger[4] <- GLOBAL ARRAY DISPLAYED ON A PANEL
wheel[4] <- LOCAL ARRAY OF POINTERS POINTING TO EACH WHEEL
gdist[4] <- LOCAL ARRAY STORES THE PRESSURE ON EACH WHEEL, FROM 0 to 1.0
alright. i'm using lite-c, so multi-dimensional arrays and arrays of pointers are allowed. each wheel is passable, and so can not be seen by the c_trace. this snippet is contained within a while loop "while(d>0)" and the line just before the snippet is "d -= 1;". before the while loop, "d = 4;". this loop iterates through the above snippet for each wheel, basically.
for each wheel, it will get the global position of each vertex of the car that corresponds to the wheel's position with maximum pressure on it. basically, its like the suspension is completely pushed together. it then traces towards the point where the wheels should be with no pressure on them -- with the suspension fully extended. then, it puts the wheel at the target (which should be between these two positions) and sets gdist[d] (which contains the pressure on each wheel) to a percentage of pressure, where 0% means nothing was hit and 100% means the wheel is pressed up against the car as close as it can get.
i hope i explained that well enough, but either way, this always works perfectly. well, almost always. from what i can guess, c_trace checks for entities whose bounds mean they could be hit by a ray moving in the direction from vectorFrom to vectorTo. then it goes through those entities, and if they are further away than the distance between vectorFrom and vectorTo, they are skipped. the bug i'm experiencing is that some of them aren't getting skipped. my level, which consists of a model with its POLYGON flag turned on, has no problems with the car, and the car's wheels will only react if they get within 48 quants of the surface. that's good.
however, if the direction of the car's c_trace points towards my other car, which is using ellipsoidal collision, that car is still traced even if it isn't within range! the wheel jumps to that position, as far as 170 (roughly) quants away, even though the distance between vectorFrom and vectorTo is 48. this means c_trace is tracing in the direction from vectorFrom to vectorTo, but not stopping at vectorTo. additionally, this problem doesn't occur if the cars have their POLYGON flags set.
visually:
Code:
(car1)*------------* (car2)
//the first asterisk represents vectorFrom, the second asterisk represents
//vectorTo. the hyphens represent the c_trace, and "(car2)" is the other car.
//that's what should be happening, but instead:
(car1)*------------*-------------------(car2)
//the c_trace from car1 goes through vectorTo and continues until it hits car2, provided car2 is in that direction.
if you go through my code step by step, you'll see that result should never possibly be greater than 48, particularly with these lines:
Code:
vec_normalize(wheelpos[d][0],48);
vec_add(wheelpos[d][0],temp);
result = c_trace(temp,wheelpos[d][0],IGNORE_ME|IGNORE_PASSENTS|IGNORE_PASSABLE);
basically, it adds temp to another vector whose magnitude has to be 48 (coz of vec_normalize). this means the distance between these two vectors
has to be 48. then c_trace traces between them, so
result can never be greater than 48. sadly, it is anyway.
target is also set far away. it is set to exactly where c_trace would hit the other entity if its range was nearly 200.
i've worked around it by clamping result and adjusting "target" accordingly, but i'm sure this problem is slowing the engine down or something.
any ideas? is there really something i'm doing wrong?
thanks for reading, i know there's a ridiculously large amount there, a lot of it explaining the same stuff, but i wanted to explain it in every way i could to make sure people understood.
julz
Edit: i'm away for the next two weeks, so if someone replies and points out a stupid error on my part, my delayed response is not due to shame 