Add new Traceray natives (#754)

This commit is contained in:
SlidyBat
2018-08-13 23:02:12 +01:00
committed by Asher Baker
parent e7c6b23439
commit 144fb907f1
2 changed files with 538 additions and 68 deletions
+182 -34
View File
@@ -9,7 +9,7 @@
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
@@ -116,22 +116,41 @@ typeset TraceEntityFilter
* Called on entity filtering.
*
* @param entity Entity index.
* @param contentsMask Contents Mask.
* @return True to allow the current entity to be hit, otherwise false.
*/
* @param contentsMask Contents Mask.
* @return True to allow the current entity to be hit, otherwise false.
*/
function bool (int entity, int contentsMask);
/**
* Called on entity filtering.
*
* @param entity Entity index.
* @param contentsMask Contents Mask.
* @param data Data value, if used.
* @return True to allow the current entity to be hit, otherwise false.
*/
* @param contentsMask Contents Mask.
* @param data Data value, if used.
* @return True to allow the current entity to be hit, otherwise false.
*/
function bool (int entity, int contentsMask, any data);
};
typeset TraceEntityEnumerator
{
/**
* Called for each entity enumerated with EnumerateEntities*.
*
* @param entity Entity index.
* @return True to continue enumerating, otherwise false.
*/
function bool (int entity);
/**
* Called for each entity enumerated with EnumerateEntities*.
*
* @param entity Entity index.
* @param data Data value, if used.
* @return True to continue enumerating, otherwise false. */
function bool (int entity, any data);
}
/**
* Get the contents mask and the entity index at the given position.
*
@@ -163,7 +182,7 @@ native void TR_TraceRay(const float pos[3],
const float vec[3],
int flags,
RayType rtype);
/**
* Starts up a new trace hull using a global trace result.
*
@@ -180,19 +199,64 @@ native void TR_TraceHull(const float pos[3],
int flags);
/**
* Starts up a new trace ray using a global trace result and a customized
* Enumerates over entities along a ray. This may find entities that are
* close to the ray but do not actually intersect it. Use TR_Clip*RayToEntity
* with TR_DidHit to check if the ray actually intersects the entity.
*
* @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 triggers If true, enumerate only triggers. Otherwise, enumerate
* only non-triggers.
* @param rtype Method to calculate the ray direction.
* @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_EnumerateEntities(const float pos[3],
const float vec[3],
bool triggers,
RayType rtype,
TraceEntityEnumerator enumerator,
any data=0);
/**
* Enumerates over entities along a ray hull. This may find entities that are
* close to the ray but do not actually intersect it. Use TR_Clip*RayToEntity
* with TR_DidHit to check if the ray actually intersects the entity.
*
* @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 triggers If true, enumerate only triggers. Otherwise, enumerate
* only non-triggers.
* @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_EnumerateEntitiesHull(const float pos[3],
const float vec[3],
const float mins[3],
const float maxs[3],
bool triggers,
TraceEntityEnumerator enumerator,
any data=0);
/**
* 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
* 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
* @param vec Depending on RayType, it will be used as the ending
* point, or the direction angle.
* @param flags Trace flags.
* @param rtype Method to calculate the ray direction.
* @param filter Function to use as a filter.
* @param data Arbitrary data value to pass through to the filter
* @param data Arbitrary data value to pass through to the filter
* function.
*/
native void TR_TraceRayFilter(const float pos[3],
@@ -201,22 +265,21 @@ native void TR_TraceRayFilter(const float pos[3],
RayType rtype,
TraceEntityFilter filter,
any data=0);
/**
* Starts up a new trace hull using a global trace result and a customized
* 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
* 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 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
* @param data Arbitrary data value to pass through to the filter
* function.
*/
native void TR_TraceHullFilter(const float pos[3],
@@ -227,11 +290,52 @@ native void TR_TraceHullFilter(const float pos[3],
TraceEntityFilter filter,
any data=0);
/**
* Clips a ray to a particular entity.
*
* @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 rtype Method to calculate the ray direction.
* @param entity Entity to clip to.
*/
native void TR_ClipRayToEntity(const float pos[3],
const float vec[3],
int flags,
RayType rtype,
int entity);
/**
* Clips a ray hull to a particular entity.
*
* @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 entity Entity to clip to.
*/
native void TR_ClipRayHullToEntity(const float pos[3],
const float vec[3],
const float mins[3],
const float maxs[3],
int flags,
int entity);
/**
* Clips the current global ray (or hull) to a particular entity.
*
* @param flags Trace flags.
* @param entity Entity to clip to.
*/
native void TR_ClipCurrentRayToEntity(int flags, int entity);
/**
* Starts up a new trace ray using a new trace result.
*
* @param pos Starting position of the ray.
* @param vec Depending on RayType, it will be used as the ending
* @param vec Depending on RayType, it will be used as the ending
* point, or the direction angle.
* @param flags Trace flags.
* @param rtype Method to calculate the ray direction.
@@ -241,7 +345,7 @@ native Handle TR_TraceRayEx(const float pos[3],
const float vec[3],
int flags,
RayType rtype);
/**
* Starts up a new trace hull using a new trace result.
*
@@ -259,14 +363,14 @@ native Handle TR_TraceHullEx(const float pos[3],
int flags);
/**
* Starts up a new trace ray using a new trace result and a customized
* 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
* 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
* @param vec Depending on RayType, it will be used as the ending
* point, or the direction angle.
* @param flags Trace flags.
* @param rtype Method to calculate the ray direction.
@@ -274,18 +378,18 @@ native Handle TR_TraceHullEx(const float pos[3],
* @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_TraceRayFilterEx(const float pos[3],
native Handle TR_TraceRayFilterEx(const float pos[3],
const float vec[3],
int flags,
RayType rtype,
int flags,
RayType rtype,
TraceEntityFilter filter,
any data=0);
/**
* Starts up a new trace hull using a new trace result and a customized
* 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
* 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.
@@ -297,14 +401,58 @@ native Handle TR_TraceRayFilterEx(const float pos[3],
* @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],
native Handle TR_TraceHullFilterEx(const float pos[3],
const float vec[3],
const float mins[3],
const float maxs[3],
int flags,
int flags,
TraceEntityFilter filter,
any data=0);
/**
* Clips a ray to a particular entity.
*
* @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 rtype Method to calculate the ray direction.
* @param entity Entity to clip to.
* @return Ray trace handle, which must be closed via CloseHandle().
*/
native Handle TR_ClipRayToEntityEx(const float pos[3],
const float vec[3],
int flags,
RayType rtype,
int entity);
/**
* Clips a ray hull to a particular entity.
*
* @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 entity Entity to clip to.
* @return Ray trace handle, which must be closed via CloseHandle().
*/
native Handle TR_ClipRayHullToEntityEx(const float pos[3],
const float vec[3],
const float mins[3],
const float maxs[3],
int flags,
int entity);
/**
* Clips the current global ray (or hull) to a particular entity.
*
* @param flags Trace flags.
* @param entity Entity to clip to.
* @return Ray trace handle, which must be closed via CloseHandle().
*/
native Handle TR_ClipCurrentRayToEntityEx(int flags, int entity);
/**
* Returns the time fraction from a trace result (1.0 means no collision).
*
@@ -363,6 +511,6 @@ native void TR_GetPlaneNormal(Handle hndl, float normal[3]);
* Tests a point to see if it's outside any playable area
*
* @param pos Vector buffer to store data in.
* @return True if outside world, otherwise false.
* @return True if outside world, otherwise false.
*/
native bool TR_PointOutsideWorld(float pos[3]);