sdktools: expose additional tr sdk capabilities (#1145)
* add the rest of the trace enumerate funcs * fix ident
This commit is contained in:
parent
9fb6430313
commit
bcd5e40842
@ -266,6 +266,91 @@ static cell_t smn_TREnumerateEntitiesHull(IPluginContext *pContext, const cell_t
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t smn_TREnumerateEntitiesSphere(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IPluginFunction *pFunc = pContext->GetFunctionById(params[4]);
|
||||
if (!pFunc)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", params[4]);
|
||||
}
|
||||
|
||||
cell_t data = 0;
|
||||
if (params[0] >= 5)
|
||||
{
|
||||
data = params[5];
|
||||
}
|
||||
|
||||
g_SMTraceEnumerator.SetFunctionPtr(pFunc, data);
|
||||
|
||||
cell_t *startaddr;
|
||||
pContext->LocalToPhysAddr(params[1], &startaddr);
|
||||
|
||||
g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
|
||||
|
||||
float radius = sp_ctof(params[2]);
|
||||
|
||||
int mask = TranslatePartitionFlags(params[3]);
|
||||
partition->EnumerateElementsInSphere(mask, g_StartVec, radius, false, &g_SMTraceEnumerator);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t smn_TREnumerateEntitiesBox(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IPluginFunction *pFunc = pContext->GetFunctionById(params[4]);
|
||||
if (!pFunc)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", params[4]);
|
||||
}
|
||||
|
||||
cell_t data = 0;
|
||||
if (params[0] >= 5)
|
||||
{
|
||||
data = params[5];
|
||||
}
|
||||
|
||||
g_SMTraceEnumerator.SetFunctionPtr(pFunc, data);
|
||||
|
||||
cell_t *minsaddr, *maxsaddr;
|
||||
pContext->LocalToPhysAddr(params[1], &minsaddr);
|
||||
pContext->LocalToPhysAddr(params[2], &maxsaddr);
|
||||
|
||||
g_HullMins.Init(sp_ctof(minsaddr[0]), sp_ctof(minsaddr[1]), sp_ctof(minsaddr[2]));
|
||||
g_HullMaxs.Init(sp_ctof(maxsaddr[0]), sp_ctof(maxsaddr[1]), sp_ctof(maxsaddr[2]));
|
||||
|
||||
int mask = TranslatePartitionFlags(params[3]);
|
||||
partition->EnumerateElementsInBox(mask, g_HullMins, g_HullMaxs, false, &g_SMTraceEnumerator);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t smn_TREnumerateEntitiesPoint(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IPluginFunction *pFunc = pContext->GetFunctionById(params[3]);
|
||||
if (!pFunc)
|
||||
{
|
||||
return pContext->ThrowNativeError("Invalid function id (%X)", params[3]);
|
||||
}
|
||||
|
||||
cell_t data = 0;
|
||||
if (params[0] >= 4)
|
||||
{
|
||||
data = params[4];
|
||||
}
|
||||
|
||||
g_SMTraceEnumerator.SetFunctionPtr(pFunc, data);
|
||||
|
||||
cell_t *startaddr;
|
||||
pContext->LocalToPhysAddr(params[1], &startaddr);
|
||||
|
||||
g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
|
||||
|
||||
int mask = TranslatePartitionFlags(params[2]);
|
||||
partition->EnumerateElementsAtPoint(mask, g_StartVec, false, &g_SMTraceEnumerator);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t smn_TRClipRayToEntity(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
cell_t *startaddr;
|
||||
@ -1100,8 +1185,11 @@ sp_nativeinfo_t g_TRNatives[] =
|
||||
{
|
||||
{"TR_TraceRay", smn_TRTraceRay},
|
||||
{"TR_TraceHull", smn_TRTraceHull},
|
||||
{"TR_EnumerateEntities", smn_TREnumerateEntities},
|
||||
{"TR_EnumerateEntitiesHull", smn_TREnumerateEntitiesHull},
|
||||
{"TR_EnumerateEntities", smn_TREnumerateEntities},
|
||||
{"TR_EnumerateEntitiesHull", smn_TREnumerateEntitiesHull},
|
||||
{"TR_EnumerateEntitiesSphere", smn_TREnumerateEntitiesSphere},
|
||||
{"TR_EnumerateEntitiesBox", smn_TREnumerateEntitiesBox},
|
||||
{"TR_EnumerateEntitiesPoint", smn_TREnumerateEntitiesPoint},
|
||||
{"TR_TraceRayEx", smn_TRTraceRayEx},
|
||||
{"TR_TraceHullEx", smn_TRTraceHullEx},
|
||||
{"TR_GetFraction", smn_TRGetFraction},
|
||||
|
@ -295,6 +295,52 @@ native void TR_EnumerateEntitiesHull(const float pos[3],
|
||||
TraceEntityEnumerator enumerator,
|
||||
any data=0);
|
||||
|
||||
/**
|
||||
* Enumerates over entities in a sphere.
|
||||
*
|
||||
* @param pos Starting position of the ray.
|
||||
* @param radius Radius of the ray.
|
||||
* @param mask Mask to use for the trace. See PARTITION_* flags.
|
||||
* @param enumerator Function to use as enumerator. For each entity found
|
||||
* along the ray, this function is called.
|
||||
* @param data Arbitrary data value to pass through to the enumerator.
|
||||
*/
|
||||
native void TR_EnumerateEntitiesSphere(const float pos[3],
|
||||
float radius,
|
||||
int mask,
|
||||
TraceEntityEnumerator enumerator,
|
||||
any data=0);
|
||||
|
||||
/**
|
||||
* Enumerates over entities in a box.
|
||||
*
|
||||
* @param mins Box minimum size.
|
||||
* @param maxs Box maximum size.
|
||||
* @param mask Mask to use for the trace. See PARTITION_* flags.
|
||||
* @param enumerator Function to use as enumerator. For each entity found
|
||||
* along the box, this function is called.
|
||||
* @param data Arbitrary data value to pass through to the enumerator.
|
||||
*/
|
||||
native void TR_EnumerateEntitiesBox(const float mins[3],
|
||||
const float maxs[3],
|
||||
int mask,
|
||||
TraceEntityEnumerator enumerator,
|
||||
any data=0);
|
||||
|
||||
/**
|
||||
* Enumerates over entities at point.
|
||||
*
|
||||
* @param pos Position of the point.
|
||||
* @param mask Mask to use for the trace. See PARTITION_* flags.
|
||||
* @param enumerator Function to use as enumerator. For each entity found
|
||||
* along the point, this function is called.
|
||||
* @param data Arbitrary data value to pass through to the enumerator.
|
||||
*/
|
||||
native void TR_EnumerateEntitiesPoint(const float pos[3],
|
||||
int mask,
|
||||
TraceEntityEnumerator enumerator,
|
||||
any data=0);
|
||||
|
||||
/**
|
||||
* Starts up a new trace ray using a global trace result and a customized
|
||||
* trace ray filter.
|
||||
|
Loading…
Reference in New Issue
Block a user