Hi,
why
TR_PointOutsideWorld() Y != m_WorldMaxs' Y on some maps?
On other maps they almost match (~ 0.1 diff.)
I'm executing the following code (when I located on open-air):
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
public void OnPluginStart()
{
RegAdminCmd("sm_b", CmdB, ADMFLAG_ROOT, "");
}
public Action CmdB(int client, int args)
{
float vLoc[3], end[3];
GetClientAbsOrigin(client, vLoc);
// Get Sky position (if we're on open-air)
if( Trace_GetRoof(vLoc, end))
{
PrintToChatAll("Sky: Y = %f", end[2]);
// check those function with a point +10.0 higher and -10.0
end[2] -= 10.0;
PrintToChatAll("TR_PointOutsideWorld? (%f) = %b", end[2], TR_PointOutsideWorld(end));
end[2] += 20.0;
PrintToChatAll("TR_PointOutsideWorld? (%f) = %b", end[2], TR_PointOutsideWorld(end));
// now, compare with the world
float min[3], max[3], pos[3];
GetEntPropVector(0, Prop_Data, "m_WorldMins", min);
GetEntPropVector(0, Prop_Data, "m_WorldMaxs", max);
GetEntPropVector(0, Prop_Data, "m_vecOrigin", pos);
AddVectors(min, pos, min);
AddVectors(max, pos, max);
PrintToChatAll("world ori: %f %f %f", pos[0], pos[1], pos[2]);
PrintToChatAll("world min: %f %f %f", min[0], min[1], min[2]);
PrintToChatAll("world max: %f %f %f", max[0], max[1], max[2]);
}
return Plugin_Handled;
}
stock bool Trace_GetRoof(float vecOrigin[3], float vecRoof[3])
{
bool bFound;
Handle hTrace = TR_TraceRayFilterEx(vecOrigin, view_as<float>({-90.0, 0.0, 0.0}), MASK_VISIBLE, RayType_Infinite, TraceRayNoPlayers);
if (hTrace != INVALID_HANDLE)
{
if (TR_DidHit(hTrace))
{
TR_GetEndPosition(vecRoof, hTrace);
bFound = true;
}
delete hTrace;
}
return bFound;
}
public bool TraceRayNoPlayers(int entity, int mask)
{
if(1 <= entity <= MaxClients)
{
return false;
}
return true;
}
Result:
Quote:
Sky: Y = 1919.968872
TR_PointOutsideWorld? (1909.968872) = 0
TR_PointOutsideWorld? (1929.968872) = 1
world ori: 0.000000 0.000000 0.000000
world min: -256.000000 -2224.000000 -360.000000
world max: 4896.000000 6656.000000 1436.000000
|
1919 != 1436
__________________