More natural mouse picking in software mode, closer to "what's under the cursor

is picked" but still not perfect. In particular, sometimes a wrong wall is
selected, and sprites don't get picked through portals. As a rule of thumb,
don't be too far away from the objects you're modifying in 3D mode.

git-svn-id: https://svn.eduke32.com/eduke32@2030 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-09-17 14:26:02 +00:00
parent 19ebd8feb3
commit b486f3aa0d
2 changed files with 26 additions and 7 deletions

View file

@ -4425,12 +4425,22 @@ static void drawalls(int32_t bunch)
if ((searchit == 2) && (searchx >= x1) && (searchx <= x2)) if ((searchit == 2) && (searchx >= x1) && (searchx <= x2))
{ {
if (searchy <= uplc[searchx]) //ceiling if (searchy <= uplc[searchx]
#ifdef YAX_ENABLE
&& umost[searchx] <= searchy && getceilzofslope(sectnum, globalposx, globalposz) <= globalposz
&& (yax_getbunch(sectnum, YAX_CEILING) < 0 || showinvisibility || (sec->ceilingstat&(256+128)) || klabs(yax_globallev-YAX_MAXDRAWS)==YAX_MAXDRAWS)
#endif
) //ceiling
{ {
searchsector = sectnum; searchwall = wallnum; searchsector = sectnum; searchwall = wallnum;
searchstat = 1; searchit = 1; searchstat = 1; searchit = 1;
} }
else if (searchy >= dplc[searchx]) //floor else if (dplc[searchx] <= searchy
#ifdef YAX_ENABLE
&& searchy < dmost[searchx] && getflorzofslope(sectnum, globalposx, globalposz) >= globalposz
&& (yax_getbunch(sectnum, YAX_FLOOR) < 0 || showinvisibility || (sec->floorstat&(256+128)) || klabs(yax_globallev-YAX_MAXDRAWS)==YAX_MAXDRAWS)
#endif
) //floor
{ {
searchsector = sectnum; searchwall = wallnum; searchsector = sectnum; searchwall = wallnum;
searchstat = 2; searchit = 1; searchstat = 2; searchit = 1;
@ -4471,6 +4481,9 @@ static void drawalls(int32_t bunch)
for (i=x1; i<=x2; i++) if (dwall[i] > dplc[i]) dwall[i] = dplc[i]; for (i=x1; i<=x2; i++) if (dwall[i] > dplc[i]) dwall[i] = dplc[i];
if ((searchit == 2) && (searchx >= x1) && (searchx <= x2)) if ((searchit == 2) && (searchx >= x1) && (searchx <= x2))
#ifdef YAX_ENABLE
if (uplc[searchx] <= searchy)
#endif
if (searchy <= dwall[searchx]) //wall if (searchy <= dwall[searchx]) //wall
{ {
searchsector = sectnum; searchbottomwall = searchwall = wallnum; searchsector = sectnum; searchbottomwall = searchwall = wallnum;
@ -4563,6 +4576,9 @@ static void drawalls(int32_t bunch)
for (i=x1; i<=x2; i++) if (uwall[i] < uplc[i]) uwall[i] = uplc[i]; for (i=x1; i<=x2; i++) if (uwall[i] < uplc[i]) uwall[i] = uplc[i];
if ((searchit == 2) && (searchx >= x1) && (searchx <= x2)) if ((searchit == 2) && (searchx >= x1) && (searchx <= x2))
#ifdef YAX_ENABLE
if (dplc[searchx] >= searchy)
#endif
if (searchy >= uwall[searchx]) //wall if (searchy >= uwall[searchx]) //wall
{ {
searchsector = sectnum; searchbottomwall = searchwall = wallnum; searchsector = sectnum; searchbottomwall = searchwall = wallnum;
@ -4740,7 +4756,10 @@ static void drawalls(int32_t bunch)
smostwalltype[smostwallcnt] = 0; smostwalltype[smostwallcnt] = 0;
smostwallcnt++; smostwallcnt++;
if ((searchit == 2) && (searchx >= x1) && (searchx <= x2)) if ((searchit == 2) && (x1 <= searchx) && (searchx <= x2))
#ifdef YAX_ENABLE
if (uplc[searchx] <= searchy && searchy < dplc[searchx])
#endif
{ {
searchit = 1; searchsector = sectnum; searchbottomwall = searchwall = wallnum; searchit = 1; searchsector = sectnum; searchbottomwall = searchwall = wallnum;
if (nextsectnum < 0) searchstat = 0; else searchstat = 4; if (nextsectnum < 0) searchstat = 0; else searchstat = 4;

View file

@ -5853,21 +5853,21 @@ static void Keys3d(void)
if (k) if (k)
{ {
sect = highlightsector[0]; sect = highlightsector[0];
havetop = AIMING_AT_WALL; havetop = AIMING_AT_WALL_OR_MASK;
} }
else else
{ {
if (AIMING_AT_WALL && wall[searchwall].nextsector>=0 if (AIMING_AT_WALL_OR_MASK && wall[searchwall].nextsector>=0
&& eitherALT && !(bstatus&1)) && eitherALT && !(bstatus&1))
{ {
sect = wall[searchwall].nextsector; sect = wall[searchwall].nextsector;
havebtm = searchisbottom; havebtm = !AIMING_AT_MASKWALL && searchisbottom;
havetop = !havebtm; havetop = !havebtm;
} }
else else
{ {
sect = searchsector; sect = searchsector;
havetop = AIMING_AT_WALL; havetop = AIMING_AT_WALL_OR_MASK;
} }
} }