TraceLine sometimes causes a hang, with no error or exception.
Edit: I also noticed that calling this function sometimes causes the character to fall through WMO's...
Code:
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate byte TracelineDelegate(ref Common.Vector end, ref Common.Vector start, ref Common.Vector result, ref float distance, uint flags, uint Optional);
public static TracelineDelegate WoWTraceLine;
Code:
[Flags]
public enum CGWorldFrameHitFlags : uint
{
HitTestNothing = 0x0,
/// <summary>
/// Models' bounding, ie. where you can't walk on a model. (Trees, smaller structures etc.)
/// </summary>
HitTestBoundingModels = 0x1,
/// <summary>
/// Structures like big buildings, Orgrimmar etc.
/// </summary>
HitTestWMO = 0x10,
/// <summary>
/// Used in ClickTerrain.
/// </summary>
HitTestUnknown = 0x40,
/// <summary>
/// The terrain.
/// </summary>
HitTestGround = 0x100,
/// <summary>
/// Tested on water - should work on lava and other liquid as well.
/// </summary>
HitTestLiquid = 0x10000,
/// <summary>
/// This flag works for liquid as well, but it also works for something else that I don't know (this hit while the liquid flag didn't hit) - called constantly by WoW.
/// </summary>
HitTestUnknown2 = 0x20000,
/// <summary>
/// Hits on movable objects - tested on UC elevator doors.
/// </summary>
HitTestMovableObjects = 0x100000,
HitTestLOS = HitTestBoundingModels | HitTestWMO, //| HitTestMovableObjects | HitTestUnknown2,
//HitTestLand = HitTestGround | HitTestWMO, //| HitTestMovableObjects | HitTestUnknown2,
HitTestGroundAndStructures = HitTestLOS | HitTestGround
}
[Serializable]
public struct Vector
{
[XmlAttribute("x")]
public float X;
[XmlAttribute("y")]
public float Y;
[XmlAttribute("z")]
public float Z;
}
Code:
public bool HitTestLOS(Common.Vector end, Common.Vector start)
{
byte result = 0;
//try
//{
Common.Vector res = new Common.Vector();
float dist = 1.0f;
uint zero = 0;
result = FunctionInterface.WoWTraceLine(ref end, ref start, ref res, ref dist, (uint)Common.CGWorldFrameHitFlags.HitTestLOS, zero);
//}
//catch (Exception ex)
//{
// LuaInterface.LoggingInterface.LogEx(ex.Message);
//}
return (result == 0);
}
Any thoughts?