Xonotic
vector.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ClipVelocity(in, normal, out, overbounce)   (out = vec_epsilon(vec_reflect(in, normal, (overbounce) - 1), 0.1))
 
#define cross(a, b)   ((a) >< (b))
 
#define dotproduct(a, b)   ((a) * (b))
 
#define PITCH(v)   ((v).x)
 
#define pointinsidebox(point, bmins, bmaxs)   boxinsidebox(point, point, bmins, bmaxs)
 
#define ROLL(v)   ((v).z)
 
#define vdist(v, cmp, f)   (vlen2(v) cmp ((f) ** 2))
 Vector distance comparison, avoids sqrt() More...
 
#define vec2(...)   EVAL(OVERLOAD(vec2, __VA_ARGS__))
 
#define vec2_1(v)   (_vec2 = (v), _vec2.z = 0, _vec2)
 
#define vec2_2(x, y)   (_vec2_x = (x), _vec2_y = (y), _vec2)
 
#define vec3(_x, _y, _z)   (_vec3.x = (_x), _vec3.y = (_y), _vec3.z = (_z), _vec3)
 
#define VEC_NAN   vec3(FLOAT_NAN, FLOAT_NAN, FLOAT_NAN);
 
#define vlen2(v)   (_vlen2 = (v), dotproduct(_vlen2, _vlen2))
 
#define vmul(a, b)
 
#define YAW(v)   ((v).y)
 
#define yinvert(v)   (_yinvert = (v), _yinvert.y = 1 - _yinvert.y, _yinvert)
 

Functions

ERASEABLE float boxesoverlap (vector m1, vector m2, vector m3, vector m4)
 requires that m2>m1 in all coordinates, and that m4>m3 More...
 
ERASEABLE float boxinsidebox (vector smins, vector smaxs, vector bmins, vector bmaxs)
 requires the same as boxesoverlap, but is a stronger condition More...
 
ERASEABLE bool is_all_nans (vector v)
 
ERASEABLE vector point_line_vec (vector p, vector l0, vector ldir)
 
ERASEABLE vector randompos (vector m1, vector m2)
 
ERASEABLE vector reflect (vector dir, vector norm)
 
ERASEABLE vector Rotate (vector v, float a)
 
ERASEABLE vector vec_epsilon (vector this, float eps)
 
ERASEABLE vector vec_reflect (vector vel, vector norm, float bounce)
 clip vel along the plane defined by norm (assuming 0 distance away), bounciness determined by bounce 0..1 More...
 
ERASEABLE float vlen_maxnorm2d (vector v)
 
ERASEABLE float vlen_minnorm2d (vector v)
 

Variables

noref vector _vec2
 
noref vector _vec3
 
noref vector _vlen2
 
noref vector _vmul_a
 
noref vector _vmul_b
 
noref vector _yinvert
 
const vector eX = '1 0 0'
 
const vector eY = '0 1 0'
 
const vector eZ = '0 0 1'
 

Macro Definition Documentation

◆ ClipVelocity

#define ClipVelocity (   in,
  normal,
  out,
  overbounce 
)    (out = vec_epsilon(vec_reflect(in, normal, (overbounce) - 1), 0.1))

Definition at line 156 of file vector.qh.

Referenced by sys_phys_simulate_simple().

◆ cross

#define cross (   a,
 
)    ((a) >< (b))

Definition at line 25 of file vector.qh.

Referenced by _Movetype_FlyMove(), W_CalculateSpread(), and WarpZone_Projectile_Touch().

◆ dotproduct

#define dotproduct (   a,
 
)    ((a) * (b))

Definition at line 14 of file vector.qh.

◆ PITCH

#define PITCH (   v)    ((v).x)

Definition at line 81 of file vector.qh.

Referenced by leanmodel_ofs().

◆ pointinsidebox

#define pointinsidebox (   point,
  bmins,
  bmaxs 
)    boxinsidebox(point, point, bmins, bmaxs)

Definition at line 79 of file vector.qh.

Referenced by HUD_Crosshair().

◆ ROLL

#define ROLL (   v)    ((v).z)

Definition at line 83 of file vector.qh.

Referenced by leanmodel_ofs().

◆ vdist

#define vdist (   v,
  cmp,
 
)    (vlen2(v) cmp ((f) ** 2))

Vector distance comparison, avoids sqrt()

Definition at line 8 of file vector.qh.

Referenced by _Movetype_Physics_Walk(), animdecide_setimplicitstate(), bot_aimdir(), botframe_showwaypointlinks(), buildpath_nodefilter_directional(), CreatureFrame_FallDamage(), CSQC_Demo_Camera(), CSQCPlayer_SetPredictionError(), ctf_FlagThink(), Drag(), Drag_Finish(), Draw_ShowNames(), fireBullet_antilag(), fireBullet_trace_callback(), GENERIC_COMMAND(), havocbot_ai(), havocbot_bunnyhop(), havocbot_chooseenemy(), havocbot_ctf_teamcount(), havocbot_goalrating_controlpoints(), havocbot_goalrating_ctf_droppedflags(), havocbot_goalrating_enemyplayers(), havocbot_goalrating_ft_freeplayers(), havocbot_goalrating_items(), havocbot_goalrating_ons_controlpoints_attack(), havocbot_goalrating_ons_generator_attack(), havocbot_goalrating_waypoints(), havocbot_movetogoal(), havocbot_role_ctf_carrier(), havocbot_role_ctf_defense(), havocbot_role_ctf_escort(), havocbot_role_ctf_middle(), havocbot_role_ctf_offense(), havocbot_role_ctf_retriever(), HUD_Crosshair(), InterpolateOrigin_Note(), Item_PreDraw(), kh_Key_Think(), m_tooltip(), Monster_Attack_Check(), Monster_FindTarget(), Monster_Move(), Monster_Move_2D(), Monster_Move_Target(), MUTATOR_HOOKFUNCTION(), navigation_get_really_close_waypoint(), navigation_goalrating_timeout_can_be_anticipated(), navigation_poptouchedgoals(), navigation_routerating(), navigation_routetogoal(), navigation_shortenpath(), navigation_waypoint_will_link(), NET_HANDLE(), ons_ControlPoint_Icon_Think(), ons_Nearest_ControlPoint(), pathlib_close_node(), pathlib_nodeatpoint(), PM_dodging_checkpressedkeys(), PM_Footsteps(), race_SpeedAwardFrame(), ResetBall(), sandbox_ObjectEdit_Get(), Simple_TeleportPlayer(), Spawn_Draw(), steerlib_wander(), SUB_CalcAngleMoveEnt(), trigger_push_test(), trigger_push_touch(), TrueAimCheck(), vehicles_impact(), vehicles_touch(), View_Ortho(), W_SetupShot_Dir_ProjectileSize_Range(), WarpZone_Camera_camera_transform(), WarpZone_camera_transform(), WarpZone_Projectile_Touch(), waypoint_load_hardwiredlinks(), waypoint_load_links(), waypoint_schedulerelink(), waypoint_spawn_fromeditor(), waypoint_spawnforitem_force(), and waypoint_think().

◆ vec2

◆ vec2_1

#define vec2_1 (   v)    (_vec2 = (v), _vec2.z = 0, _vec2)

Definition at line 91 of file vector.qh.

◆ vec2_2

#define vec2_2 (   x,
 
)    (_vec2_x = (x), _vec2_y = (y), _vec2)

Definition at line 92 of file vector.qh.

◆ vec3

#define vec3 (   _x,
  _y,
  _z 
)    (_vec3.x = (_x), _vec3.y = (_y), _vec3.z = (_z), _vec3)

◆ VEC_NAN

#define VEC_NAN   vec3(FLOAT_NAN, FLOAT_NAN, FLOAT_NAN);

Definition at line 97 of file vector.qh.

◆ vlen2

◆ vmul

#define vmul (   a,
 
)
Value:
(_vmul_a = (a), _vmul_b = (b), \
'1 0 0' * (_vmul_a.x * _vmul_b.x) \
+ '0 1 0' * (_vmul_a.y * _vmul_b.y) \
+ '0 0 1' * (_vmul_a.z * _vmul_b.z))
noref vector _vmul_a
Definition: vector.qh:37
noref vector _vmul_b
Definition: vector.qh:37

Definition at line 38 of file vector.qh.

Referenced by sys_phys_simulate().

◆ YAW

#define YAW (   v)    ((v).y)

Definition at line 82 of file vector.qh.

Referenced by leanmodel_ofs().

◆ yinvert

#define yinvert (   v)    (_yinvert = (v), _yinvert.y = 1 - _yinvert.y, _yinvert)

Definition at line 112 of file vector.qh.

Referenced by draw_teamradar_background().

Function Documentation

◆ boxesoverlap()

ERASEABLE float boxesoverlap ( vector  m1,
vector  m2,
vector  m3,
vector  m4 
)

requires that m2>m1 in all coordinates, and that m4>m3

Definition at line 73 of file vector.qh.

References ERASEABLE.

Referenced by _Movetype_LinkEdict_TouchAreaGrid(), _Movetype_Physics_Toss(), botframe_autowaypoints_createwp(), conveyor_think(), Draw_ShowNames(), func_ladder_think(), havocbot_movetogoal(), HUD_Notify(), MUTATOR_HOOKFUNCTION(), navigation_checkladders(), navigation_findnearestwaypoint_withdist_except(), navigation_poptouchedgoals(), sys_phys_simulate_simple(), trigger_push_test(), waypoint_addlink_for_custom_jumppad(), waypoint_get(), waypoint_get_type_name(), waypoint_spawn(), waypoint_spawn_fromeditor(), and waypoint_think().

73 { return m2_x >= m3_x && m1_x <= m4_x && m2_y >= m3_y && m1_y <= m4_y && m2_z >= m3_z && m1_z <= m4_z; }
+ Here is the caller graph for this function:

◆ boxinsidebox()

ERASEABLE float boxinsidebox ( vector  smins,
vector  smaxs,
vector  bmins,
vector  bmaxs 
)

requires the same as boxesoverlap, but is a stronger condition

Definition at line 77 of file vector.qh.

77 { return smins.x >= bmins.x && smaxs.x <= bmaxs.x && smins.y >= bmins.y && smaxs.y <= bmaxs.y && smins.z >= bmins.z && smaxs.z <= bmaxs.z; }

◆ is_all_nans()

ERASEABLE bool is_all_nans ( vector  v)

Definition at line 100 of file vector.qh.

References ERASEABLE, and isnan().

100  {
101  return isnan(v.x) && isnan(v.y) && isnan(v.z);
102 }
vector v
Definition: ent_cs.qc:116
bool isnan(float e)
Definition: mathlib.qc:25
+ Here is the call graph for this function:

◆ point_line_vec()

ERASEABLE vector point_line_vec ( vector  p,
vector  l0,
vector  ldir 
)
Parameters
[in]ppoint
[in]l0starting point of ldir
[in]ldirline
Returns
Vector starting from p perpendicular to ldir

Definition at line 119 of file vector.qh.

References ERASEABLE, and normalize().

Referenced by havocbot_movetogoal().

120 {
121  ldir = normalize(ldir);
122  p = l0 - p;
123  // remove the component in line direction from p
124  return p - ((p * ldir) * ldir);
125 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ randompos()

ERASEABLE vector randompos ( vector  m1,
vector  m2 
)

Definition at line 49 of file vector.qh.

References ERASEABLE, random(), v, and vector().

Referenced by generator_draw(), and ons_ControlPoint_Icon_Think().

50 {
51  vector v;
52  m2 = m2 - m1;
53  v_x = m2_x * random() + m1_x;
54  v_y = m2_y * random() + m1_y;
55  v_z = m2_z * random() + m1_z;
56  return v;
57 }
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reflect()

ERASEABLE vector reflect ( vector  dir,
vector  norm 
)
Parameters
dirthe directional vector
normthe normalized normal
Returns
dir reflected by norm

Definition at line 133 of file vector.qh.

References ERASEABLE.

134 {
135  return dir - 2 * (dir * norm) * norm;
136 }
int dir
Definition: impulse.qc:89

◆ Rotate()

ERASEABLE vector Rotate ( vector  v,
float  a 
)

Definition at line 105 of file vector.qh.

References cos(), sin(), and vec2.

Referenced by HUD_Radar(), teamradar_2dcoord_to_texcoord(), teamradar_texcoord_to_2dcoord(), and waypoint_getSymmetricalPoint().

106 {
107  float a_sin = sin(a), a_cos = cos(a);
108  return vec2(v.x * a_cos + v.y * a_sin, -v.x * a_sin + v.y * a_cos);
109 }
vector v
Definition: ent_cs.qc:116
#define vec2(...)
Definition: vector.qh:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vec_epsilon()

ERASEABLE vector vec_epsilon ( vector  this,
float  eps 
)

Definition at line 148 of file vector.qh.

149 {
150  if (this.x > -eps && this.x < eps) this.x = 0;
151  if (this.y > -eps && this.y < eps) this.y = 0;
152  if (this.z > -eps && this.z < eps) this.z = 0;
153  return this;
154 }

◆ vec_reflect()

ERASEABLE vector vec_reflect ( vector  vel,
vector  norm,
float  bounce 
)

clip vel along the plane defined by norm (assuming 0 distance away), bounciness determined by bounce 0..1

Definition at line 142 of file vector.qh.

References ERASEABLE.

143 {
144  return vel - (1 + bounce) * (vel * norm) * norm;
145 }

◆ vlen_maxnorm2d()

ERASEABLE float vlen_maxnorm2d ( vector  v)

Definition at line 60 of file vector.qh.

References ERASEABLE, and max().

Referenced by HUD_Radar().

61 {
62  return max(v.x, v.y, -v.x, -v.y);
63 }
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vlen_minnorm2d()

ERASEABLE float vlen_minnorm2d ( vector  v)

Definition at line 66 of file vector.qh.

References ERASEABLE, max(), and min().

Referenced by HUD_Radar().

67 {
68  return min(max(v.x, -v.x), max(v.y, -v.y));
69 }
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ _vec2

noref vector _vec2

Definition at line 89 of file vector.qh.

◆ _vec3

noref vector _vec3

Definition at line 94 of file vector.qh.

◆ _vlen2

noref vector _vlen2

Definition at line 3 of file vector.qh.

◆ _vmul_a

noref vector _vmul_a

Definition at line 37 of file vector.qh.

◆ _vmul_b

noref vector _vmul_b

Definition at line 37 of file vector.qh.

◆ _yinvert

noref vector _yinvert

Definition at line 111 of file vector.qh.

◆ eX

const vector eX = '1 0 0'

Definition at line 44 of file vector.qh.

Referenced by BorderImage_recalcPositionWithText(), Button_draw(), checkColorCode(), crosshairpicker_crosshairToCell(), DemoConfirm_ListClick_Check_Gamestatus(), Dialog_addItemSimple(), Dialog_configureDialog(), draw_BorderPicture(), draw_ButtonPicture(), draw_CenterText(), draw_Picture_Aligned(), draw_setMousePointer(), Draw_ShowNames(), draw_VertButtonPicture(), DrawAmmoItem(), DrawCAItem(), DrawDomItem(), DrawNadeProgressBar(), DrawNumIcon_expanding(), hslimage_color(), HUD_Configure_DrawGrid(), HUD_GetTableSize_BestItemAR(), HUD_HealthArmor(), HUD_Main(), HUD_MinigameMenu_MouseInput(), HUD_Mod_CTF(), HUD_Mod_Keepaway(), HUD_Mod_KH(), HUD_Mod_NexBall(), HUD_Notify(), HUD_Panel_DrawHighlight(), HUD_Panel_DrawProgressBar(), HUD_Panel_DrawStrafeHUD(), HUD_Panel_Highlight(), HUD_Panel_HlBorder(), HUD_Physics(), HUD_PressedKeys(), HUD_Quickmenu_DrawEntry(), HUD_RaceTimer(), HUD_Score(), HUD_Score_Rankings(), HUD_StrafeHUD(), Image_updateAspect(), InfoMessages_drawstring(), InputBox_draw(), Item_ItemsTime_Allow(), ListBox_draw(), ListBox_mouseRelease(), m_draw(), m_init_delayed(), MainWindow_configureMainWindow(), MainWindow_draw(), preMenuDraw(), preMenuInit(), Scoreboard_AccuracyStats_Draw(), Scoreboard_DrawHeader(), Scoreboard_DrawItem(), Scoreboard_DrawOthers(), Scoreboard_ItemStats_Draw(), Scoreboard_MapStats_Draw(), Scoreboard_Rankings_Draw(), ServerList_Info_Click(), Slider_draw(), StrafeHUD_drawGradient(), UpdateConWidthHeight(), WarpZoneLib_MoveOutOfSolid(), XonoticCampaignList_drawListBoxItem(), XonoticCampaignList_resizeNotify(), XonoticCharmap_resizeNotify(), XonoticColorpickerString_loadCvars(), XonoticCreditsList_drawListBoxItem(), XonoticCvarList_drawListBoxItem(), XonoticDemoList_drawListBoxItem(), XonoticGametypeList_drawListBoxItem(), XonoticHUDSkinList_drawListBoxItem(), XonoticKeyBinder_drawListBoxItem(), XonoticLanguageList_drawListBoxItem(), XonoticMapList_doubleClickListBoxItem(), XonoticMapList_drawListBoxItem(), XonoticMapList_keyDown(), XonoticMapList_resizeNotify(), XonoticPicker_configureXonoticPicker(), XonoticPicker_keyDown(), XonoticPlayList_drawListBoxItem(), XonoticRegisteredSettingsList_getTooltip_cb(), XonoticScreenshotList_drawListBoxItem(), XonoticScreenshotList_startScreenshot(), XonoticServerList_drawListBoxItem(), XonoticServerList_keyDown(), XonoticServerList_positionSortButton(), XonoticSkinList_drawListBoxItem(), XonoticSoundList_drawListBoxItem(), and XonoticStatsList_drawListBoxItem().

◆ eY

const vector eY = '0 1 0'

Definition at line 45 of file vector.qh.

Referenced by BorderImage_recalcPositionWithText(), Button_draw(), c4_move(), checkColorCode(), crosshairpicker_crosshairToCell(), DemoConfirm_ListClick_Check_Gamestatus(), Dialog_addItemSimple(), Dialog_configureDialog(), draw_BorderPicture(), draw_ButtonPicture(), draw_Picture_Aligned(), draw_setMousePointer(), Draw_ShowNames(), draw_VertButtonPicture(), DrawAmmoItem(), DrawNumIcon_expanding(), GENERIC_COMMAND(), hslimage_color(), HUD_Configure_DrawGrid(), HUD_Draw(), HUD_GetTableSize_BestItemAR(), HUD_HealthArmor(), HUD_Main(), HUD_MinigameMenu_MouseInput(), HUD_Mod_CTF(), HUD_Mod_Keepaway(), HUD_Mod_KH(), HUD_Mod_NexBall(), HUD_Notify(), HUD_Panel_DrawHighlight(), HUD_Panel_DrawProgressBar(), HUD_Panel_Highlight(), HUD_Panel_HlBorder(), HUD_Physics(), HUD_Score(), HUD_StrafeHUD(), Image_updateAspect(), InputBox_draw(), ListBox_draw(), ListBox_mouseRelease(), m_draw(), m_init_delayed(), MainWindow_configureMainWindow(), MainWindow_draw(), nmm_in_mill(), pp_next_match(), preMenuDraw(), preMenuInit(), Scoreboard_DrawHeader(), Scoreboard_DrawItem(), Scoreboard_MakeTable(), Scoreboard_Rankings_Draw(), ServerList_Info_Click(), Slider_draw(), UpdateConWidthHeight(), WarpZoneLib_MoveOutOfSolid(), XonoticCampaignList_drawListBoxItem(), XonoticCampaignList_resizeNotify(), XonoticCharmap_resizeNotify(), XonoticColorpickerString_loadCvars(), XonoticCreditsList_drawListBoxItem(), XonoticCvarList_drawListBoxItem(), XonoticDemoList_drawListBoxItem(), XonoticGametypeList_drawListBoxItem(), XonoticHUDSkinList_drawListBoxItem(), XonoticKeyBinder_drawListBoxItem(), XonoticLanguageList_drawListBoxItem(), XonoticMapList_doubleClickListBoxItem(), XonoticMapList_drawListBoxItem(), XonoticMapList_keyDown(), XonoticMapList_resizeNotify(), XonoticPicker_configureXonoticPicker(), XonoticPicker_keyDown(), XonoticPlayList_drawListBoxItem(), XonoticRegisteredSettingsList_getTooltip_cb(), XonoticScreenshotList_drawListBoxItem(), XonoticScreenshotList_startScreenshot(), XonoticServerList_drawListBoxItem(), XonoticServerList_keyDown(), XonoticServerList_positionSortButton(), XonoticSkinList_drawListBoxItem(), XonoticSoundList_drawListBoxItem(), XonoticStatsList_drawListBoxItem(), and XonoticWeaponsList_drawListBoxItem().

◆ eZ