added amb1403 - CBaseTrace.plane from pRED

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401865
This commit is contained in:
David Anderson 2008-01-23 17:05:50 +00:00
parent e553996281
commit 4ade0dbdc2
2 changed files with 715 additions and 679 deletions

View File

@ -283,6 +283,31 @@ static cell_t smn_TRGetFraction(IPluginContext *pContext, const cell_t *params)
return sp_ftoc(tr->fraction);
}
static cell_t smn_TRGetPlaneNormal(IPluginContext *pContext, const cell_t *params)
{
trace_t *tr;
HandleError err;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if (params[1] == BAD_HANDLE)
{
tr = &g_Trace;
} else if ((err = handlesys->ReadHandle(params[1], g_TraceHandle, &sec, (void **)&tr)) != HandleError_None) {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
}
Vector *normal = &tr->plane.normal;
cell_t *r;
pContext->LocalToPhysAddr(params[2], &r);
r[0] = sp_ftoc(normal->x);
r[1] = sp_ftoc(normal->y);
r[2] = sp_ftoc(normal->z);
return 1;
}
static cell_t smn_TRGetEndPosition(IPluginContext *pContext, const cell_t *params)
{
trace_t *tr;
@ -414,5 +439,6 @@ sp_nativeinfo_t g_TRNatives[] =
{"TR_GetPointContentsEnt", smn_TRGetPointContentsEnt},
{"TR_TraceRayFilter", smn_TRTraceRayFilter},
{"TR_TraceRayFilterEx", smn_TRTraceRayFilterEx},
{"TR_GetPlaneNormal", smn_TRGetPlaneNormal},
{NULL, NULL}
};

View File

@ -259,3 +259,13 @@ native bool:TR_DidHit(Handle:hndl=INVALID_HANDLE);
* @error Invalid Handle.
*/
native TR_GetHitGroup(Handle:hndl=INVALID_HANDLE);
/**
* Find the normal vector to the collison plane of a trace.
*
* @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
* @param normal Vector buffer to store the vector normal to the collision plane
* @noreturn
* @error Invalid Handle
*/
native TR_GetPlaneNormal(Handle:hndl=INVALID_HANDLE, Float:normal[3]);