added amb1715 - tracehull
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402201
This commit is contained in:
parent
627e4fd115
commit
81af704f58
@ -61,6 +61,8 @@ Ray_t g_Ray;
|
|||||||
trace_t g_Trace;
|
trace_t g_Trace;
|
||||||
Vector g_StartVec;
|
Vector g_StartVec;
|
||||||
Vector g_EndVec;
|
Vector g_EndVec;
|
||||||
|
Vector g_HullMins;
|
||||||
|
Vector g_HullMaxs;
|
||||||
QAngle g_DirAngles;
|
QAngle g_DirAngles;
|
||||||
CTraceFilterHitAll g_HitAllFilter;
|
CTraceFilterHitAll g_HitAllFilter;
|
||||||
CSMTraceFilter g_SMTraceFilter;
|
CSMTraceFilter g_SMTraceFilter;
|
||||||
@ -104,6 +106,25 @@ static cell_t smn_TRTraceRay(IPluginContext *pContext, const cell_t *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t smn_TRTraceHull(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
cell_t *startaddr, *endaddr, *mins, *maxs;
|
||||||
|
pContext->LocalToPhysAddr(params[1], &startaddr);
|
||||||
|
pContext->LocalToPhysAddr(params[2], &endaddr);
|
||||||
|
pContext->LocalToPhysAddr(params[3], &mins);
|
||||||
|
pContext->LocalToPhysAddr(params[4], &maxs);
|
||||||
|
|
||||||
|
g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
|
||||||
|
g_HullMins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
|
||||||
|
g_HullMaxs.Init(sp_ctof(maxs[0]), sp_ctof(maxs[1]), sp_ctof(maxs[2]));
|
||||||
|
g_EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
|
||||||
|
|
||||||
|
g_Ray.Init(g_StartVec, g_EndVec, g_HullMins, g_HullMaxs);
|
||||||
|
enginetrace->TraceRay(g_Ray, params[5], &g_HitAllFilter, &g_Trace);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t smn_TRTraceRayFilter(IPluginContext *pContext, const cell_t *params)
|
static cell_t smn_TRTraceRayFilter(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
cell_t *startaddr, *endaddr;
|
cell_t *startaddr, *endaddr;
|
||||||
@ -156,6 +177,38 @@ static cell_t smn_TRTraceRayFilter(IPluginContext *pContext, const cell_t *param
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t smn_TRTraceHullFilter(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
cell_t data;
|
||||||
|
IPluginFunction *pFunc;
|
||||||
|
cell_t *startaddr, *endaddr, *mins, *maxs;
|
||||||
|
|
||||||
|
pFunc = pContext->GetFunctionById(params[6]);
|
||||||
|
if (!pFunc)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid function id (%X)", params[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
data = params[7];
|
||||||
|
|
||||||
|
g_SMTraceFilter.SetFunctionPtr(pFunc, data);
|
||||||
|
pContext->LocalToPhysAddr(params[1], &startaddr);
|
||||||
|
pContext->LocalToPhysAddr(params[2], &endaddr);
|
||||||
|
pContext->LocalToPhysAddr(params[3], &mins);
|
||||||
|
pContext->LocalToPhysAddr(params[4], &maxs);
|
||||||
|
|
||||||
|
g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
|
||||||
|
g_HullMins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
|
||||||
|
g_HullMaxs.Init(sp_ctof(maxs[0]), sp_ctof(maxs[1]), sp_ctof(maxs[2]));
|
||||||
|
g_EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
|
||||||
|
|
||||||
|
g_Ray.Init(g_StartVec, g_EndVec, g_HullMins, g_HullMaxs);
|
||||||
|
enginetrace->TraceRay(g_Ray, params[5], &g_SMTraceFilter, &g_Trace);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static cell_t smn_TRTraceRayEx(IPluginContext *pContext, const cell_t *params)
|
static cell_t smn_TRTraceRayEx(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
cell_t *startaddr, *endaddr;
|
cell_t *startaddr, *endaddr;
|
||||||
@ -202,6 +255,38 @@ static cell_t smn_TRTraceRayEx(IPluginContext *pContext, const cell_t *params)
|
|||||||
return hndl;
|
return hndl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t smn_TRTraceHullEx(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
cell_t *startaddr, *endaddr, *mins, *maxs;
|
||||||
|
pContext->LocalToPhysAddr(params[1], &startaddr);
|
||||||
|
pContext->LocalToPhysAddr(params[2], &endaddr);
|
||||||
|
pContext->LocalToPhysAddr(params[3], &mins);
|
||||||
|
pContext->LocalToPhysAddr(params[4], &maxs);
|
||||||
|
|
||||||
|
Ray_t ray;
|
||||||
|
Vector StartVec, EndVec, vmins, vmaxs;
|
||||||
|
|
||||||
|
StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
|
||||||
|
vmins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
|
||||||
|
vmaxs.Init(sp_ctof(maxs[0]), sp_ctof(maxs[1]), sp_ctof(maxs[2]));
|
||||||
|
EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
|
||||||
|
|
||||||
|
ray.Init(StartVec, EndVec, vmins, vmaxs);
|
||||||
|
|
||||||
|
trace_t *tr = new trace_t;
|
||||||
|
enginetrace->TraceRay(ray, params[5], &g_HitAllFilter, tr);
|
||||||
|
|
||||||
|
HandleError herr;
|
||||||
|
Handle_t hndl;
|
||||||
|
if (!(hndl=handlesys->CreateHandle(g_TraceHandle, tr, pContext->GetIdentity(), myself->GetIdentity(), &herr)))
|
||||||
|
{
|
||||||
|
delete tr;
|
||||||
|
return pContext->ThrowNativeError("Unable to create a new trace handle (error %d)", herr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hndl;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t smn_TRTraceRayFilterEx(IPluginContext *pContext, const cell_t *params)
|
static cell_t smn_TRTraceRayFilterEx(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
IPluginFunction *pFunc;
|
IPluginFunction *pFunc;
|
||||||
@ -267,6 +352,50 @@ static cell_t smn_TRTraceRayFilterEx(IPluginContext *pContext, const cell_t *par
|
|||||||
return hndl;
|
return hndl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t smn_TRTraceHullFilterEx(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
IPluginFunction *pFunc;
|
||||||
|
cell_t *startaddr, *endaddr, *mins, *maxs;
|
||||||
|
cell_t data;
|
||||||
|
|
||||||
|
pFunc = pContext->GetFunctionById(params[6]);
|
||||||
|
if (!pFunc)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid function id (%X)", params[5]);
|
||||||
|
}
|
||||||
|
pContext->LocalToPhysAddr(params[1], &startaddr);
|
||||||
|
pContext->LocalToPhysAddr(params[2], &endaddr);
|
||||||
|
pContext->LocalToPhysAddr(params[3], &mins);
|
||||||
|
pContext->LocalToPhysAddr(params[4], &maxs);
|
||||||
|
|
||||||
|
Vector StartVec, EndVec, vmins, vmaxs;
|
||||||
|
CSMTraceFilter smfilter;
|
||||||
|
Ray_t ray;
|
||||||
|
|
||||||
|
data = params[7];
|
||||||
|
|
||||||
|
smfilter.SetFunctionPtr(pFunc, data);
|
||||||
|
StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
|
||||||
|
vmins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
|
||||||
|
vmaxs.Init(sp_ctof(maxs[0]), sp_ctof(maxs[1]), sp_ctof(maxs[2]));
|
||||||
|
EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
|
||||||
|
|
||||||
|
ray.Init(StartVec, EndVec, vmins, vmaxs);
|
||||||
|
|
||||||
|
trace_t *tr = new trace_t;
|
||||||
|
enginetrace->TraceRay(ray, params[5], &smfilter, tr);
|
||||||
|
|
||||||
|
HandleError herr;
|
||||||
|
Handle_t hndl;
|
||||||
|
if (!(hndl=handlesys->CreateHandle(g_TraceHandle, tr, pContext->GetIdentity(), myself->GetIdentity(), &herr)))
|
||||||
|
{
|
||||||
|
delete tr;
|
||||||
|
return pContext->ThrowNativeError("Unable to create a new trace handle (error %d)", herr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hndl;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t smn_TRGetFraction(IPluginContext *pContext, const cell_t *params)
|
static cell_t smn_TRGetFraction(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
trace_t *tr;
|
trace_t *tr;
|
||||||
@ -429,7 +558,9 @@ static cell_t smn_TRGetPointContentsEnt(IPluginContext *pContext, const cell_t *
|
|||||||
sp_nativeinfo_t g_TRNatives[] =
|
sp_nativeinfo_t g_TRNatives[] =
|
||||||
{
|
{
|
||||||
{"TR_TraceRay", smn_TRTraceRay},
|
{"TR_TraceRay", smn_TRTraceRay},
|
||||||
|
{"TR_TraceHull", smn_TRTraceHull},
|
||||||
{"TR_TraceRayEx", smn_TRTraceRayEx},
|
{"TR_TraceRayEx", smn_TRTraceRayEx},
|
||||||
|
{"TR_TraceHullEx", smn_TRTraceHullEx},
|
||||||
{"TR_GetFraction", smn_TRGetFraction},
|
{"TR_GetFraction", smn_TRGetFraction},
|
||||||
{"TR_GetEndPosition", smn_TRGetEndPosition},
|
{"TR_GetEndPosition", smn_TRGetEndPosition},
|
||||||
{"TR_GetEntityIndex", smn_TRGetEntityIndex},
|
{"TR_GetEntityIndex", smn_TRGetEntityIndex},
|
||||||
@ -439,6 +570,8 @@ sp_nativeinfo_t g_TRNatives[] =
|
|||||||
{"TR_GetPointContentsEnt", smn_TRGetPointContentsEnt},
|
{"TR_GetPointContentsEnt", smn_TRGetPointContentsEnt},
|
||||||
{"TR_TraceRayFilter", smn_TRTraceRayFilter},
|
{"TR_TraceRayFilter", smn_TRTraceRayFilter},
|
||||||
{"TR_TraceRayFilterEx", smn_TRTraceRayFilterEx},
|
{"TR_TraceRayFilterEx", smn_TRTraceRayFilterEx},
|
||||||
|
{"TR_TraceHullFilter", smn_TRTraceHullFilter},
|
||||||
|
{"TR_TraceHullFilterEx", smn_TRTraceHullFilterEx},
|
||||||
{"TR_GetPlaneNormal", smn_TRGetPlaneNormal},
|
{"TR_GetPlaneNormal", smn_TRGetPlaneNormal},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -154,25 +154,48 @@ native TR_GetPointContentsEnt(entindex, const Float:pos[3]);
|
|||||||
* Starts up a new trace ray using a global trace result.
|
* Starts up a new trace ray using a global trace result.
|
||||||
*
|
*
|
||||||
* @param pos Starting position of the ray.
|
* @param pos Starting position of the ray.
|
||||||
* @param vec Depending on RayType, it will be used as the ending point, or the direction angle.
|
* @param vec Depending on RayType, it will be used as the
|
||||||
|
* ending point, or the direction angle.
|
||||||
* @param flags Trace flags.
|
* @param flags Trace flags.
|
||||||
* @param rtype Method to calculate the ray direction.
|
* @param rtype Method to calculate the ray direction.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
native TR_TraceRay(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
|
native TR_TraceRay(const Float:pos[3],
|
||||||
|
const Float:vec[3],
|
||||||
|
flags,
|
||||||
|
RayType:rtype);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts up a new trace ray using a global trace result and a customized trace ray filter.
|
* Starts up a new trace hull using a global trace result.
|
||||||
*
|
|
||||||
* Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is
|
|
||||||
* currently not allowed and may not work.
|
|
||||||
*
|
*
|
||||||
* @param pos Starting position of the ray.
|
* @param pos Starting position of the ray.
|
||||||
* @param vec Depending on RayType, it will be used as the ending point, or the direction angle.
|
* @param vec Ending position of the ray.
|
||||||
|
* @param mins Hull minimum size.
|
||||||
|
* @param maxs Hull maximum size.
|
||||||
|
* @param flags Trace flags.
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
native TR_TraceHull(const Float:pos[3],
|
||||||
|
const Float:vec[3],
|
||||||
|
const Float:mins[3],
|
||||||
|
const Float:maxs[3],
|
||||||
|
flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts up a new trace ray using a global trace result and a customized
|
||||||
|
* trace ray filter.
|
||||||
|
*
|
||||||
|
* Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter
|
||||||
|
* function is currently not allowed and may not work.
|
||||||
|
*
|
||||||
|
* @param pos Starting position of the ray.
|
||||||
|
* @param vec Depending on RayType, it will be used as the ending
|
||||||
|
* point, or the direction angle.
|
||||||
* @param flags Trace flags.
|
* @param flags Trace flags.
|
||||||
* @param rtype Method to calculate the ray direction.
|
* @param rtype Method to calculate the ray direction.
|
||||||
* @param filter Function to use as a filter.
|
* @param filter Function to use as a filter.
|
||||||
* @param data Arbitrary data value to pass through to the filter function.
|
* @param data Arbitrary data value to pass through to the filter
|
||||||
|
* function.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
native TR_TraceRayFilter(const Float:pos[3],
|
native TR_TraceRayFilter(const Float:pos[3],
|
||||||
@ -181,26 +204,74 @@ native TR_TraceRayFilter(const Float:pos[3],
|
|||||||
RayType:rtype,
|
RayType:rtype,
|
||||||
TraceEntityFilter:filter,
|
TraceEntityFilter:filter,
|
||||||
any:data=0);
|
any:data=0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts up a new trace hull using a global trace result and a customized
|
||||||
|
* trace ray filter.
|
||||||
|
*
|
||||||
|
* Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter
|
||||||
|
* function is currently not allowed and may not work.
|
||||||
|
*
|
||||||
|
* @param pos Starting position of the ray.
|
||||||
|
* @param vec Depending on RayType, it will be used as the ending
|
||||||
|
* point, or the direction angle.
|
||||||
|
* @param mins Hull minimum size.
|
||||||
|
* @param maxs Hull maximum size.
|
||||||
|
* @param flags Trace flags.
|
||||||
|
* @param filter Function to use as a filter.
|
||||||
|
* @param data Arbitrary data value to pass through to the filter
|
||||||
|
* function.
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
native TR_TraceHullFilter(const Float:pos[3],
|
||||||
|
const Float:vec[3],
|
||||||
|
const Float:mins[3],
|
||||||
|
const Float:maxs[3],
|
||||||
|
flags,
|
||||||
|
TraceEntityFilter:filter,
|
||||||
|
any:data=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts up a new trace ray using a new trace result.
|
* Starts up a new trace ray using a new trace result.
|
||||||
*
|
*
|
||||||
* @param pos Starting position of the ray.
|
* @param pos Starting position of the ray.
|
||||||
* @param vec Depending on RayType, it will be used as the ending point, or the direction angle.
|
* @param vec Depending on RayType, it will be used as the ending
|
||||||
|
* point, or the direction angle.
|
||||||
* @param flags Trace flags.
|
* @param flags Trace flags.
|
||||||
* @param rtype Method to calculate the ray direction.
|
* @param rtype Method to calculate the ray direction.
|
||||||
* @return Ray trace handle, which must be closed via CloseHandle().
|
* @return Ray trace handle, which must be closed via CloseHandle().
|
||||||
*/
|
*/
|
||||||
native Handle:TR_TraceRayEx(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
|
native Handle:TR_TraceRayEx(const Float:pos[3],
|
||||||
|
const Float:vec[3],
|
||||||
|
flags,
|
||||||
|
RayType:rtype);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts up a new trace ray using a new trace result and a customized trace ray filter.
|
* Starts up a new trace hull using a new trace result.
|
||||||
*
|
|
||||||
* Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is
|
|
||||||
* currently not allowed and may not work.
|
|
||||||
*
|
*
|
||||||
* @param pos Starting position of the ray.
|
* @param pos Starting position of the ray.
|
||||||
* @param vec Depending on RayType, it will be used as the ending point, or the direction angle.
|
* @param vec Ending position of the ray.
|
||||||
|
* @param mins Hull minimum size.
|
||||||
|
* @param maxs Hull maximum size.
|
||||||
|
* @param flags Trace flags.
|
||||||
|
* @return Ray trace handle, which must be closed via CloseHandle().
|
||||||
|
*/
|
||||||
|
native Handle:TR_TraceHullEx(const Float:pos[3],
|
||||||
|
const Float:vec[3],
|
||||||
|
const Float:mins[3],
|
||||||
|
const Float:maxs[3],
|
||||||
|
flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts up a new trace ray using a new trace result and a customized
|
||||||
|
* trace ray filter.
|
||||||
|
*
|
||||||
|
* Calling TR_Trace*Filter or TR_TraceRay*Ex from inside a filter
|
||||||
|
* function is currently not allowed and may not work.
|
||||||
|
*
|
||||||
|
* @param pos Starting position of the ray.
|
||||||
|
* @param vec Depending on RayType, it will be used as the ending
|
||||||
|
* point, or the direction angle.
|
||||||
* @param flags Trace flags.
|
* @param flags Trace flags.
|
||||||
* @param rtype Method to calculate the ray direction.
|
* @param rtype Method to calculate the ray direction.
|
||||||
* @param filter Function to use as a filter.
|
* @param filter Function to use as a filter.
|
||||||
@ -213,6 +284,30 @@ native Handle:TR_TraceRayFilterEx(const Float:pos[3],
|
|||||||
RayType:rtype,
|
RayType:rtype,
|
||||||
TraceEntityFilter:filter,
|
TraceEntityFilter:filter,
|
||||||
any:data=0);
|
any:data=0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts up a new trace hull using a new trace result and a customized
|
||||||
|
* trace ray filter.
|
||||||
|
*
|
||||||
|
* Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter
|
||||||
|
* function is currently not allowed and may not work.
|
||||||
|
*
|
||||||
|
* @param pos Starting position of the ray.
|
||||||
|
* @param vec Ending position of the ray.
|
||||||
|
* @param mins Hull minimum size.
|
||||||
|
* @param maxs Hull maximum size.
|
||||||
|
* @param flags Trace flags.
|
||||||
|
* @param filter Function to use as a filter.
|
||||||
|
* @param data Arbitrary data value to pass through to the filter function.
|
||||||
|
* @return Ray trace handle, which must be closed via CloseHandle().
|
||||||
|
*/
|
||||||
|
native Handle:TR_TraceHullFilterEx(const Float:pos[3],
|
||||||
|
const Float:vec[3],
|
||||||
|
const Float:mins[3],
|
||||||
|
const Float:maxs[3],
|
||||||
|
flags,
|
||||||
|
TraceEntityFilter:filter,
|
||||||
|
any:data=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the time fraction from a trace result (1.0 means no collision).
|
* Returns the time fraction from a trace result (1.0 means no collision).
|
||||||
|
Loading…
Reference in New Issue
Block a user