Maes
I like big butts!

Posts: 10179
Registered: 07-06 |
entryway said:
Like this?
http://pastebin.com/wGmaJfs3
Something like that, but there are other subtleties as well. E.g. I'd replace the FixedDiv (y2-y1,abs(x2-x1)) expressions with a specialized function that does (b-a)/abs(d-c), by taking into account internal overflows as well.
I gotta see if fixing just the blockmap addressing part would be enough.
P.S.: don't you ever sleep? :-p
Edit: Yeah, using longs for that particular place does fix the blockmap indexes, however there's the problem of all the other y2-y1, x2-x1 etc. calculations. Those remain wrong even after getting the blockmap indexes right if you still use fixed_t for the rest of the calculations.
I am using this function:
code:
public final int getSafeBlockX(long blockx){
// Interpret as positive if positive
if (blockx>0){
blockx>>>=MAPBLOCKSHIFT;
return (int) blockx;
}
else {
blockx>>=MAPBLOCKSHIFT;
return (int) blockx;
}
}
As a guide, when you shoot parallel to the x/y axis, a line is traced between your current position and a map block up to 16 positions away (e.g. shooting from your starting position straight ahead, you should get a maximum trace from block _x1,_y1: 266,0 to _x2, _y2: 282,0 (2048 units, hardcoded hitscan/autoaim range).
Shooting from the opposite direction, you should get a trace from block (268,0) to (252,0). By strafing full left then turning 90 degrees right from the start and shooting the south wall, you should get a trace from (266,1) to (266, -15).
In principle, this part of the deal seems to work correctly without wraparounds or other funky effects, so any further problems must occur further down. I'd analyze the ystep/xstep stuff next.
I believe the problem will be ultimately solvable, but that the resulting P_PathTrasverse function will be so different and full of hacks that it will make more sense to have two of them: one normal, and one specifically to deal with extended maps, in order to preserve performance when you don't need all this fudging.
Last edited by Maes on 12-04-11 at 15:23
|